Hot answers tagged

8 votes
Accepted

pset4 filter: reflect the image reflect half only

If you swap the first pixel with the last, and then the last with the first, you are reflecting twice. Make your horizontal loop run width / 2 times instead of width.
Blauelf's user avatar
  • 20.9k
6 votes
Accepted

pset4 filter won't open file

That's simple because infile.bmp does not exist, that is just a placeholder it means that, that the path you put in there should contain a file. The folder images has images where you could process or ...
Ojou Nii's user avatar
  • 731
6 votes
Accepted

pset4 filter: blur seems to be working, but check50 reads errors

You overwrite pixels you still need later, for calculating the neighbouring pixels. What looks about right visually is still wrong. I made another array, wrote my blurred image to that, then later ...
Blauelf's user avatar
  • 20.9k
5 votes
Accepted

runtime error in filter: reflect

For j being 0, your index would be width. But valid index is from 0 to width-1. Subtract one and it should be right. After fixing this, I see another issue: You first swap the left half with the ...
Blauelf's user avatar
  • 20.9k
4 votes
Accepted

pset4: filter reflect all check right except two of them

Remove the -1 from HW. If the number of pixels per row is even, you need to swap half as many times. If the number of pixels per row is odd, no need to swap the middle one with itself, so swap that ...
Blauelf's user avatar
  • 20.9k
4 votes

Help with blur filter for pset4! Output image is significantly darker than input

Got the solution. Using the BYTE type to store the color values resulted in overflow. Solving by using int or double for redAvg, greenAvg, and blueAvg.
Michael Weiser's user avatar
4 votes
Accepted

PSET4 filter (more) - edge

You are using 'RGBTRIPLE' structs along your code which is kind of neat but it comes with some issues: That struct only can store values from 0 to 255 with no decimal point. That means that when ...
Tritum's user avatar
  • 1,571
4 votes
Accepted

pset4 filter blur problem

You're adding one pixel twice, and missing one pixel. The code, as you've written it, is really prone to tiny bugs like that, and they're hard to find. Once you've got it working, consider how you can ...
Llenk's user avatar
  • 744
4 votes

pset4 filter Could not open infile.bmp

After reading the documentation again, I found that to get an grayscale image you have to run it with a different command include image folder and the name of the image like: [ ./filter -g images/yard....
Matrix's user avatar
  • 67
3 votes
Accepted

pset4 filter reflect. runtime error: index 601 out of bounds for type 'RGBTRIPLE [width]'

Reading your code I can see that you're worried about the number of width pixels been even or not. Should you be worried? If you look at your code you can see that you're answering yourself. When ...
Tritum's user avatar
  • 1,571
3 votes
Accepted

helpers.c not compiling for filter

You are not meant to compile helpers.c to its own programme. Just make filter. The Makefile will make sure that helpers.c gets compiled as well, and that it gets linked into filter.
Blauelf's user avatar
  • 20.9k
3 votes

Pset4 filter edges issue

I found the solution, it turns out I was supposed to create a copy of the original image to work on.
Marianna's user avatar
3 votes
Accepted

pset4 filter: reflect produces "UndefinedBehaviorSanitizer:DEADLYSIGNAL" forever

for (int i = 0; i < width; i++) Shouldn't it be height?
Blauelf's user avatar
  • 20.9k
3 votes
Accepted

What's my error?

Your problem lies with the / operator. Because the RGB values and the denominator are all integers, integer division is being performed and the fractional remainder is dropped instead of being passed ...
Sentox's user avatar
  • 950
3 votes
Accepted

Questions regarding pset4 Blur filter (less comfortable)

Because BYTE can only hold values up to 255. If say all three RGB values were already 255, then the sum would overflow the variable. If both dividend and divisor are ints in a division, then it's ...
Fuelled_By_Coffee's user avatar
3 votes
Accepted

Image blurs but check50 fails for filter less. Why?

Did you look at the actual raw data of the resulting image to see what's happening? You can't just look at the image and say it's working because it "looks blurrred". Its just not blurred ...
Cliff B's user avatar
  • 68.7k
2 votes
Accepted

PSET4 Filter, edge detection process only works for square-like pictures. How to make it work for the whole picture?

if (j < height - 1) Something's wrong with that line.
Blauelf's user avatar
  • 20.9k
2 votes
Accepted

cs50 pset4 filter sepia

instead of using BYTE before sepiaRed, sepiaBlue, sepiaGreen, originalRed, originalBlue and originalGreen, use float Also, don't forget to round the values of sepia Red, Blue and Green using the ...
Areen's user avatar
  • 51
2 votes

Pset4 filter edges issue

The code you used does not create a separate temporary memory for the changes that you make to the image. As your code uses data stored in previous pixel as reference to edit the image, it creates a ...
Crisp_Coder99's user avatar
2 votes
Accepted

PSET4 (More Comfortable) Filter Edges

I've found 3 problems in your code: 1. You're making a copy of the image but you're not using it? 2. Revise the arrays Gx-Gy something is wrong. 3. Pay attention where you declare the group of long ...
Tritum's user avatar
  • 1,571
2 votes
Accepted

Filter (Less Comfortable) Seems to Work Perfectly, but only passes 7 of 22 checks

When doing operationns that could result in decimal point values it's not a good idea to work with 'int' values because the result's decimal point will be truncated. It's better to do the math with a ...
Tritum's user avatar
  • 1,571
2 votes
Accepted

Pset4: filter greyscale UndefinedBehaviorSanitizer (not due to incorrect order of height and width)

here " for (int j = 0; i < width; i++)" instead of 'j' you used 'i' by mistake..
Himanshi's user avatar
  • 391
2 votes
Accepted

Pset4 Reflect Filter Challenges - Not Reflecting

Notice what your for loops are doing. i = 0 will not switch with i = height-1 here. What you are doing is replacing i = height - 1 with i = 0. In this process you are overwriting the last pixel (in ...
Himanshi's user avatar
  • 391
2 votes
Accepted

pset4 - filter program,can't figure out what exactly is the problem with blur!

This is happening because your loop is summing values from neighbors to the left and up of the current pixel that have already been blurred by previous iterations of the same loop. You need to modify ...
AWTom's user avatar
  • 165
2 votes
Accepted

cs50 Pset 4 filter:Greyscale. Cade is not averaging correctly?

Did you happen to notice that the incorrect results all happen to be 1 less than the correct answers? That's a big clue. The problem lies here. float average = total / 3; Since total is an int and &...
Cliff B's user avatar
  • 68.7k
2 votes

My blur function blurs every image, but fails every check50 check - please help!

Please note I haven't validated this with testing and have only glanced at your code, but one thing that stands out to me: round((float) (sum_blue / pixel_type)) Remember operator precedence here: ...
Sentox's user avatar
  • 950
2 votes
Accepted

PSET4 Blur not passing Check50

Without doing a deep dive, I do see a major problem in the logic. The code copies all the pixels from image to temp array. But then, it does all the calculations using the temp array as the source ...
Cliff B's user avatar
  • 68.7k
2 votes

PSET4 filter less Blur function

Well, this code definitely blurs the image, but far from correctly. While the "math" may be right (not saying yes or no because I didn't look), there's a more serious logic problem. To blur ...
Cliff B's user avatar
  • 68.7k
2 votes
Accepted

My CS50 PSET4 Filter (Less) Blur function doesn't pass check50 despite seemingly working fine

"The code seemingly blurs images without error" indicates a problem. "Seemingly" correct output is not exactly correct. It tells me that the actual digital data output needs to ...
Cliff B's user avatar
  • 68.7k
1 vote
Accepted

Blur works visually, but check50 reads errors for every section

You're doing integer division it disregards the remainder, simple fix would be to just divide by 9.0 as it will become a float division, integer division is like 11 / 2 = 5.5, oh the data type is int ...
Ojou Nii's user avatar
  • 731

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