Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

convert image to black and white python

#applying thresholding technique to return black and white image (threshold = 127 = 255/2)
import cv2
  
originalImage = cv2.imread('image.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)
Source by techtutorialsx.com #
 
PREVIOUS NEXT
Tagged: #convert #image #black #white #python
ADD COMMENT
Topic
Name
7+6 =