简体   繁体   English

Opencv Python维护零像素

[英]Opencv Python maintain null pixel

I have an image I am trying to run a classification on. 我有一张要进行分类的图片。 This is the image opened in Paint 2: 这是在Paint 2中打开的图像: 在此处输入图片说明

And this is the image loaded into opencv when I do imshow. 这是我执行imshow时加载到opencv中的图像。 在此处输入图片说明

My Question is how can I maintain the null area of the image where there are no pixel values when I load the image into python and opencv. 我的问题是,当我将图像加载到python和opencv中时,如何维护没有像素值的图像的空白区域。 It is currently being received as white (255,255,255)? 目前收到的是白色(255,255,255)吗?

Code: 码:

img = cv2.imread('/Volumes/EXTERNAL/ClassifierImageSets/Origional_2.png',cv2.IMREAD_UNCHANGED)
    imgS = cv2.resize(img,(0,0), fx=0.5, fy=0.5)
    cv2.imshow("result",imgS)
    while (1):
        k = cv2.waitKey(0)
        if k==27:
            cv2.destroyAllWindows()
            break

Try to load the image using 尝试使用加载图像

img = cv2.imread('path_to_image',cv2.IMREAD_UNCHANGED)

The cv2.IMREAD_UNCHANGED parameter should load the image as it is with default alpha value cv2.IMREAD_UNCHANGED参数应按默认Alpha值加载图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM