zhiqingstudy

Be a young person with knowledge and content

The color space of Opencv can be converted to each other. It is very common for Opencv to convert the color space.
Color space conversion api: cvtColor (img, colorspace)


import cv2
from cv2 import WINDOW_NORMAL
from matplotlib import colors

# 创建回调函数
def callback():
    pass

# 创建窗口
cv2.namedWindow('color',cv2.WINDOW_NORMAL)
# 选择一张你的图片
img=cv2.imread('图片地址和图片名')

# 定义色彩空间转化列表
colorspace=[cv2.COLOR_BGR2RGBA,cv2.COLOR_BGR2BGRA,cv2.COLOR_BGR2GRAY,cv2.COLOR_BGR2HSV_FULL,cv2.COLOR_BGR2YUV]

# 创建trackbar
cv2.createTrackbar('bar','color',0,len(colorspace),callback)

while 1:
    index=cv2.getTrackbarPos('bar','color')
    # 颜色空间转换api
    cvt_img=cv2.cvtColor(img,colorspace[index])
    cv2.imshow('color',cvt_img)
    key=cv2.waitKey(10)
    if key==ord('q'):
        break
cv2.destroyAllWindows()
comment
head sculpture
Code:
Related

Why you shouldn't stay at a job for more than 2 years?

3 harsh facts long-distance relationships

how to keep your girlfriend interested in a long-distance relationship




Unless otherwise specified, all content on this website is original. If the reprinted content infringes on your rights, please contact the administrator to delete it
Contact Email:2380712278@qq.com

Filing number:皖ICP备19012824号