If you want to convert an image to black and white, then pass cv2.COLOR_BGR2GRAY
flag to the cv2.cvtColor()
function.
import cv2 img = cv2.imread('/home/mohit/cardiff.jpg') if img is None: print('Image is not present.') else: img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) cv2.imshow(img) cv2.destroyAllWindows() cv2.waitKey(0)
Output
Original Image