我只想得到一张有葡萄和三个圆圈(红、绿、蓝)的图像。 [我需要去除所有污迹]。 我该如何改进我的代码?
这是我的代码:
RGB = imread('img_3235.jpg');
GRAY = rgb2gray(RGB);
threshold = graythresh(GRAY);
originalImage = im2bw(GRAY, threshold);
originalImage = bwareaopen(originalImage,250);
imshow(originalImage);
CC = bwconncomp(originalImage); %Ibw is my binary image
stats = regionprops(CC,'pixellist');
这是我的图片 (img_3235.jpg)。
这是我的代码的结果:
最佳答案
您可以使用 IMCLOSE
执行形态闭合.
se = strel('disk', 10); %# structuring element
closeBW = imclose(originalImage,se);
figure, imshow(closeBW);
closing通过 B 对 A 进行膨胀,然后对得到的结构进行 B 的腐 eclipse ,获得 B 对 A 的影响。
关于matlab - 从二值图像中去除噪声,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12820571/