讀取影象並轉換為灰度
import cv2
import numpy as np
img = cv2.imread('<your_image>')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imshow('image', img)
cv2.imshow('gray', gray)
cv2.waitKey(0)
cv2.destroyAllWindows()
import cv2
import numpy as np
img = cv2.imread('<your_image>')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imshow('image', img)
cv2.imshow('gray', gray)
cv2.waitKey(0)
cv2.destroyAllWindows()