Skip to content Skip to sidebar Skip to footer

Using Opencv / Numpy To Find White Pixels In A Color Image Using Python

I have an image I loaded using opencv, that I would like to find pixels that are white. input_img = [[[255,255,255], [0,127,255]], [[255,255,255], [255,127,255]]] sho

Solution 1:

How about

(input_img == 255).all(axis=2)

Solution 2:

This should do it

input_img = [[[255,255,255], [0,127,255]],
         [[255,255,255], [255,127,255]]]
white = np.array(np.sum(input_img, axis=-1) == 765, dtype=np.int32)

Post a Comment for "Using Opencv / Numpy To Find White Pixels In A Color Image Using Python"