I read a JPG image in Python with cv2.imread() and added an alpha channel with random values. I used cv2.imwrite() to store the modified image after that. However, I got a different display result when I use cv2.imread() and show() from PIL.Image library.
The code is shown below:
cv2.imwrite('D:/Hygon/python/block_comp/BlockCompression/test_rgba.png',img_origin) cv2.imshow('Example - Show RGBA image in window',img_origin) a=Image.open('D:/Hygon/python/block_comp/BlockCompression/test_rgba.png') a.show()
The result is shown in the following diagram:
Could you help me figure out what’s happening and which one is the real image? Thanks a lot.
Python: 3.10.9 (anacoda)