AcademySoftwareFoundation / OpenImageIO

Reading, writing, and processing images in a wide variety of file formats, using a format-agnostic API, aimed at VFX applications.
https://openimageio.readthedocs.org
Apache License 2.0
1.98k stars 597 forks source link

[BUG] ImageBufAlgo::demosaic work only with float ImageBuf #4416

Closed ssh4net closed 2 months ago

ssh4net commented 2 months ago

ImageBuf demosaiced = ImageBufAlgo::demosaic(input, { {"algorithm", "linear"}, {"pattern", "bayer"}, {"layout", "RGGB"} });

output zero for uint8/uint16 ImageBuf

this code will output black image.

ImageBuf input(file.string(), 0, 0, nullptr, &spec, nullptr);
ImageBuf demosaiced = ImageBufAlgo::demosaic(input, { {"algorithm", "linear"}, {"pattern", "bayer"}, {"layout", "RGGB"} });
newfile = "demosaic.exr";
demosaiced.write(newfile);

This code that convert uint to float on load will output correctly demosaiced image

ImageBuf input(file.string());
input.read(0, 0, true, TypeDesc::FLOAT, nullptr, nullptr);
ImageBuf demosaiced = ImageBufAlgo::demosaic(input, { {"algorithm", "linear"}, {"pattern", "bayer"}, {"layout", "RGGB"} });
newfile = "demosaic.exr";
demosaiced.write(newfile);

tested on latest master.

(Looks like tests are use only floats images?)

antond-weta commented 2 months ago

I've fixed the bug and got uint8/uint16 images covered in unit tests. See #4419 Thanks for reporting this.

ssh4net commented 2 months ago

Thanx! Now everything works.