I’m not sure how to calculate the brightness using only integer arithmetics. Are you supposed to round the numbers down/up? What if, e.g. I have a pixel as follows:
255 254 0
I would have the brightness of that: (255+254+0)/3= 169 R2. If I were to round that, I would have a very wrong answer in the total brightness so another solution would be to calculate every rest and consider that in the brightness of the whole picture. But still, what if I have a non integer result there?
Thanks in advance!
integer arithmetic simply truncates any decimal places that might occur in the result.
So, in your example the result would be:
(255 + 254 + 0)/3 = 169
The rest is simply cut off here.
In C, this is automatically performed if both operands are of integral type,
so you don’t really need to manually round any numbers.
As mentioned in the project description, you are supposed to use this at all times during the brightness calculation, meaning you don’t have to worry about the stripped rests even when calculating the brightness of a single pixel.
Does this answer your question?
Yes, thank you!