OpenCV:只能显示灰色
import cv2 as cvfilename = r'/Users/sg/Desktop/OpenCV//hsv.jpeg'
img = cv.imread(filename) # 读入文件
cv.imshow('source image',img) # imshow:显示原图像
cv.imshow('blue',img[:,:,0])
cv.imshow('green',img[:,:,1])
cv.imshow('res',img[:,:,2])
cv.waitKey()
gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
cv.imshow('gray',gray)
cv.waitKey()
hsv = cv.cvtColor(img,cv.COLOR_BGR2HSV)
cv.imshow('Hue',hsv[:,:,0])
cv.imshow('saturation',hsv[:,:,1])
cv.imshow('Value',hsv[:,:,2])
cv.waitKey()
cv.destroyAllWindows()
只有原图能显示彩色
其他的,比如green,blue什么的都是显示灰色! cv.imshow('source image',img) # imshow:显示原图像
cv.imshow('blue',img[:,:,0])
cv.imshow('green',img[:,:,1])
cv.imshow('res',img[:,:,2])
这段代码中:
img[:,:,0]
img[:,:,1]
img[:,:,2]
已经改变颜色(RGB)了
页:
[1]