def calculateTransitions(im):
h, w = im.shape[0], im.shape[1]
prev = im[0,0]
n = 0
for x in range(1, h):
for y in range(1, w):
curr = im[x,y]
# check if the is black to white transition
n = n+1 if curr == 255 and prev == 0 else n
prev = curr
return n
There is something wrong with
n = n+1 if curr == 255 and prev == 0 else n
prev = curr
return n
this part
in findBB(im)
13 for x in range(h):
14 for y in range(w):
---> 15 if (im[x,y] == 0):
16 right = x if x > right else right
17 left = x if x < left else left
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I have tried a lot but still not able to solve this error. Please help