27 Mar
2007
27 Mar
'07
6:59 p.m.
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