Image stats - going from Matlab to Python

tjv at hotmail.com tjv at hotmail.com
Mon Jan 31 01:41:00 EST 2005


Hi all,
I am working with images in python using PIL. I come from a MATLAB
background so I am finding it to be sometimes frustrating to do things
correctly and quickly. All I need to do is load an image and store a
list of pixel coordinates at which the alpha channel is set to 1.
In Matlab this would be easy...Lets say we have a 2x2x4 array that
represents the image. I would just type something like:

indices = find(im(:,:,3)==1);

then work with indices to get xy coords. Is there a similar way to
accomplish the same thing in python and PIL without having a nested for
loop and checking every pixel?
I would appreciate advice. Thanks very much for your attention!
-Tim




More information about the Python-list mailing list