Ludwig wrote: > 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.
The Python keywords "and", "or", and "not" try to evaluate the truth value of the objects. We cannot override them to operate elementwise. Instead, the operators &, |, and ~, respectively, are the elementwise operators on arrays of booleans. Thus, you want this: indexes = where((image1>0) & (image2>0) & (sigma<quality)) However, also note that numpy arrays support indexing with boolean arrays, so the where() is superfluous. mask = (image1>0) & (image2>0) & (sigma<quality) result[mask] = i -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion