1 | initial version |
load the image as grayscale,single channel intensity image, not as a color one:
img = cv2.imread(filename, cv2.IMREAD_GRAYSCALE)
binarize it (the opencv way). you can use cv2.threshold
, cv2.compare
, or similar functions, resulting in an np.uint8
array, where each "on" pixel is 255, and each "off" one is 0.
if you really need binary (True/False) values, you can use numpy operations, like: bin = img > 20
, just note, that those are unusable for further opencv processing (where [0..255] is expected)