【问题标题】:How can i delete certains regions of an image?如何删除图像的某些区域?
【发布时间】:2020-12-16 21:04:33
【问题描述】:

我有这张图片,其中包含我想通过索引消除的不同区域。

数字与此代码一起放置:

[labeled,numObject] = bwlabel(I12S,8);
stats = regionprops(labeled,'Eccentricity','Area','BoundingBox','centroid','Pixelidxlist');
areas = [stats.Area];
eccentricities = [stats.Eccentricity];

idxOfSkittles = find(eccentricities);
statsDefects = stats(idxOfSkittles);

figure(47);
hold  on;
for idx=1 : numObject
           if(idx==22 || idx== 34 || idx==50) %%index I want to delete
               
           else
                text(stats(idx).Centroid(1),stats(idx).Centroid(2),num2str(idx),'Color', [0.89, 0, 0]);
           end
           hold on;
end
imshow(labeled);

它还没有完成,我不知道如何获取 blob 的索引并删除它。

【问题讨论】:

  • 我不明白想要的输出是什么。上下图是一样的
  • 有区别,抱歉没有指出,22区和50区没了。
  • 如果您发布您的标记图像,或者至少是您的原始二进制图像,将会很有帮助。标记图像的像素值应该等于 blob 的索引(这就是标记的作用)。使用该图像,您可以将具有所需值的所有像素归零,例如 labeled(labeled == idx) = 0;

标签: matlab image-processing


【解决方案1】:

L 包含每个像素所属的区域索引(白色像素的连接体)。

I = im2bw(imread('blobs.png'));
L = bwlabel(I,8);
I2 = I;
I2(L==22 | L== 34 | L==50) = false; % this is how
imshowpair(I, I2);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多