EOxServer / eoxserver

EOxServer is a Python application and framework for presenting Earth Observation (EO) data and metadata.
https://eoxserver.org
Other
40 stars 19 forks source link

Fix overflow in interpolate function #547

Closed totycro closed 1 year ago

totycro commented 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.

The subtraction later made basically all values negative.