colour space reduction calculation

Viewed 46
1 Answers

The expression is table[i] = (uchar)(divideWith * (i/divideWith))

The whole point of that is to exploit integer division (innermost parenthesis, i/divideWith) to cause discretized colors.

Mathematically, this (over-)"simplifies" to table[i] = i, which means the range is approximately maintained.

If you didn't multiply "back" after dividing, you'd get smaller values, rather than values stretching mostly the whole 0 .. 255 range, and that would make your picture very much darker. In fact, the integer division is rounding down, so that already makes your picture darker.

Related