How to load png images with 4 channels?

后端 未结 5 1233
暗喜
暗喜 2020-12-03 00:45

I have been trying to load .png files with transparency channel (RGB and Alph) with no luck. It appears that openCV strips the 4th channel out of the image. Is there any met

5条回答
  •  爱一瞬间的悲伤
    2020-12-03 01:13

    The best possible way to load a png image with all 4 channels is ;

    img= cv2.imread('imagepath.jpg',negative value)
    

    As per openCV documentation,
    If Flag value is,
    1) =0 Return a grayscale image.
    2) <0 Return the loaded image as is (with alpha channel).

提交回复
热议问题