Reputation: 119
I currently am doing homework and I have this question that I am unable to understand. I am NOT asking for someone to code for me or anything, I just find that I am unable to understand what my question is asking for. If someone can help me understand what should be done, then I can code it ;p!
Here is the question:
Invert the image intensities, so that black becomes white and vice versa, and light shades of grey become the corresponding dark shade.
Now, I know that white is 0 and black is 255 and all I have to do is swap them in the array, but what does it mean in the last part where it asks me to switch the light shades of grey to dark shades of grey. Assuming it is referring to the remaining 1-254 numbers (pixels), what am I supposed to swap? If someone can explain to me how to do this then it would be great. Again, I am not looking for someone to code for me, I just want to know what it is asking for so I can myself code it.
Upvotes: 2
Views: 2760
Reputation: 23560
The homework does not even mention the word "swap" so forget all about it. It clearly states that the grayscale should be inverted.
This is how you would do it for the first pixel:
image[0] = 255 - image[0];
Upvotes: 2