问题
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