Converting an OpenCV Image to Black and White

后端 未结 7 1521
逝去的感伤
逝去的感伤 2020-11-29 17:38

How do you convert a grayscale OpenCV image to black and white? I see a similar question has already been asked, but I\'m using OpenCV 2.3, and the proposed solution no long

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 17:59

    Simply you can write the following code snippet to convert an OpenCV image into a grey scale image

    import cv2
    image = cv2.imread('image.jpg',0)
    cv2.imshow('grey scale image',image)
    

    Observe that the image.jpg and the code must be saved in same folder.

    Note that:

    • ('image.jpg') gives a RGB image
    • ('image.jpg',0) gives Grey Scale Image.

提交回复
热议问题