how can I convert this black and white image to this gray coloured image?
Black and White Image
Grey Scale Image
in python
CodePudding user response:
The best that you can do in Python/OpenCV is just change black to gray in your image.
Input:
import cv2
import numpy as np
img = cv2.imread('bw_img.png', 0)
result = img.copy()
result[result==0] = 128
cv2.imwrite('bw_img_grayed.png', result)
cv2.imshow('result', result)
cv2.waitKey(0)
Result:
CodePudding user response:
try this:
import cv2
from PIL import Image
cur_frame = Image.open('image.jpg')
gray_image = cv2.cvtColor(cur_frame, cv2.COLOR_BGR2GRAY)
cv2.imshow("show image", gray_image)