필터 지우기
필터 지우기

Separation of rice grains . I want to separate out the grains that are darker in the image.

조회 수: 3 (최근 30일)
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.

답변 (1개)

DGM
DGM 2022년 2월 24일
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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by