【问题标题】:Remove noise from a binary image从二值图像中去除噪声
【发布时间】:2012-10-11 00:34:05
【问题描述】:

我想得到一张只有葡萄和三个圆圈(红、绿、蓝)的图像。 [我需要去除所有的污迹]。 我该如何改进我的代码?

这是我的代码:

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)。

这是我的代码的结果:

【问题讨论】:

    标签: matlab image-processing computer-vision


    【解决方案1】:

    您可以使用IMCLOSE 执行形态闭合。

    se = strel('disk', 10); %# structuring element
    closeBW = imclose(originalImage,se);
    figure, imshow(closeBW);
    

    B 对 A 的 closing 是通过 B 对 A 进行膨胀,然后由 B 侵蚀所得结构而获得的。

    【讨论】:

    • 它有效!谢谢你!我正在用另一个问题更新我的主题:/谢谢!
    【解决方案2】:

    另一种解决方案是在应用阈值之后使用适当的窗口大小进行中值滤波:

     ...
     originalImage = im2bw(GRAY, threshold);
     originalImage = medfilt2(originalImage,[37 37],'symmetric'); 
     originalImage = bwareaopen(originalImage,250);
     figure, imshow(originalImage);
    

    【讨论】:

    • 谢谢!我会检查哪个选项对我来说更重要。非常感谢您!! :]]
    猜你喜欢
    • 2021-02-28
    • 2012-03-08
    • 1970-01-01
    • 2014-05-22
    • 2017-06-23
    • 2023-04-05
    • 1970-01-01
    • 2021-08-16
    • 2011-12-30
    相关资源
    最近更新 更多