What do we have to do in Pset 5 : Whodunit?
I know we need to analyze a file, but all I see is a lot of red pixels.
CS50 Stack Exchange is a question and answer site for students of Harvard University's CS50. It only takes a minute to sign up.Sign up to join this community
The image has a "secret" message on it, but the message is hidden by random pixels. We need to clean all the noise (the red pixels) and find the hidden message of whodunit.
Pixels of an image are stored as 8-bit integer triples (the so-called RGB code). Each byte of the triple represents the level (i.e. the "quantity") of the colour: R for red, G for Green and B for blue.
Setting the three bytes of the triple to 0 means "this pixel has no color in it", hence the pixel will appear black. Setting the three bytes of the triple to their maximum (255, as each value only has 8 bits, and 28 - 1 = 255), will produce a white pixel.
The colour of each pixel can then be modified by changing the value of each colour "channel", i.e. the value of each byte in the triple.
If we want to create an image having all pixels red, we should set to 255 the Red channel, and to 0 the other two channels of each pixel. In the same fashion, we can have an image with no red pixels setting to 0 the Red channel of each pixel's triple.
Now, back to our Pset: we have a picture with an hidden message in it, and the message is covered by "Red" noise: how can we get rid of the red noise of the image? The answer should be "reading each pixel (each triple of bytes), turning off the "red" channel and rewriting each pixel with the "denoised" value.