I'm trying to do scaled quantizing on a 8 bit image.
I get input int:bits, which is 1-8 and the intensity of every pixel, 0-255.
I need to scale and quantize it.

Example:
bits = 1 // = 2 colors...