RenderKit / oidn

Intel® Open Image Denoise library
https://www.openimagedenoise.org/
Apache License 2.0
1.74k stars 160 forks source link

Sample apps crop blackspace around input image #85

Closed NicWickman closed 3 years ago

NicWickman commented 3 years ago

I am trying to denoise renders with a black background that extend past the rendered asset. However, OpenImageIO is working with the data window instead of the display window, and thus outputting an image smaller than inputted. This obviously does not work for our rendering pipeline.

Images in the denoise sample app are loaded like so:

  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;
  }

How can I get an ImageBuffer with the full resolution of the Display window?

atafra commented 3 years ago

The example application was not designed to be used in production so its feature set is limited by design. Modifying the example to suit your needs would be probably possible but the issue you mentioned seems to be entirely independent from Open Image Denoise. I think it would be better to ask this question from the OpenImageIO team instead, as this is an OpenImageIO related issue.