import cv2 import numpy as np image=cv2.imread('path/to/image.jpg') ### binarising image gray_scale=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) th1,img_bin = cv2.threshold(gray_scale,150,225,cv2.THRESH_BINARY)