[SciPy-User] Image analysis: Counting masked areas

David Warde-Farley dwf@cs.toronto....
Wed Oct 21 22:42:16 CDT 2009


On Wed, Oct 21, 2009 at 12:12:00AM -0700, Michael Aye wrote:
> Dear all,
> is it possible to count the areas in an image, that have been masked
> by some condition?
> I need to count all areas in an image darker than a certain value.
> Masking is no problem, but how do I count independent areas? I was
> thinking just to look at the masked array, but then a pixel-by-pixel
> check if the neighbour pixel is masked as well to find *independent*
> masked areas sees numerically very costly.
> Isn't there a better way?

In Python, it would be, yes.

Have a look at scipy.ndimage.label(), it does exactly this. 

David



More information about the SciPy-User mailing list