Matlab - 根据regionprops过滤标记的矩阵 [英] Matlab - filtering labeled matrix according to regionprops

查看:400
本文介绍了Matlab - 根据regionprops过滤标记的矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我标记了一张图片(使用 bwlabel ),之后我使用了 regionprops 来获取标记物体的怪癖。我现在要做的是过滤每个偏心度小于0.5的标记对象。

I have labeled an image (using bwlabel) and, after that, I've used regionprops to get the eccentricities of the labeled objects. What I want to do now is to filter every labeled object whose eccentricity is under 0.5.

到目前为止,我已经能够使用 find了获取符合条件的区域数量,但我不知道如何使用它们来过滤原始标记图像。

So far, I've been able to use find to get the number of those regions that match the criteria, but I don't know how to use them to filter the original labeled image.

例如:

labeledImage = bwlabel(originalImage);
properties = regionprops(labeledImage, 'eccentricity');
eccentricities = cat(1, properties.Eccentricity);

regions = find(eccentricities > 0.5);
% now what?

我尝试使用来做循环,但它很慢,我确信必须有一个隐藏的matlab函数来执行它。

I've tried to do it using for loops, but it's slow as hell and I'm sure there must be a hidden matlab function to do it.

推荐答案

In如果您仍在尝试解决此问题,请考虑以下示例:

In case you are still trying to solve this, consider the following example:

BW = imread('text.png');

CC = bwconncomp(BW);
L = labelmatrix(CC);

props = regionprops(CC, 'eccentricity');
idx = ( [props.Eccentricity] > 0.6);

BW2 = ismember(L,find(idx));    %# filter components with Eccentricity>0.6
BW3 = ismember(L,find(~idx));   %# filter components with Eccentricity<0.6

subplot(131), imshow(BW)
subplot(132), imshow(BW2)
subplot(133), imshow(BW3)

这篇关于Matlab - 根据regionprops过滤标记的矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆