// Detect edges
void edges(int height, int width, RGBTRIPLE image[height][width])
{
// Copying
RGBTRIPLE copy[height][width];
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
copy[i][j] = image[i][j];
}
}
int Gx[3][3] = {{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}};
int Gy[3][3] = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}};
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
int GxsumRed = 0;
int GxsumGreen = 0;
int GxsumBlue = 0;
int GysumRed = 0;
int GysumGreen = 0;
int GysumBlue = 0;
// Forming 3x3 grid
int m = 0; // For Gx and Gy
for (int k = i - 1; k < i + 2; k++)
{
if (k < 0)
{
continue;
}
// if k > height then break
if (k >= height)
{
break;
}
int n = 0; // For Gx and Gy
for (int l = j - 1; l < j + 2; l++)
{
if (l < 0)
{
continue;
}
if (l >= width)
{
break;
}
GxsumRed += Gx[m][n] * copy[k][l].rgbtRed;
GxsumGreen += Gx[m][n] * copy[k][l].rgbtGreen;
GxsumBlue += Gx[m][n] * copy[k][l].rgbtBlue;
GysumRed += Gy[m][n] * copy[k][l].rgbtRed;
GysumGreen += Gy[m][n] * copy[k][l].rgbtGreen;
GysumBlue += Gy[m][n] * copy[k][l].rgbtBlue;
n++;
}
m++;
}
int newRed = round(sqrt((GxsumRed * GxsumRed) + (GysumRed * GysumRed)));
int newGreen = round(sqrt((GxsumGreen * GxsumGreen) + (GysumGreen * GysumGreen)));
int newBlue = round(sqrt((GxsumBlue * GxsumBlue) + (GysumBlue * GysumBlue)));
// Caping to 255
if (newRed > 255)
{
newRed = 255;
}
if (newGreen > 255)
{
newGreen = 255;
}
if (newBlue > 255)
{
newBlue = 255;
}
image[i][j].rgbtRed = newRed;
image[i][j].rgbtGreen = newGreen;
image[i][j].rgbtBlue = newBlue;
}
}
return;
}
This CS50 Problem-Set 4. filter-more problem. Everything is okay except for edges function. ChatGPT says that my code is correct, but check50 says it is not correct why? What did I do wrong?
Please can you anyone tell me? Please Please?
This is all the details:

The problem is you increment
nandmat the end of the loop bodies, but this increment is bypassed whenk < 0orl < 0respectively are true and thecontinuestatement is evaluated.You should either avoid the
continuestatement or move the increment to the third clause of theforstatements.Breaking from the loops early if
k >= heightorl >= widthis an optimisation that breaks the symmetry of the code and makes it more difficult for the compiler to unroll or parallelize the loops. This optimisation is marginal for even moderately large images. It is recommended to favor code readability and regularity over premature optimisation.Here is a modified version of the inner loops: