色彩空间基础知识s???????http://t.csdn.cn/WWh6G
import cv2
cv2.namedWindow('color',cv2.WINDOW_NORMAL)
def callback():
pass
img = cv2.imread('C:\\Users\\Mengyang\\Desktop\\Myopencv\\image\\111.png')
colorspaces=[cv2.COLOR_BGR2RGBA,cv2.COLOR_BGR2BGRA,
cv2.COLOR_BGR2GRAY,cv2.COLOR_BGR2HSV,
cv2.COLOR_BGR2YUV]
#BGR转RGB BGR转BGR正常显示 BGR转灰度 转HSV 转YUV
cv2.createTrackbar('curcolor','color',0,len(colorspaces),callback)
while True:
index = cv2.getTrackbarPos('curcolor','color')
#颜色空间转换API
cvt_img = cv2.cvtColor(img,colorspaces[index])
cv2.imshow('color',cvt_img)
key = cv2.waitKey(1)
if key & 0xFF == ord('q'):
break
cv2.destroyAllWindows()
运行结果:
?
?
?
|