diff --git a/src/libImaging/ColorLUT.c b/src/libImaging/ColorLUT.c index 4a5c6bced..2af348586 100644 --- a/src/libImaging/ColorLUT.c +++ b/src/libImaging/ColorLUT.c @@ -144,13 +144,16 @@ ImagingColorLUT3D_linear(Imaging imOut, Imaging imIn, int table_channels, int size1D, int size2D, int size3D, INT16* table) { - /* The fractions are a way to avoid overflow. - For every pixel, we interpolate 8 elements from the table: - current and +1 for every dimension and they combinations. - If we hit the upper cells from the table, - +1 cells will be outside of the table. - With this compensation we never hit the upper cells - but this also doesn't introduce any noticable difference. */ + /* This float to int conversion doesn't have rounding + error compensation (+ 0.5) for two reasons: + 1. As we don't hit the highest value, + we can use one extra bit for precision. + 2. For every pixel, we interpolate 8 elements from the table: + current and +1 for every dimension and they combinations. + If we hit the upper cells from the table, + +1 cells will be outside of the table. + With this compensation we never hit the upper cells + but this also doesn't introduce any noticable difference. */ UINT32 scale1D = (size1D - 1) / 255.0 * (1<