18

When you open a file a cursor is set somewhere in it (look at man fopen for more about that) and you can change this cursor position using fseek. When you read a "block" (in your case you read sizeof(RGBTRIPLE) bytes) from your file using fread the cursor will be move forward automatically by sizeof(RGBTRIPLE) bytes since your cursor needs to be on each ...


8

You are most probably doing make whodunit.c which should be make whodunit I also often get confused with these. So there is a way to think for it, always remember, you want to create executable that's why you write make whodunit, you don't want to create whodunit.c(ofc you are the one who is going to write it and not the computer), so you don't write ...


7

I got the same picture! After tweaking, I found that the reason why it's so light and hard to see is because all the coloured pixels are very close to white. What I mean is each pixel has an rgb that resembles (200,255,255). The more red, the whiter the pixel. With that in mind, I used if statements to separate each shade of "light blue" and turned it ...


7

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 ...


5

how does freed know to read one byte after another? It's essentially the definition of fread(): size_t fread ( void * ptr, size_t size, size_t count, FILE * stream ); Reads an array of count elements, each one with a size of size bytes, from the stream and stores them in the block of memory specified by ptr. In your example fread(&triple, sizeof(...


5

Black is represented by all three RGB elemments set to 0 or minimum value, or no color. White is the maximum color. If you want to change a pixel to white, you need to change all 3 elements to 0xff: triple.rgbtBlue = 0xff ; triple.rgbtGreen = 0xff ; triple.rgbtRed = 0xff ; This is the correct format for these elements. ...


3

Each part of the RGBTRIPLE can be 0xff, 0x00, 0xf0, or 0x0f. They can't be 0x000000- that's for the whole triple.


3

The person should be recognisable as one of the members of staff. What he's holding is probably a bit more obscure. As long as you've figured out how to actually change some of the pixel values to make the red noise go away, you've basically solved it.


3

I would say do not spend time worrying about how to fill in those 18 questions right now. Its simply a waste of time. What you should do is complete the whodunit lab first. Start by watching the whodunit walkthrough. Surprisingly, you will notice the walkthrough clears up and explains alot of the questions and the lab. Then later in the end, answering the 18 ...


3

The comparison operator is != not !==.


2

Given that padding cannot be read by fread Who says the padding can't be read by fread? Of course it can and that's the main reason you need to skip it — in order to make fread read the first pixel of the next scanline rather than the padding.


2

The RGBTRIPLE is a struct that contains 3 bytes: rgbtRed rgbtGreen rgbtBlue If the value of any of these triples is 0x00, then that means that color is not in the pixel. Thus, if I had an RGBTRIPLE named triple and the values of its members were as follows: triple.rgbtRed = 0xff; triple.rgbtGreen = 0x00; triple.rgbtBlue = 0x00; this would represent a red ...


2

When you try to remove the red pixels from the image, what you're really trying to do should be to convert the red pixels into white pixels. So it's useful to know... a black pixel is Red = 0x00, Green = 0x00, Blue = 0x00 and a white pixel is Red = 0xff, Green = 0xff, Blue = 0xff So if you're trying to convert a colored pixel into a while pixel, you add ...


2

If by enchancing you mean making the colors stronger, you can. What differentiates each of these tones of blue, if you think of the RGBTRIPLE structure? On the "stronger" pixels, the value of blue is higher. So, in order to make the image clearer, you can just increase the B component in every pixel, remebering that: 255 is the limit value. Make sure it ...


2

As long as you can recognize a human face in the image, you're fine. If you don't recognize who the particular face belongs to, recall that in Problem Set 2, after correctly implementing your Caesar cipher, there was a URL that could be decoded. If you don't remember, here is the encrypted link from the Problem Set 2 HTML form. uggc://jjj.lbhghor.pbz/jngpu?...


2

Actually this image can be slightly better enhanced by setting different values for the three color components, I've searched the RGB value of human face (I think this guy is a white guy so I searched the white people's RGB value) and its about 0xffe0bd (http://www.color-hex.com/color-palette/737), well my idea was to create a color image like a real human ...


2

Are your files actually named infile and outfile? Shouldn't you be running it with clue.bmp and verdict.bmp as the problem set describes? ./whodunit clue.bmp verdict.bmp In gdb, that means this: (gdb) r clue.bmp verdict.bmp


2

I'm not going to spoil the answer for you, but I'll share the line of reasoning that helped me to "get the red out" of the image. Think about this. The hexadecimal RGB representation of black is #000000 and the hexadecimal RGB representation of white is #ffffff. If I make the red value higher than the green and blue values, the pixel will get redder until ...


2

if( (triple.rgbtBlue=0x00) && (triple.rgbtGreen=0x00)&& (triple.rgbtRed=0xff) ) What is the difference between an assignment operator, = and an equality test operator, ==? What happens when you use = in a logic test? If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)


2

Yes, what students normally get is a picture like you're describing. You can, if you want, try to improve contrast. It is also possible to recover that pic perfectly in grayscale, but that's a little more complex and almost every student (let's say 99,9%) doesn't do it, so you shouldn't worry. If you're not sure about who it is, you could go back to ...


2

clue.bmp has changed. From the spec: When submitting this problem, you’ll be asked whodunit! Your result will enable you to answer the question.


2

Looks like there are "stray bytes", presumably at the end of clue.bmp. When it's opened in the IDE, clue.bmp is 640W * 480H. The filesize should be 54 + (640 * 3) * 480 which is 921,654 bytes. ls -l clue.bmp reveals that the file is 921,656 bytes. copy produces a file that is 921,654 bytes.


2

I did that before. The sources for the lab are at https://github.com/cs50/labs/tree/2019/x/whodunit. Make a new directory, open a terminal there, then execute wget https://raw.githubusercontent.com/cs50/labs/2019/x/whodunit/bmp.h wget https://raw.githubusercontent.com/cs50/labs/2019/x/whodunit/clue.bmp wget https://raw.githubusercontent.com/cs50/labs/2019/...


1

It turned out that I needed to change the location of my code. I had to have the fread command before it! Thank anyway for the help!


1

Go look at how color values work. If the shades are light, how might you enhance or change those values to see what they look like? You'll need to read up a bit more on RGB color and changing triple values to get this to work. Remember, you don't need to create a lifelike image, just one you can see.


1

Think about what your test is saying: if(triple.rgbtBlue != 0xff && triple.rgbtRed!= 0xff && triple.rgbtGreen != 0xff){ This will be true only if all three triples are not 0xff. If any one of them is 0xff, then the test is false. That means that a pure red, green or blue pixel will not be turned to black. If you want to test for a pixel ...


1

I have the same problem. After removing the 0xff red pixels I tried changing all remaining colored (all non-blank) pixels to black but that was definitely worse. Maybe that was going overboard. My next idea is to double the intensity of any non-whites.


1

Remember that white is represented by ffffff or when red, green, and blue are all 0xff. So when you search for triple.rgbtBlue == 0xff, you will also find all the pixels colored white. That's why almost your entire image is turned black


1

I'm guessing your error is about comparing a constant to triple.rgbtBlue. Keep in mind that triple.rgbtBlue is just a byte; its values don't range from 0x000000 to 0xff0000, but rather from 0x00 to 0xff. So, you'll want to compare against a different number.


1

I just checked and apparently this is the answer. that is, the program that was used to create clue.bmp added 2 bytes at the end of the file. copy.c does not assume there are any additional bytes other than the BMP itself (i.e., the headers and the image).


Only top voted, non community-wiki answers of a minimum length are eligible