# Pset4 filter (more) - Edge Help

I stuck on pset4 for days. Only the corners passed check50. Any help, please?

``````void edges(int height, int width, RGBTRIPLE image[height][width])
{
int cap (int c);
//get a copy of all the pixels (create a copying container in the same data type)
RGBTRIPLE copy[height][width];
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
copy[i][j] = image[i][j];
}
}

//iterate through rows
for (int i = 0; i < height; i++)
{
//iterate through columns
for (int j = 0; j < width; j++)
{
//initiate sumGx, sumGy
int sumGxRed = 0, sumGxGreen = 0, sumGxBlue = 0,
sumGyRed = 0, sumGyGreen = 0, sumGyBlue = 0;

//create Gx block, Gy block:
int Gxy[3][3] = {{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}};

//iterate through rows in 3x3 blocks, Gy          //m, l (from -1 to 1)
for (int m = -1; m < 2; m++) //(Gx[x][y], Gy[x][y])
{

//iterate through columns in 3x3 blocks, Gx
for (int l = -1; l < 2; l++)
{
//check if pixel is valid
if (i + m >= 0 && i + m < height - 1 && j + l >= 0 && j + l < width - 1)
{

//sumGx = sumGy =
sumGxRed += Gxy[m + 1][l + 1] * copy[i + m][j + l].rgbtRed;
sumGxGreen += Gxy[m + 1][l + 1] * copy[i + m][j + l].rgbtGreen;
sumGxBlue += Gxy[m + 1][l + 1] * copy[i + m][j + l].rgbtBlue;

sumGyRed += Gxy[l + 1][m + 1] * copy[i + m][j + l].rgbtRed;
sumGyGreen += Gxy[l + 1][m + 1] * copy[i + m][j + l].rgbtGreen;
sumGyBlue += Gxy[l + 1][m + 1] * copy[i + m][j + l].rgbtBlue;
}
}
}

////get final value = square root of Gx^2 + Gy^2 --> function: sqrt(), pow() (final values applies to image[i][j])
int finalRed = cap(round(sqrt(pow((float)sumGxRed, 2) + pow((float)sumGyRed, 2))));
int finalGreen = cap(round(sqrt(pow((float)sumGxGreen, 2) + pow((float)sumGyGreen, 2))));
int finalBlue = cap(round(sqrt(pow((float)sumGxBlue, 2) + pow((float)sumGyBlue, 2))));

image[i][j].rgbtRed = finalRed;
image[i][j].rgbtGreen = finalGreen;
image[i][j].rgbtBlue = finalBlue;
}
}
return;
}

int cap (int c)
{
if (c > 255)
{
c = 255;
}
return c;
}
``````