I am converting a code from Matlab to Python. The code in Matlab is:
x = find(sEdgepoints > 0 & sNorm < lowT);
sEdgepoints(x)=0;
Both arrays are of same size, and I am basically creating a mask.
I read here that nonzero() in numpy is equivalent to find(), so I used that. In Python, I have dstc for sEdgepoints and dst for sNorm. I have also directly put in lowT = 60. So, the code was
x = np.nonzero(dstc > 0 and dst < 60)
dstc[x] = 0
But, I get following error:
Traceback (most recent call last):
File "C:\Python27\Sheet Counter\customsobel.py", line 32, in <module>
x = np.nonzero(dstc > 0 and dst < 60)
ValueError: The truth value of an array with more than one element is
ambiguous. Use a.any() or a.all()
I read about the usage of a.any()/a.all() in this post, and I am not sure how that will work. So, I have two questions: 1. If it does, which array to use? 2. If I am correct and it does not work, how to convert the code?