Answers for "convert black and white image in openv"

3

opencv convert to black and white

import cv2
  
originalImage = cv2.imread('C:/Users/N/Desktop/Test.jpg')
grayImage = cv2.cvtColor(originalImage, cv2.COLOR_BGR2GRAY)
  
(thresh, blackAndWhiteImage) = cv2.threshold(grayImage, 127, 255, cv2.THRESH_BINARY)
 
cv2.imshow('Black white image', blackAndWhiteImage)
cv2.imshow('Original image',originalImage)
cv2.imshow('Gray image', grayImage)
  
cv2.waitKey(0)
cv2.destroyAllWindows()
Posted by: Guest on May-22-2020
0

convert image to binary python

img=cv2.imread('<image path>')gray_img=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
Posted by: Guest on June-06-2020

Code answers related to "convert black and white image in openv"

Python Answers by Framework

Browse Popular Code Answers by Language