Separation of rice grains . I want to separate out the grains that are darker in the image.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
The image contains rice grains. I want to separate out the darker rice grains in image 'Main'. I have marked the ones which needed to be separate out in attachment 'Result'. I also want to count the no. of lighter and darker grians. I know the image has a lot of noise because i captured the grains by keeping them on laptop screen. Apologies for that.
0 Kommentare
Antworten (1)
DGM
am 24 Feb. 2022
Segmentation might be a bit easier with a bit of a diffuser to deal with the bg. The median filter (or just downscaling the image) helps deal with it in this case.
A = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/905805/Main.jpg');
A = rgb2gray(A);
A = medfilt2(A,[10 10]);
mask = imclearborder(A<150);
mask = bwareaopen(mask,2000);
imshow(mask)
S = regionprops(mask,A,'meanintensity','centroid');
C = vertcat(S.Centroid);
graincolor = vertcat(S.MeanIntensity);
grainmask = graincolor<60;
figure
imshow(A); hold on
for b = 1:numel(S)
if grainmask(b)
plot(C(b,1),C(b,2),'bo','markersize',25);
else
plot(C(b,1),C(b,2),'ro','markersize',25);
end
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with Image Processing Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!