我正在使用 OpenImage Denoiser,它使用 OpenImageIO 加载 EXR 文件。
图像加载如下:
std::shared_ptr<ImageBuffer> loadImageOIIO(const std::string& filename, int channels)
{
auto in = OIIO::ImageInput::open(filename);
if (!in)
throw std::runtime_error("cannot open image file: " + filename);
const OIIO::ImageSpec& spec = in->spec();
if (channels == 0)
channels = spec.nchannels;
else if (spec.nchannels < channels)
throw std::runtime_error("not enough image channels");
auto image = std::make_shared<ImageBuffer>(spec.width, spec.height, channels);
if (!in->read_image(0, 0, 0, channels, OIIO::TypeDesc::FLOAT, image->getData()))
throw std::runtime_error("failed to read image data");
in->close();
#if OIIO_VERSION < 10903
OIIO::ImageInput::destroy(in);
#endif
return image;
}
但是,这会将图像裁剪到数据窗口的边界框。因为我的图像有 0 个值,所以这个图像比实际输入的图像小。
如何获得具有显示窗口全分辨率的 ImageBuffer?