[Numpy-discussion] Complex 'where' expression

Ludwig ludwigbrinckmann@gmail....
Tue Mar 27 12:50:46 CDT 2007

A bit new to numpy, trying to move over some IDL code.

I have a complex array selection expression, where I need an array of indexes as
a result, so I can use this as a selection expression to apply changes to a
different array.

I have two images, image1 and image2, plus an array sigma, the result of a
previous calculation. All have the same shape. quality is a scalar threshold.

I need the indexes where image1 and image2 are not 0 and the sigma value at that
point is lower than my threshold. I then take these indices and store some value
against this in a different array.

In pseudo code:

indexes = where(image1 > 0 and image2 > 0 and sigma < quality)
result[indexes] = i # scalar

When I run this numpy tells me that the that the truth value of the array
comparison is ambiguous -- but I do not want to compare the whole arrays here,
but the value for every point. 

How do I do this



More information about the Numpy-discussion mailing list