1 | initial version |
your pixel , center_px = img[cx,cy]
is a numpy array, and ORANGE is a plain tuple, let's simulate it:
>>> pixel = np.array([4,3,2],dtype=np.uint8)
>>> ORANGE = (0,127,255)
>>> pixel == ORANGE
array([False, False, False], dtype=bool)
as you can see, you get a whole array of True, False values, one for each channel.
the solution, as stated in the error msg, is to check if the comparison is False for all channels, like:
>>> (pixel == ORANGE).all()
False
so, your if-statement should be:
if ((center_px == ORANGE).all()):
print "Orange"
2 | No.2 Revision |
your pixel , center_px = img[cx,cy]
is a numpy array, and ORANGE is a plain tuple, let's simulate it:
>>> pixel = np.array([4,3,2],dtype=np.uint8)
>>> ORANGE = (0,127,255)
>>> pixel == ORANGE
array([False, False, False], dtype=bool)
as you can see, you get a whole array of True, False values, one for each channel.
the solution, as stated in the error msg, is to check if the comparison is False True for all channels, like:
>>> (pixel == ORANGE).all()
False
so, your if-statement should be:
if ((center_px == ORANGE).all()):
print "Orange"