[Numpy-discussion] Simple pattern recognition

David Warde-Farley dwf@cs.toronto....
Wed Sep 16 20:43:15 CDT 2009

On 16-Sep-09, at 8:22 PM, Gökhan Sever wrote:

> Hello all,
> I want to be able to count predefined simple rectangle shapes on an  
> image as
> shown like in this one: http://img7.imageshack.us/img7/2327/particles.png
> Which is in my case to count all the blue pixels (they are ice-snow  
> flake
> shadows in reality) in one of the column.
> What is the way to automate this task, which library or technique  
> should I
> study to tackle it.

Hey Gokhan,

Well, scipy.ndimage.label() will be handy once you extract those  
columns one by one. Is one contiguous blue region considered one  
object? In that case, you'd be done.

Once you've run label() you can use scipy.ndimage.find_objects() to  
get slices into the entire column that contain the contiguous region.

If you want to try and count individual rectangles that may overlap,  
there are likely dynamic programming algorithms that can find the  
biggest rectangles. The truth is you can probably even do something  
pretty naive and then compile it with Cython and it'll go blazing fast.

If you can be more specific about the kinds of "predefined simple  
rectangle shapes" we can probably tell you more.


More information about the NumPy-Discussion mailing list