1994.02.17 16:23 "Fax images gets inverted (sometimes)", by Soren Pingel Dalsgaard

1994.02.17 16:23 "Fax images gets inverted (sometimes)", by Soren Pingel Dalsgaard

During a thorough test of libtiff I have discovered a BUG in libtiff. The bug only affects fax compression, and if all tiff readers/writers in the entire galaxy sticks with libtiff noone will ever discover the bug :-).

We tried writing the same image in two different ways:

  1. having 0 bits black, 1 bits white and setting PhotometricInterpretation to MinIsBlack.
  2. having 1 bits black, 0 bits white (done by xor'ing all bytes in the image data area with 0xFF) and setting P..I.. to MinIsWhite.

Now both of these methods should produce the same image. But when we compare the produced tiff files the only difference is the PhotometricInterpretation. The actual compressed image data is identical. If you ever encounter two tiff files with the same image data but different PhotometricInterpretation it means that the one is the negative of the other.

The problem, as I see it, is the definition of fax compression. It tells the implementor how to encode 'white' and 'black' pixels. But Photometric Interpretation has nothing to do with how to compress the image and nothing to do with inverting the image before writing it. Fax compression should instead mention how to encode 0 pixels (white) and 1 pixels (black).

Maybe this should be addressed to the TIFF document maintainers (I'll have to look up their address in the TIFF 6.0 paper).

Please comment on the above.

--
Soren Pingel Dalsgaard
pingel@daimi.aau.dk
Department of Computer Science
Aarhus University
Ny Munkegade 116
DK-8000 Aarhus C
DENMARK