The output image is majorly white, with some outlines of the edges
void edges(int height, int width, RGBTRIPLE image[height][width])
{
RGBTRIPLE temporary[height][width];
for (int row = 0; row < height; row++)
{
for (int column = 0; column < width; column++)
{
temporary[row][column] = image[row][column];
}
}
for (int row = 0; row < height; row++)
{
for (int column = 0; column < width; column++)
{
image[row][column] = determineEdges(row, column, height, width, image, temporary);
}
}
return;
}
RGBTRIPLE determineEdges (int i, int j, int height, int width, RGBTRIPLE image[height][width], RGBTRIPLE temp[height][width])
{
float sum_surround_redX = 0, sum_surround_greenX = 0, sum_surround_blueX = 0, sum_surround_redY = 0, sum_surround_greenY = 0, sum_surround_blueY = 0;
float newRed = 0, newGreen = 0, newBlue = 0;
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 row_idx = i - 1; row_idx <= i + 1; row_idx++)
{
for (int column_idx = j - 1; column_idx <= j + 1; column_idx++)
{
if (row_idx < 0 || column_idx < 0 || row_idx > height - 1 || column_idx > width - 1)
{
continue;
}
sum_surround_redX += Gx[row_idx - i + 1][column_idx - j + 1] * image[row_idx][column_idx].rgbtRed;
sum_surround_greenX += Gx[row_idx - i + 1][column_idx - j + 1] * image[row_idx][column_idx].rgbtGreen;
sum_surround_blueX += Gx[row_idx - i + 1][column_idx - j + 1] * image[row_idx][column_idx].rgbtBlue;
sum_surround_redY += Gy[row_idx - i + 1][column_idx - j + 1] * image[row_idx][column_idx].rgbtRed;
sum_surround_greenY += Gy[row_idx - i + 1][column_idx - j + 1] * image[row_idx][column_idx].rgbtGreen;
sum_surround_blueY += Gy[row_idx - i + 1][column_idx - j + 1] * image[row_idx][column_idx].rgbtBlue;
}
}
newRed = round (sqrt (pow (sum_surround_redX, 2) + pow (sum_surround_redY, 2)));
newGreen = round (sqrt (pow (sum_surround_greenX, 2) + pow (sum_surround_greenY, 2)));
newBlue = round (sqrt (pow (sum_surround_blueX, 2) + pow (sum_surround_blueY, 2)));
if(newRed > 255)
{
newRed = 255;
}
if(newGreen > 255)
{
newGreen = 255;
}
if(newBlue > 255)
{
newBlue = 255;
}
temp[i][j].rgbtRed = newRed;
temp[i][j].rgbtGreen = newGreen;
temp[i][j].rgbtBlue = newBlue;
return temp[i][j];
}
What I have tried:
I've used debug50, but the variables seem to be correctly updated.
I've changed parameters, but no change succeed.