def posterize(image, bits):
 lut = []
 mask = (~ ((2 ** (8 - bits)) - 1))
 for i in range(256):
  lut.append((i & mask))
 return _lut(image, lut)

def posterize ( image , bits ) : lut = [ ] mask = ( ~ ( ( 2 ** ( 8 - bits ) ) - 1 ) ) for i in range ( 256 ) : lut . append ( ( i & mask ) ) return _lut ( image , lut )
reduce the number of bits for each color channel .