Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. load the image as grayscale,single channel intensity image, not as a color one:

    img = cv2.imread(filename, cv2.IMREAD_GRAYSCALE)

  2. 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.

  3. 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)