How to Load a Many-Channel EXR in Android

百般思念 提交于 2019-12-12 04:57:29

问题


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


回答1:


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).



来源:https://stackoverflow.com/questions/25413604/how-to-load-a-many-channel-exr-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!