Ask Your Question

Revision history [back]

Doing an adaptive thresholding to a grayscale image

I have a png image which is in grayscale 'test.png'. I need to do an adaptive thresholding to this image. I am using opencv2.

image = cv2.imread('test_big.png')
im = cv2.adaptiveThreshold(image, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV, 11, 2)

I am not able to do thresholding since the image is not in grayscale. So I tried to read the image as grayscale

image = cv2.imread('test_big.png',1)

Now I can do the thresholding but the output will be a blue and red image instead of black and white. Can anyone help Plsss