Image Segmentation not working properly
3 次查看(过去 30 天)
显示 更早的评论
I have written a code to identify the green and black color seeds and then calculate the ratio of the area occupied by green seeds to that of black seeds. I used the color thresholder app to identify the two colors and generated 2 functions- one to segment the green color and another to segment the black. I saved the 2 segmented images in Binary format. Then I found each of the area using bwarea() and hence found out their ratio.


However, the result so obtained is not accurate. For 50:50 ratio (black:green), I get 42:68 and for 70:30, I get 40:60.
Also I am unable to use this function on other similar images with different seeds proportion. Displaying both the binary images using imshowpair(bImg, gImg, 'falsecolor'), I get :


Please tell me where I have gone wrong and what is the solution? Thank you.
10 个评论
PeterHaultan
2018-10-7
Does this help?
I = imread('lena.jpg');
I = rgb2gray(I);
[r,c] = size(I);
L = kmeans(I(:),5);
I = reshape(L,[r,c]);
mask25 = (I==2)|(I==5);
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
