So this is my first time using Stack Exchange, I have been relying on reddit so far for cs50 however I am stuck on blur. Someone on reddit told me I have to "create a temporary container that is the size of the original image, and then using nested for loops fill that container with the same image" however I do not know how to do that. I wanted to use pseudocode to try to explain what I imagine the code I have written for blur is doing.

[code removed per academic honesty guidelines. If anyone wants to help and needs to see it, you can use the edit button]

  1. Initializes variables

  2. Enter row (for loop height)

  3. Enter column (for loop width)

  4. Defines a matrix (the for loop's of int x& int y)

  5. Restricts the matrices to not go out of bounds (x and y if statements) if the matrix is 2x6 or 3x3 it stays within those parameters

  6. !! here is where I am going lost, as I do not know how to assign each image[i][j] (pixel) to a temporary variable "elements" in the case of my code. Unless I was to do red elements/blue elements/green elements and use image[i][j].rgbtRed...Green...Blue for instance ¡¡

  7. i also do not know where to insert my incrementing variable, much less how to write that variable

If anyone has any ideas I would greatly appreciate, I know my code as well as pseudocode most likely contain issues, I have been stuck for a few weeks now!

  • The suggestion to create a temporary copy of the image was a good one. You don't want to blur the original pixels unless you have a copy of them; each pixel relies on its surrounding ones, so if you blur as you go, each subsequent pixel's calculation will be incorrect. – curiouskiwi Aug 5 '20 at 1:37

You must log in to answer this question.

Browse other questions tagged .