I'm brand new to programming and I'm going through the CS50 course. Got stuck on Blur problem for weeks. The code compiles but the image doesn't change to blur. These are the errors
I don't really understand those numbers shown in the error message and what they mean, looks like the value of the pixel is not what it's supposed to be. I found a similar question on the platform but the code was written different than mine and the answer to it did not help me :( Thank you for your time!
// Blur image
void blur(int height, int width, RGBTRIPLE image[height][width])
// make copy of file
{
RGBTRIPLE temp[height][width];
for (int row = 0; row < height; row++)
{
for (int column = 0; column < width; column++)
{
temp[row][column] = image[row][column];
}
}
for (int row = 0; row < height; row++)
{
for (int column = 0; column < width; column++)
{
int totalRed, totalGreen, totalBlue;
totalRed = totalGreen = totalBlue = 0;
float counter = 0.00;
//find neighbour pixels
for ( int i = -1; i < 2; i++)
{
for (int j = -1; j < 2; j++)
{
int currentRow = height + row;
int currentColumn = width + column;
//exclude invalid pixels
if (currentRow < 0 || currentRow > (height - 1) || currentColumn < 0 || currentColumn > (width - 1))
{
continue;
}
// adding the total value of the valid neighbouring pixels
totalRed += image[currentRow][currentColumn].rgbtRed;
totalGreen += image[currentRow][currentColumn].rgbtGreen;
totalBlue += image[currentRow][currentColumn].rgbtBlue;
counter++;
}
//calculate average of sorrounding pixels
temp[height][width].rgbtRed = round(totalRed / counter);
temp[height][width].rgbtGreen= round(totalGreen / counter);
temp[height][width].rgbtBlue= round(totalBlue / counter);
}
}
}
// copy temp values in original file
for (int row = 0; row < height; row++)
{
for (int column = 0; column < width; column++)
{
image[row][column].rgbtRed = temp[row][column].rgbtRed;
image[row][column].rgbtGreen = temp[row][column].rgbtGreen;
image[row][column].rgbtBlue = temp[row][column].rgbtBlue;
}
}
return;
}