Separation of rice grains . I want to separate out the grains that are darker in the image.
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
DGM
el 24 de Feb. de 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 comentarios
Ver también
Categorías
Más información sobre Get Started with Image Processing Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!