x=imread("RGBA.png",IMREAD_GRAYSCALE=1); size(x)
ans = [1x2 double]
420. 434.
loads the image as a grayscale image. However, the prototype of imread() does not allow to set more than one option (which is likely a misconception), and the default setting (IMREAD_ANYDEPTH=1,IMREAD_ANYCOLOR = 1) strips the alpha channel. After playing with the different values, using IMREAD_LOAD_GDAL=1 does preserve the alpha channel:
--> x=imread("RGBA.png",IMREAD_LOAD_GDAL=1); size(x)
ans = [1x3 double]
420. 434. 4.
I suggest that the next version of IPCV should preserve all image channels (@kailup, don’t you think so ?) as version <= 4.1, so in that case the default setting should be IMREAD_LOAD_GDAL=1 instead of IMREAD_ANYDEPTH=1,IMREAD_ANYCOLOR = 1 when the image filename ends with .png ?