[Numpy-discussion] color filtering

Stéfan van der Walt stefan at sun.ac.za
Wed Sep 17 15:44:43 EDT 2008


2008/9/17 paul taney <paultaney at yahoo.com>:
>> # silly algorithm for guessing blue pixels
>> >>> bluemask = (a[...,2] > 1.25*a[...,1]) & (a[...,2] > 1.25*a[...,0])
>
> Thanks Stéfan, that"s very cool.  But the xy coords were tossed.
> Can you show me a cheap way to return a line:
>
>    line=[(3, 0), (2, 1), (0, 2), (1, 2), (3, 2), (0, 3), (4, 3), (3, 4)]
>
> type-o-thing?

Sure, how about

np.array(bluemask.nonzero()).swapaxes(0,1)

Does that do what you want?

Cheers
Stéfan



More information about the NumPy-Discussion mailing list