image-rs / image-tiff

TIFF decoding and encoding library in pure Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Floating point predictor support

HeroicKatora opened this issue · comments

Forked from #70 .

The horizontal predictor for floating points does not use float differences, as those would be lossy, but apparently uses an integer difference. Recheck this with the standard.

There is a dedicated floating point predictor which first re-orders some bytes: http://chriscox.org/TIFFTN3d1.pdf

I got the floating point predictor working, will try to polish the code a bit and submit a PR.

Here's a little visualization of how it works: (note that differencing is done before reordering)
visual

I only implemented the f32 version. Libtiff supports 16, 24, 32 and 64-bit versions. We currently don't support 16 and 24-bit floating-point samples at all, so I won't implement that but it won't be hard to add later.

I guess I could add code for 64-bit samples as well, but I sadly don't have any test images in that format. All of my test images were generated using Photoshop, which doesn't support saving 64-bit samples.