How to load png images with 4 channels?

If you are using OpenCV 2 or OpenCV 3 you should use IMREAD_* flags (as mentioned at here).

C++

using namespace cv;
Mat image = imread("image.png", IMREAD_UNCHANGED);

Python

import cv2
im = cv2.imread("image.png", cv2.IMREAD_UNCHANGED)

Leave a Comment