How do I Access Channels beyond the First 3 or 4 in an OpenEXR Image?

asked 2014-08-20 15:04:55 -0600

jasongpeterson gravatar image

I'm using OpenCV for Android like this to try to load an EXR image:

String testImgPath = "/storage/sdcard0/test2.exr"; Mat mRgba = Highgui.imread(testImgPath, Highgui.CV_LOAD_IMAGE_ANYCOLOR|Highgui.CV_LOAD_IMAGE_ANYDEPTH);

Regardless of the combination of flags I use with imload, I never see a channel count greater than 3 (CV_32FC3), but I know for a fact my test image contains 9 channels. There are 3, 3-channel images embedded within it. How can I load these extra channels?

Thanks, Jason

edit retag flag offensive close merge delete

Comments

Hi, I know this topic is quite old, but i have a similar problem:

If an EXR is loaded, mat.channel() shows me only 3 channels that means that I cannot access the alpha channel. Saving an png with alpha as exr ends up in an exr without an alpha channel.

Is there a restiction in the implementation?

Thanks for your help.

jann gravatar imagejann ( 2016-03-28 15:07:27 -0600 )edit

Maybe when you read an EXR image, the resulting mat is similar to multi-dimensional mat.

What do you have when you print this ?

for (int i=0; i < image.dims; i++)  {
  std::cout << image.size[i] << std::endl;
}
Eduardo gravatar imageEduardo ( 2016-03-29 08:31:29 -0600 )edit

Hi Eduardo, your code shows me resolution (dims) of my exr. It printed out 2 values. 4096, 4096. This is the image resolution of my file. I got no other data.

Jason asked also on stackoverflow and he got an answer:

http://stackoverflow.com/questions/25...

It seems that OpenCV can only read the image as RGB.

Pritty sad because I think that OpenCV is quite easy to use. Loading an OpenEXR into a QT Framework based app is not so easy.

jann gravatar imagejann ( 2016-03-29 15:49:49 -0600 )edit