Hot answers tagged

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 ...
user avatar
  • 20.7k
5 votes
Accepted

check50 error on helpers.c in pset4

When doing math operations that could result in decimal point number, although the recieving variable is a decimal point capable, the math on the right side of the asign simbol'=', when working with ...
user avatar
  • 1,561
4 votes
Accepted

pset4 Blur (Filter) not passing check50

This is an interesting one! It took me a bit to realize what was happening. As you probably did, I spent a lot of time, looking for an error in the math, in the logic, in something that was in the ...
user avatar
  • 64.2k
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 ...
user avatar
  • 709
3 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.
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 ...
user avatar
  • 64.2k
2 votes

pset4 filter blur help

You read from and write to the same array, but you need the original values for computing other averages. A solution would be to use two arrays, one for reading, one for writing, and copy between ...
user avatar
  • 20.7k
2 votes
Accepted

rounding problems with blur function - pset4 2020, filter less

You solved grayscale. Maybe you should check how you did the rounding there, and if you can apply that to blur. Edit: Totally missed that you do typecasts in most of the averages. But there are some ...
user avatar
  • 20.7k
2 votes
Accepted

PSET 4 Filter(Less) help with Blur

>= 0, not > 0. 0 is a valid index. Also, you might have rounding issues because you are doing integer division.
user avatar
  • 20.7k
2 votes
Accepted

PSET4 Filter: Blur help

First you have to think that when taking the values from the surroundings pixels, some of them will be already changed so the result will be diferent than with the original ones. Think in how you ...
user avatar
  • 1,561
2 votes
Accepted

CS50 filter issues with greyscale, sepia, and blur

When you divide the 3 colors by 3 you'll probably get a decimal point value. If you receive it in a 'int' variable you'll get a trimmed number. (the decimal part will be removed) The way to do it is ...
user avatar
  • 1,561
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 ...
user avatar
  • 165
2 votes

pset4 filter - blur - runtime error, colors off

Um, your code seems pretty hardcoded. It is good to improve the ability to think by trying to implement a new algorithm. I'm really sorry, I couldn't read it because its a lot. :( Anyways here's my ...
user avatar
2 votes
Accepted

CS50 Pset4 Blur

From one blind old fart to another, it's like the guy that lost his glasses in the basement but was looking in the back yard because the light was better. You're looking in the wrong place. ;-) The ...
user avatar
  • 64.2k
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: ...
user avatar
  • 940
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 ...
user avatar
  • 64.2k
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 ...
user avatar
  • 64.2k
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 ...
user avatar
  • 64.2k
2 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 ...
user avatar
1 vote
Accepted

Pset4 Blur filter, loop for searching surrounding pixels

Just get rid of int x=0; and replace x+i-1 with int x = i - 1. Likewise for the variable y. You can put any expression or declaration in the first section of the for loop. https://en.cppreference.com/...
user avatar
  • 165
1 vote

cs50 pset4 blur function index out of bounds issue

Some of your conditions need to change. There's no 'between' syntax like in maths, so (0 < j < width-1) won't work in c. You need to split this into something like (j > 0 && j < ...
user avatar
1 vote
Accepted

Pset 4 Blur Filter Program Seems to Compile but Doesn't Output Anything and Check50 Reads Errors

For starters, the loops never run. That's why the output looks like the original image. Look at the test conditions in the for loop: for (int i = 0; i < height && i > 0; i++) { for (...
user avatar
  • 64.2k
1 vote
Accepted

pset4 filter/blur code problem

If you look carefully at the extended results for check50 (the link at the end), you'd see that the result array is the same as the original input array. The problem lies here: image = new_image; ...
user avatar
  • 64.2k
1 vote
Accepted

CS50 pset4, I have problems with getting the blur filter to work

When you divided here: image[i][j].rgbtRed = (sumRed / pixCount); you'll problably get a decimal point result. The problem is that working with int variables will result in a truncated result, the ...
user avatar
  • 1,561
1 vote

CS50 Blur issue

I missed a += on the rgbtGreen :S
user avatar
  • 11
1 vote

pset4 - Filter - blur error

Your code assumes that every pixel can be made the centre pixel in a 3x3 block of pixels. This is not true for corner pixels as well as pixels at the vertical and horizontal borders of the image. ...
user avatar
1 vote

pset4 - Filter - blur error

I was very intriged because looking through your code I couldn't find anything wrong. So I compared with my blur version and they were very similar except for one thing. For my average calculations I ...
user avatar
  • 1,561
1 vote

PSET4 Filter: Blur help

Conditional loops is really the way to go on this one. If the pixel is along the left edge and time there is an image[j - 1] it would cause an index error. Think of all conditions that would cause an ...
user avatar
1 vote
Accepted

PSET 4 BLUR and 2 of REFLECT

For reflect, you have to re-think this expresion: [width - (j + 1)]. For Blur, you need to reset your variables before every i/j iteration.
user avatar
  • 1,561
1 vote
Accepted

blur pset4 help please, my code compiles but it does not pass any of the check50 at all

It's the same problem here: https://cs50.stackexchange.com/a/38197/27433 Also by doing the division for the averaging with 'int' types, will result in a number that will be truncated. i.e. if the ...
user avatar
  • 1,561

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