Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python image black and white

from PIL import Image
img = Image.open("image.jpg")
img.convert("1").save("result.jpg")
Comment

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)
Comment

PREVIOUS NEXT
Code Example
Python :: discord.py send messages 
Python :: What happens when you use the built-in function any() on a list? 
Python :: im save to a bytes io python 
Python :: python get index of first element of list that matches condition 
Python :: python zip extract directory 
Python :: convert pandas column type 
Python :: how to create random tensor with tensorflow 
Python :: finding the index of an element in a pandas df 
Python :: selenium assert text on page python 
Python :: python remove articles from string regex 
Python :: python textbox 
Python :: reverse python dict 
Python :: python get number of days 
Python :: read a file and split the words python 
Python :: if list item is found in string get that item python 
Python :: merge two df 
Python :: equal sides of an array python 
Python :: python for loop in one line 
Python :: pi in python math 
Python :: how to round a number down in python 
Python :: convert a number column into datetime pandas 
Python :: no such table: django_session admin 
Python :: get first x characters of string python 
Python :: flask read form data 
Python :: catch error python 
Python :: port 5432 failed: timeout expired 
Python :: django and operator 
Python :: python warning 
Python :: max pooling tf keras 
Python :: how to check whole number in python 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =