gpt4 book ai didi

algorithm - 如何过滤带有不需要区域和空洞区域的二值图像

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:43:32 25 4
gpt4 key购买 nike

我有一个难题需要你的帮助。我有一个二进制图像,它保留了一些不需要的区域(小白点)和孔区域(图 1)。我的想法是,首先我将通过计算这些区域的面积来删除不需要的区域,然后用小面积值进行过滤。在第二步,我填充孔区域以使图像清晰。您认为填充孔区域的最佳方法是什么。你有什么想法解决它。你能帮我用matlab实现吗?太感谢了。这是我删除不需要的区域的引用代码。但它需要阈值项。您可以在here下载图片测试

function exImage=rmUnwantedRegion(Img,threshold)
lb = bwlabel(Img);
st = regionprops(lb, 'Area', 'PixelIdxList' );
toRemove = [st.Area] <threshold; % fix your threshold here
exImage = Img;
exImage( vertcat(st(toRemove).PixelIdxList ) ) = 0; % remove
end

enter image description here

最佳答案

这是一个基于我的评论的示例实现:

subplot(1,3,1), imshow(input);
title('Original Image');

计算图像的开口:

openInput=bwareaopen(input, 20);    
subplot(1,3,2), imshow(bwareaopen(input, 20));
title('Opened Image');

以及随后的关闭:

ClosedInput = imclose(openInput,ones(10)); 
subplot(1,3,3), imshow(ClosedInput);
title('Closed Image');

结果:

Morph filtered image

关于algorithm - 如何过滤带有不需要区域和空洞区域的二值图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23365276/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com