Re: [Numpy-discussion] [SciPy-User] Simple pattern recognition

2009-09-21 Thread Gökhan Sever
Ahh my blindness and apologies :) The nice feeling of reinventing the wheel... Probably I forgot to reshape the image data in the first place before applying into ndimage.label(). However, this was a nice example to understand recursion, and get to know some basics of computer vision and few lib

Re: [Numpy-discussion] [SciPy-User] Simple pattern recognition

2009-09-21 Thread David Warde-Farley
I think Zachary is right, ndimage does what you want: In [48]: image = array( [[0,0,0,1,1,0,0], [0,0,0,1,1,1,0], [0,0,0,1,0,0,0], [0,0,0,0,0,0,0], [0,1,0,0,0,0,0], [0,1,1,0,0,0,0], [0,0,0,0,1,1,0], [0,0,0,0,1,1,1]]) In [57]: import scipy.ndimage as ndimage In [58]: labels, num_found = ndimage.la

Re: [Numpy-discussion] [SciPy-User] Simple pattern recognition

2009-09-21 Thread Gökhan Sever
ndimage.label works differently than what I have done here. Later using find_objects you can get slices for row or column basis. Not possible to construct a dynamical structure to find objects that are in the in both axis. Could you look at the stackoverflow article once again and comment back?

Re: [Numpy-discussion] [SciPy-User] Simple pattern recognition

2009-09-21 Thread Zachary Pincus
I believe that pretty generic connected-component finding is already available with scipy.ndimage.label, as David suggested at the beginning of the thread... This function takes a binary array (e.g. zeros where the background is, non-zero where foreground is) and outputs an array where each