how to convert grayscale image to binary image in python code example
Example 1: python image to grayscale
from PIL import Image
img = Image.open("image.jpg")
img.convert("L").save("result.jpg")
Example 2: convert image to binary python
img=cv2.imread('<image path>')
gray_img=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
Example 3: convert image to binary python
img=cv2.imread('<image path>')gray_img=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)