translating shifts from Java (Processing) to C++ (arduino)

This worked. And thanks a lot for the explanation.
As you now finaly also wrote the convertion function for me I now get a grayscale picture from the cam.

I have to tune it as it is too dark, even with the most correct translation function you provided (have to figure out the bit shift part, but also without the calculaiton for the whole picture only takes 0.2 seconds).

I learned a lot from the information you provided. In retrospect all you explained (beside the bit shifting part) is clear and I should have been able to do it myself. But that how it is when you learn something.

Thanks
Robert