Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV imread transparency gone

I have an image (a captcha) that I download from the web.

Initial Image

When I loaded to opencv it seems to loose its properties or simply mixes the transparent background with the dark/black colors:

Processed Image

Currently the code does nothing but loading a writing again:

captchaImg = cv2.imread('captcha1.png')
cv2.imwrite("captcha2.png", captchaImg)

I have tried loading also with options 0, 1, 2, 3 but the result is the same.

like image 223
roccolocko Avatar asked Nov 02 '25 04:11

roccolocko


1 Answers

Using the provided constants might help. I do the equivalent of

captchaImg = cv2.imread('captcha1.png', cv2.IMREAD_UNCHANGED)

which reads the alpha channel (if there is one). The REPL says that cv2.IMREAD_UNCHANGED is -1

like image 152
Dave W. Smith Avatar answered Nov 04 '25 20:11

Dave W. Smith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!