Hello, I think you should add the '( )' brackets in the Bitwise Operator. For example: if pixel_i == 0 << 5 + 31: should be: if pixel_i == (0 << 5) + 31: I have tested it, if not have the brackets, the result is getting wrong.