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

조회 수: 1 (최근 30일)
Nadav Alkaslassy
Nadav Alkaslassy 2022년 1월 26일
댓글: Image Analyst 2022년 2월 11일

답변 (1개)

Image Analyst
Image Analyst 2022년 1월 26일
편집: Image Analyst 2022년 1월 26일
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
Image Analyst
Image Analyst 2022년 1월 27일
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 2022년 2월 11일
I think you forgot to attach face.jpg.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by