问题描述
我正在使用 OpenCV for Android 来加载 EXR 图像:
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);
这适用于图像的前 3 个通道(RGB 排序除外).我可以像这样显示结果矩阵:
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);
但无论我使用 imload 的标志组合如何,当我知道我的测试图像包含 9 个通道时,我从未看到通道数大于 3 (CV_32FC3).其中嵌入了 3 个 3 通道图像.如何使用 OpenCV 或其他方法访问这些额外的频道?
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?
谢谢,杰森
推荐答案
我刚刚快速浏览了 grfmt_exr.cpp.ExrDecoder::readHeader()
似乎只是假设图像是 RGB 格式或亮度/色度格式.因此,我认为您不能将 imread()
与您的 9 通道图像一起使用.
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.
OpenCV 编解码器建立在 OpenCV 源代码中包含的 ILM OpenEXR 库之上,因此如果您想编写一些 C++ 代码,请参阅 http://www.openexr.com/ReadingAndWritingImageFiles.pdf.openexr4j 可能是另一种可能性(但我从未使用过).
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).
这篇关于如何在 Android 中加载多通道 EXR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!