Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在OpenCV Tkinter Python中实现颜色转换器的选择_Python_Image_Opencv_Tkinter_Cv2 - Fatal编程技术网

在OpenCV Tkinter Python中实现颜色转换器的选择

在OpenCV Tkinter Python中实现颜色转换器的选择,python,image,opencv,tkinter,cv2,Python,Image,Opencv,Tkinter,Cv2,各位。我有一个关于在Python中实现多选颜色转换器的问题。 这是密码 选项数组 effectoption = ["Effect RGB", "Effect HSV", "Effect LAB", "Effect RGBA", "Effect HLS"] 否则 #if

各位。我有一个关于在Python中实现多选颜色转换器的问题。 这是密码

选项数组

effectoption = ["Effect RGB",
                "Effect HSV",
                "Effect LAB",
                "Effect RGBA",
                "Effect HLS"]
否则

#if effectoption[0] :
    #edited = cv2.cvtColor(edited, cv2.COLOR_BGR2RGB)
#elif effectoption[1] :
    #edited = cv2.cvtColor(edited, cv2.COLOR_BGR2HSV)
#elif effectoption[2] :
    #edited = cv2.cvtColor(edited, cv2.COLOR_BGR2LAB)
#elif effectoption[3] :
    #edited = cv2.cvtColor(edited, cv2.COLOR_BGR2RGBA)
#elif effectoption[4] :
    #edited = cv2.cvtColor(edited, cv2.COLOR_BGR2HLS)
当前代码为

image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
颜色转换器的设置在这里

opt = tk.OptionMenu(window, var1, *effectoption)
opt.config(width=90, font=('Helvetica', 12))
opt.pack(side="top")
问题是如何在图像上正确实现(当用户将颜色转换器更改为“图像”时)

更新 我忘了在这里添加代码

def insertbutton_cb():
#global orima, editima
global image

picpath = filedialog.askopenfilename(
    title="Select An Image",
    filetypes=(("JPG Files", "*.jpg"), ("GIF Files", "*.gif*"), ("PNG files", "*.png"), ("JPEG Files", "*.jpeg"))
)

if len(picpath) > 0:

    image = cv2.imread(picpath)
    edited = cv2.imread(picpath)

    edited = np.array(edited)
    #edited = PILImage.fromarray(edited.astype('uint8'))

    print(picpath)
    print('Original Dimensions : ',image.shape)
    print(image)
    print(edited) #skip to image = cv.2

    image = cv2.resize(image, dim, interpolation = cv2.INTER_AREA)
    edited = cv2.resize(edited, dim2, interpolation = cv2.INTER_AREA)

    #edited = cv2.cvtColor(edited, cv2.COLOR_BGR2RGB) this code was mean to replace for implementing effectoption

    on_change(image) #the error is from here which cause futureelement

    image =  PILImage.fromarray(image)
    edited = PILImage.fromarray(edited)

    image = np.uint8(image)
    edited = np.uint8(edited)

    bright = 255
    contrast = 100
    saturation = 50

    cv2.namedWindow(WINDOW_NAME)
    cv2.createTrackbar('Bright', WINDOW_NAME, 255, 2 * 255, bccb)
    cv2.createTrackbar('Contrast', WINDOW_NAME, 255, 2 * 127, bccb)
    cv2.createTrackbar('Saturation', WINDOW_NAME, 255, 2 * 255, bccb)
    #functionbcs(edited, 0, 0, 0)
    bccb(0, 0, 0)
    teste = controller(image, bright, contrast, saturation)
    cv2.imshow(WINDOW_NAME, teste)