 Status New
 Percent Complete
 Task Type Bug Report
 Category Backend / Core
 Assigned To Noone
 Operating System Win32
 Severity Low
 Priority Very Low
 Reported Version 1.0
 Due in Version Undecided

Due Date
Undecided
 Votes
 Private
FS#3179  TIFFReadRGBAImageOriented Premultiplication rounding error
TIFFReadRGBAImageOriented executes an alpha premultiplication even when the alpha value is stored as EXTRASAMPLE_UNASSALPHA. This leads to rounding errors.
example:
(correct mathematical rounding)
gt: 226 and alpha 0.5 > 127
read the premultiplied value: 226*127/255 = 112.56 > 113
converting to nonpremultiplied value: 113*255/127 = 226.89 > 227
gt: 225 and alpha 0.5 > 127
read the premultiplied value: 225*127/255 = 112.06 > 112
converting to nonpremultiplied value: 112*255/127 = 224.88 > 225
so we have a difference of 1 or 0 between the ground truth and the read value after undoing the premultiplication.
(incorrect mathematical rounding)
gt: 226 and alpha 0.5 > 127
read the premultiplied value: 226*127/255 = 112.56 > 112
converting to nonpremultiplied value: 112*255/127 = 224.88 > 224
so incorrect mathematical rounding leading to much worse results.
Consider using a different way to read the tiff image (for instance ReadEncodedStrip).