Code: Select all
import cv2
def grey():
img = cv2.imread('1.jpg')
for x in range(img.shape[0]):
for y in range(img.shape[1]):
if img[x,y,0] == img[x,y,1] == img[x,y,2]:
grey = img
else:
grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
return grey
Code: Select all
import cv2
def grey():
img = cv2.imread('1.jpg')
for x in range(img.shape[0]):
for y in range(img.shape[1]):
if img[x,y,0] == img[x,y,1] == img[x,y,2]:
grey = img
else:
grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
return grey