How to randomly choose three pixels and use their values in kmeans

1 Ansicht (letzte 30 Tage)
Nadav Alkaslassy
Nadav Alkaslassy am 26 Jan. 2022
Kommentiert: Image Analyst am 11 Feb. 2022

Antworten (1)

Image Analyst
Image Analyst am 26 Jan. 2022
Bearbeitet: Image Analyst am 26 Jan. 2022
See my attached example for how to do kmeans on a color image. In general kmeans is not a good color segmentation method. You'd probably be better off using discriminant analysis (like the other attached demo).
You might also be interested in the color frequency image code from the File Exchange:
  6 Kommentare
Image Analyst
Image Analyst am 27 Jan. 2022
kmeans starts its process with starting locations. If you don't specify them, I believe it picks them at random. So if you want random starting locations, you don't need to do anything. Of course you can specify starting locations if you have a good idea of where to start, but if you just pick random ones, it's just like the function picking random ones. So why pick random ones yourself when the function will do it for you if you don't specify the starting location?
The final image should be a classified image with 3 values: 1, 2, and 3, which you can map to any colors you want. It should not be a single scalar. Again, see my full demo for instructions.
Make sure you build Z like I did, not like you did.
Attach your image and m-file if you need more help.
Image Analyst
Image Analyst am 11 Feb. 2022
I think you forgot to attach face.jpg.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by