Change image colour using python

Published: 25 October 2020
on channel: Mukesh
54
7

code for above program

pip install opencv-python

import cv2

#reading image data

img = cv2.imread('E:\mukesh\python\lion.jpg' , cv2.IMREAD_GRAYSCALE)

defining a threshold 128 is a gray colour

colour = 128

threshold the image

img_1 = cv2.threshold(img , colour , 255 , cv2.THRESH_BINARY)[1]

saving image in grey colour

cv2.imwrite('E:\mukesh\python\liongray.jpg' , img_1)


On this page of the site you can watch the video online Change image colour using python with a duration of hours minute second in good quality, which was uploaded by the user Mukesh 25 October 2020, share the link with friends and acquaintances, this video has already been watched 54 times on youtube and it was liked by 7 viewers. Enjoy your viewing!