在python中使用Open CV的调色板

时间:2017-07-20 05:58:42

标签: python-3.x opencv image-processing ipython color-palette

使用OpenCv我尝试通过从User获取RGB值来做一个简单的调色板。我使用numpy创建了一个黑色图像,并用用户输入的BGR值更改了整个图像并尝试显示它。不幸的是,Python和Ipython停止响应

import cv2
import numpy as np

while(1):

    #Getting RGB values from user

    r=int(input("Enter R value"))
    g=int(input("Enter G value"))
    b=int(input("Enter B value"))

    #Making a Black image
    img=np.zeros((520,520,3),np.uint8)

    #Changing whole image with user defined RGB values
    img[:]=[b,g,r]

    #Making the Image to display
    cv2.imshow("Pallete",img)

    #Breaking the process while pressing ESC key
    key=cv2.waitKey(1)&0xFF
    if(key==27):
        break

    #My IPython Window is not Responding and gets strucked

0 个答案:

没有答案