So basically what I did was, first I started off with the row above and then the relevant row and then the row below. I created a for loop which would run across the row 3 times.
My code looks like this, After editing once again,
// Blur image
void blur(int height, int width, RGBTRIPLE image[height][width])
{
float temp[height][width][3];
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
long sumRed = 0, sumBlue = 0, sumGreen = 0;
int pixCount = 0;
//top row
for (int k = j - 1; k <= j + 1; k++)
{
if (i - 1 >= 0 && (k >= 0 && k < width))
{
sumRed += (long)image[i-1][k].rgbtRed;
sumBlue += (long)image[i-1][k].rgbtBlue;
sumGreen += (long)image[i-1][k].rgbtGreen;
pixCount++;
}
}
//relevant row
for (int k = j - 1; k <= j + 1; k++)
{
if (i >= 0 && (k >=0 && k < width))
{
sumRed += (long)image[i][k].rgbtRed;
sumBlue += (long)image[i][k].rgbtBlue;
sumGreen += (long)image[i][k].rgbtGreen;
pixCount++;
}
}
//bottom row
for (int k = j - 1; k <= j + 1; k++)
{
if (i + 1 < height && (k >= 0 && k < width))
{
sumRed += (long)image[i+1][k].rgbtRed;
sumBlue += (long)image[i+1][k].rgbtBlue;
sumGreen += (long)image[i+1][k].rgbtGreen;
pixCount++;
}
}
temp[i][j][0] = round(sumRed / pixCount);
temp[i][j][1] = round(sumBlue / pixCount);
temp[i][j][2] = round(sumGreen / pixCount);
}
}
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
image[i][j].rgbtRed = temp[i][j][0];
image[i][j].rgbtBlue = temp[i][j][1];
image[i][j].rgbtGreen = temp[i][j][2];
}
}
return;
}
And then when I run check 50 I get some errors.
So basically What I think happens there is the values doesn't get rounded off correctly. It misses by a slight error. Can someone help me. Thank you so much.