help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Selecting elements in an image based on area


From: Jordi Gutiérrez Hermoso
Subject: Re: Selecting elements in an image based on area
Date: Wed, 13 Jul 2011 12:51:56 -0500

2011/7/13 Samuel Setchell <address@hidden>:
> I think I have grabbed one designed for MATLAB....which had been
> ported for mac.

That's odd. I wonder why would someone write one of those. Both Octave
and Matlab ship their own, and an m-file implementatino of bwlabel is
bound to be very slow.

> seems to work fine. I tried running regionprops.m on my output and
> got:
>
> ans =
> {
>  1x381 struct array containing the fields:
>
>    Area
>    Centroid
>    BoundingBox
> }
>
> Is this correct?

Looks like it. Now assign ans to some variable, say regions = ans;
and do

    idx = find([regions.Area] > lo & [regions.Area] < hi)

to give you the indices of the regions that have area higher than your
lower bound lo and lower than your upper bound hi. Now if imlabel is
the outout of bwlabel, you can do

    mask = any(bsxfun(@eq, x, reshape(idx, 1,1, length(idx))),3);

to get a binary mask of the regions that have the size within [lo,hi].

HTH,
- Jordi G. H.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]