Read a gray scale or monochrome image with alpha channel [closed]

asked 2016-09-15 00:12:27 -0600

kampta gravatar image

updated 2016-09-15 00:59:10 -0600

berak gravatar image

Repeating a question from stackoverflow.

How can I read a gray scale image in OpenCV with alpha channel? For example, if I try to read the following image, all I get is 2d array of all zeros.

C:\fakepath\1.png

image = cv2.imread('1.png', cv2.IMREAD_UNCHANGED)
image.shape

(480, 960)
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-09-17 06:37:09.052270

Comments

believe it or not, opencv is a computer-vision library, where alpha channels have no relevance at all.

berak gravatar imageberak ( 2016-09-15 01:10:54 -0600 )edit

which opencv version do you use ? you might be missing this

berak gravatar imageberak ( 2016-09-15 01:56:54 -0600 )edit

Saving/loading images with alpha channels come handy while working on problems related to foreground/background extraction, object segmentation

kampta gravatar imagekampta ( 2016-09-15 02:06:46 -0600 )edit

I am using opencv 3.1 with python 3.5, let me try out the development version

kampta gravatar imagekampta ( 2016-09-15 02:07:39 -0600 )edit

just don''t expect too much. even, if you can load it, imshow won't be able to blit it correctly.

berak gravatar imageberak ( 2016-09-15 03:15:50 -0600 )edit