Closed totycro closed 1 year ago
The input data was read as uint16, which wraps around at 65k, which is actually reached by this formula depending on the interpolate target range.
E.g. one pixel color happened to be 618, leading to a calculation like this:
( ( 255 - 100 ) * 618 + 814 * 100 - 560 * 255 ) / ( 815 - 560 )
So evaluating this would start with (255 - 100) * 618 which is 95790, but with uint16, you get 30254.
(255 - 100) * 618
The subtraction later made basically all values negative.
The input data was read as uint16, which wraps around at 65k, which is actually reached by this formula depending on the interpolate target range.
E.g. one pixel color happened to be 618, leading to a calculation like this:
( ( 255 - 100 ) * 618 + 814 * 100 - 560 * 255 ) / ( 815 - 560 )
So evaluating this would start with
(255 - 100) * 618
which is 95790, but with uint16, you get 30254.The subtraction later made basically all values negative.