Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Reading PNG images not giving alpha values

I am trying to read a png image but I don't see the alpha values when I parse through the image.

Mat srcImage = Imgcodecs.imread("image_matting_example.png", IMREAD_UNCHANGED);
        byte[] buffer = new byte[4];
        Mat alphaOne = srcImage.clone();
        for(int x=100;x<440;x++){
            for(int y=20;y<60;y++){
                alphaOne.get(x,y,buffer);;
            }
        }

Here the code gives me an error as the buffer array value that I get is having just 3 values which is actually BGR(or RGB) but I am not able to see the Alpha channel, so any reason why this error is happening?