How to randomly choose three pixels and use their values in kmeans
1 次查看(过去 30 天)
显示 更早的评论
1 个评论
KALYAN ACHARJYA
2022-1-26
编辑:KALYAN ACHARJYA
2022-1-26
Please refer the below link for your reference
回答(1 个)
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
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!