image icon indicating copy to clipboard operation
image copied to clipboard

Reminder: Simplify HDR Decoder

Open johannesvollmer opened this issue 4 years ago • 5 comments

F32 color support was further improved, allowing us to hopefully simplify the HDR decoder.

See #1478 and maybe #1473

Draft

The HDR decoder currently uses an adapter to simulate f32 storage. This issue is a reminder to consider removing the adapter in favor of a simple RGB32F buffer.

johannesvollmer avatar May 22 '21 11:05 johannesvollmer

There seems to be a very minimal HDR encoder, which is not used anywhere yet. There seems to be no comment about whether it could work. Maybe the only barrier preventing it from being used was the missing f32 support back then?

Now that f32 support is here, is it a matter of enabling the encoder, or will it have to be actually implemented?

johannesvollmer avatar Oct 21 '21 22:10 johannesvollmer

The approach for the decoder would be simply to change the default color type to Rgb32F instead of Rgb8 simply to maintain the accuracy. What do you think?

johannesvollmer avatar Oct 21 '21 22:10 johannesvollmer

Yes, please, do that. All my votes for that! I just stumbled about that issue.

My project is hdr/exr import, image = "0.24.1" Invoking Reader::decode() Result:

  • the brand-new OpenExr decoder works great (many thanks to all involved)
  • the Hdr decoder, as it currently is, renders itself unusable, on the first impression. One could call it broken. It should return f32, not u8.

Workaround for me was to invoke the Hdr decoder directly and call decoder.read_image_hdr(), while passing the other formats to decode()

Again, please remove the bad wrapper code that breaks the good code.

emble avatar Apr 08 '22 23:04 emble

I've opened #1599 for this, but got stuck

johannesvollmer avatar Apr 09 '22 09:04 johannesvollmer

Btw, the solution @emble mentioned would look like this (if anyone's searching for it):

        let mut r = BufReader::new(File::open(file_name).unwrap());
        let decoder = image::codecs::hdr::HdrDecoder::new(r).unwrap();
        let pixels = decoder.read_image_hdr().unwrap();

wrightwriter avatar Nov 14 '22 14:11 wrightwriter