2

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

String testImgPath = "/storage/sdcard0/test2.exr"; //I know better than to hardcode paths. This is just a test.
Mat mRgba = Highgui.imread(testImgPath, Highgui.CV_LOAD_IMAGE_ANYCOLOR|Highgui.CV_LOAD_IMAGE_ANYDEPTH);

This works for the first 3 channels of an image (RGB ordering aside). I can display the resulting matrix like this:

Bitmap img = Bitmap.createBitmap(mRgba.cols(), mRgba.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(mRgba, img);
imgView.setImageBitmap(img);

But regardless of the combination of flags I use with imload, I never see a channel count greater than 3 (CV_32FC3) when I know for a fact my test image contains 9 channels. There are 3, 3-channel images embedded within it. How can I access these extra channels using OpenCV or other methods?

Thanks, Jason

JASON G PETERSON
  • 2,193
  • 1
  • 18
  • 19

1 Answers1

2

I just had a quick look at grfmt_exr.cpp. ExrDecoder::readHeader() seems to just assume that the image is in RGB format or luminance/chroma format. Therefore I think that you cannot use imread() with your 9 channel image.

The OpenCV codec is built on top of the ILM OpenEXR library which is included with the OpenCV source, so if you want to write some C++ code, see http://www.openexr.com/ReadingAndWritingImageFiles.pdf. openexr4j might be another possibility (but I have never used it).

Bull
  • 11,771
  • 9
  • 42
  • 53
  • Thanks much for looking into the code and confirming that OpenCV is not going to be my savior here. I was getting the feeling last night that there's going to be no avoiding figuring out the NDK -- and C++ (gulp). – JASON G PETERSON Aug 21 '14 at 04:25