How can i get label in condition

2 views (last 30 days)
Tokyo Kim
Tokyo Kim on 22 Feb 2013
Hi everyone.
I searching a method for connected component.
I used this code.
[lbimg numBlob] = bwlabel(resultG, 8);
stats = regionprops(lbimg, 'BoundingBox', 'Area');
allBlobAreas = [stats.Area];
%loop through all blobs, putting up Bounding box
for k = 1 : numBlob
boundingBox = stats(k).BoundingBox; % Get box.
x1 = boundingBox(1);
y1 = boundingBox(2);
x2 = x1+boundingBox(3)-1;
y2 = y1+boundingBox(4) -1;
verticesX = [x1 x2 x2 x1 x1];
verticesY = [y1 y1 y2 y2 y1];
aspectRatio(k) = boundingBox(3) / boundingBox(4);
end
as you know, i got a aspect ratio of each label.
but i want to get a any result image(or Mat) labels in my condition.
example
if aspectRatio(k) < 1.6
RR = 1;
else
RR = 0;
... exactly..how can i get filtered labels with aspectRatio.
I'm not good at English. sorry..please note...
thanks for watching

Answers (1)

Walter Roberson
Walter Roberson on 22 Feb 2013
RR = find(aspectRation < 1.6);
  2 Comments
Tokyo Kim
Tokyo Kim on 22 Feb 2013
Edited: Tokyo Kim on 22 Feb 2013
i think... are you sure this comment code? undefined valuable 'aspectRation'. i think aspectRatio is right valuable. but. in this case i can't use this code. i just input your code after 'end' . so, can you teach me correct code T_T...?
Walter Roberson
Walter Roberson on 22 Feb 2013
Sorry, aspectRatio is correct.
What happens when you attempt to use the code ?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!