1import cv2
2
3originalImage = cv2.imread('C:/Users/N/Desktop/Test.jpg')
4grayImage = cv2.cvtColor(originalImage, cv2.COLOR_BGR2GRAY)
5
6(thresh, blackAndWhiteImage) = cv2.threshold(grayImage, 127, 255, cv2.THRESH_BINARY)
7
8cv2.imshow('Black white image', blackAndWhiteImage)
9cv2.imshow('Original image',originalImage)
10cv2.imshow('Gray image', grayImage)
11
12cv2.waitKey(0)
13cv2.destroyAllWindows()
14
1import cv2
2
3originalImage = cv2.imread("PATH/TO/IMG")
4grayImage = cv2.cvtColor(originalImage, cv2.COLOR_BGR2GRAY)