0

All the filters on the filter program work well, but check50 is giving me a few errors, which I think, is due to rounding issues. But, I have checked and re-checked the code for those errors, and haven't found any place where my rounding can be an issue. Now, I have no idea as to what is wrong with it. Any inputs? Thanks

Here's the code for blur and edge detection: For blur:

// Blur image
void blur(int height, int width, RGBTRIPLE image[height][width])
{
    int avgr, avgb, avgg, red = 0, green = 0, blue = 0;
    RGBTRIPLE imgCopy[height][width];
    
    for (int row = 0; row < height; row++)
    {
        for (int col = 0; col < width; col++)
        {
            imgCopy[row][col].rgbtRed = image[row][col].rgbtRed;
            imgCopy[row][col].rgbtGreen = image[row][col].rgbtGreen;
            imgCopy[row][col].rgbtBlue = image[row][col].rgbtBlue;
        }
    }

    for (int i = 0; i < height; i++)
    {
        for (int j = 0; j < width; j++)
        {
            //corners
            if (i == 0 && j == 0) //LHS Upper
            {
                red = imgCopy[0][0].rgbtRed + imgCopy[0][1].rgbtRed + imgCopy[1][0].rgbtRed + imgCopy[1][1].rgbtRed;
                avgr = round(red / 4);

                blue = imgCopy[0][0].rgbtBlue + imgCopy[0][1].rgbtBlue + imgCopy[1][0].rgbtBlue + imgCopy[1][1].rgbtBlue;
                avgb = round(blue / 4);

                green = imgCopy[0][0].rgbtGreen + imgCopy[0][1].rgbtGreen + imgCopy[1][0].rgbtGreen + imgCopy[1][1].rgbtGreen;
                avgg = round(green / 4);

            }

            else if (i == (height - 1) && j == 0) //LHS Lower
            {
                red = imgCopy[height - 1][0].rgbtRed + imgCopy[height - 2][0].rgbtRed + imgCopy[height - 2][1].rgbtRed +
                      imgCopy[height - 1][1].rgbtRed;
                avgr = round(red / 4);

                blue = imgCopy[height - 1][0].rgbtBlue + imgCopy[height - 2][0].rgbtBlue + imgCopy[height - 2][1].rgbtBlue +
                       imgCopy[height - 1][1].rgbtBlue;
                avgb = round(blue / 4);

                green = imgCopy[height - 1][0].rgbtGreen + imgCopy[height - 2][0].rgbtGreen + imgCopy[height - 2][1].rgbtGreen +
                        imgCopy[height - 1][1].rgbtGreen;
                avgg = round(green / 4);
            }

            else if (i == 0 && j == (width - 1)) //RHS Upper
            {
                red = imgCopy[0][width - 1].rgbtRed + imgCopy[0][width - 2].rgbtRed + imgCopy[1][width - 2].rgbtRed +
                      imgCopy[1][width - 1].rgbtRed;
                avgr = round(red / 4);

                blue = imgCopy[0][width - 1].rgbtBlue + imgCopy[0][width - 2].rgbtBlue + imgCopy[1][width - 2].rgbtBlue +
                       imgCopy[1][width - 1].rgbtBlue;
                avgb = round(blue / 4);

                green = imgCopy[0][width - 1].rgbtGreen + imgCopy[0][width - 2].rgbtGreen + imgCopy[1][width - 2].rgbtGreen +
                        imgCopy[1][width - 1].rgbtGreen;
                avgg = round(green / 4);

            }

            else if (i == (height - 1) && j == (width - 1)) //RHS Lower
            {
                red = imgCopy[height - 1][width - 1].rgbtRed + imgCopy[height - 2][width - 1].rgbtRed +
                      imgCopy[height - 2][width - 2].rgbtRed + imgCopy[height - 1][width - 2].rgbtRed;
                avgr = round(red / 4);

                blue = imgCopy[height - 1][width - 1].rgbtBlue + imgCopy[height - 2][width - 1].rgbtBlue +
                       imgCopy[height - 2][width - 2].rgbtBlue + imgCopy[height - 1][width - 2].rgbtBlue;
                avgb = round(blue / 4);

                green = imgCopy[height - 1][width - 1].rgbtGreen + imgCopy[height - 2][width - 1].rgbtGreen +
                        imgCopy[height - 2][width - 2].rgbtGreen + imgCopy[height - 1][width - 2].rgbtGreen;
                avgg = round(green / 4);

            }

            //edges
            else if (i == 0) //Upper
            {
                red = imgCopy[0][j - 1].rgbtRed + imgCopy[0][j].rgbtRed + imgCopy[0][j + 1].rgbtRed + imgCopy[1][j - 1].rgbtRed +
                      imgCopy[1][j].rgbtRed + imgCopy[1][j + 1].rgbtRed;
                avgr = round(red / 6);

                blue = imgCopy[0][j - 1].rgbtBlue + imgCopy[0][j].rgbtBlue + imgCopy[0][j + 1].rgbtBlue + imgCopy[1][j - 1].rgbtBlue +
                       imgCopy[1][j].rgbtBlue + imgCopy[1][j + 1].rgbtBlue;
                avgb = round(blue / 6);

                green = imgCopy[0][j - 1].rgbtGreen + imgCopy[0][j].rgbtGreen + imgCopy[0][j + 1].rgbtGreen + imgCopy[1][j - 1].rgbtGreen +
                        imgCopy[1][j].rgbtGreen + imgCopy[1][j + 1].rgbtGreen;
                avgg = round(green / 6);

            }

            else if (i == (height - 1)) //Lower
            {
                red = imgCopy[height - 2][j - 1].rgbtRed + imgCopy[height - 2][j].rgbtRed + imgCopy[height - 2][j + 1].rgbtRed +
                      imgCopy[height - 1][j - 1].rgbtRed + imgCopy[height - 1][j].rgbtRed + imgCopy[height - 1][j + 1].rgbtRed;
                avgr = round(red / 6);

                blue = imgCopy[height - 2][j - 1].rgbtBlue + imgCopy[height - 2][j].rgbtBlue + imgCopy[height - 2][j + 1].rgbtBlue +
                       imgCopy[height - 1][j - 1].rgbtBlue + imgCopy[height - 1][j].rgbtBlue + imgCopy[height - 1][j + 1].rgbtBlue;
                avgb = round(blue / 6);

                green = imgCopy[height - 2][j - 1].rgbtGreen + imgCopy[height - 2][j].rgbtGreen + imgCopy[height - 2][j + 1].rgbtGreen +
                        imgCopy[height - 1][j - 1].rgbtGreen + imgCopy[height - 1][j].rgbtGreen + imgCopy[height - 1][j + 1].rgbtGreen;
                avgg = round(green / 6);

            }

            else if (j == 0) //Left
            {
                red = imgCopy[i - 1][0].rgbtRed + imgCopy[i - 1][1].rgbtRed + imgCopy[i][0].rgbtRed + imgCopy[i][1].rgbtRed +
                      imgCopy[i + 1][0].rgbtRed + imgCopy[i + 1][1].rgbtRed;
                avgr = round(red / 6);

                blue = imgCopy[i - 1][0].rgbtBlue + imgCopy[i - 1][1].rgbtBlue + imgCopy[i][0].rgbtBlue + imgCopy[i][1].rgbtBlue +
                       imgCopy[i + 1][0].rgbtBlue + imgCopy[i + 1][1].rgbtBlue;
                avgb = round(blue / 6);

                green = imgCopy[i - 1][0].rgbtGreen + imgCopy[i - 1][1].rgbtGreen + imgCopy[i][0].rgbtGreen + imgCopy[i][1].rgbtGreen +
                        imgCopy[i + 1][0].rgbtGreen + imgCopy[i + 1][1].rgbtGreen;
                avgg = round(green / 6);

            }

            else if (j == (width - 1)) //Right
            {
                red = imgCopy[i - 1][width - 2].rgbtRed + imgCopy[i - 1][width - 1].rgbtRed + imgCopy[i][width - 2].rgbtRed +
                      imgCopy[i][width - 1].rgbtRed + imgCopy[i + 1][width - 2].rgbtRed + imgCopy[i + 1][width - 1].rgbtRed;
                avgr = round(red / 6);

                blue = imgCopy[i - 1][width - 2].rgbtBlue + imgCopy[i - 1][width - 1].rgbtBlue + imgCopy[i][width - 2].rgbtBlue +
                       imgCopy[i][width - 1].rgbtBlue + imgCopy[i + 1][width - 2].rgbtBlue + imgCopy[i + 1][width - 1].rgbtBlue;
                avgb = round(blue / 6);

                green = imgCopy[i - 1][width - 2].rgbtGreen + imgCopy[i - 1][width - 1].rgbtGreen + imgCopy[i][width - 2].rgbtGreen +
                        imgCopy[i][width - 1].rgbtGreen + imgCopy[i + 1][width - 2].rgbtGreen + imgCopy[i + 1][width - 1].rgbtGreen;
                avgg = round(green / 6);

            }

            else
            {
                red = round(imgCopy[i - 1][j - 1].rgbtRed) + round(imgCopy[i - 1][j].rgbtRed) + round(imgCopy[i - 1][j + 1].rgbtRed) +
                      round(imgCopy[i][j - 1].rgbtRed) + round(imgCopy[i][j].rgbtRed) + round(imgCopy[i][j + 1].rgbtRed) +
                      round(imgCopy[i + 1][j - 1].rgbtRed) + round(imgCopy[i + 1][j].rgbtRed) + round(imgCopy[i + 1][j + 1].rgbtRed);
                avgr = round(round(red) / 9);

                blue = round(imgCopy[i - 1][j - 1].rgbtBlue) + round(imgCopy[i - 1][j].rgbtBlue) + round(imgCopy[i - 1][j + 1].rgbtBlue) +
                       round(imgCopy[i][j - 1].rgbtBlue) + round(imgCopy[i][j].rgbtBlue + imgCopy[i][j + 1].rgbtBlue) +
                       round(imgCopy[i + 1][j - 1].rgbtBlue) + round(imgCopy[i + 1][j].rgbtBlue) + round(imgCopy[i + 1][j + 1].rgbtBlue);
                avgb = round(round(blue) / 9);

                green = round(imgCopy[i - 1][j - 1].rgbtGreen) + round(imgCopy[i - 1][j].rgbtGreen) + round(imgCopy[i - 1][j + 1].rgbtGreen) +
                        round(imgCopy[i][j - 1].rgbtGreen) + round(imgCopy[i][j].rgbtGreen) + round(imgCopy[i][j + 1].rgbtGreen) +
                        round(imgCopy[i + 1][j - 1].rgbtGreen) + round(imgCopy[i + 1][j].rgbtGreen) + round(imgCopy[i + 1][j + 1].rgbtGreen);
                avgg = round(round(green) / 9);
            }

            image[i][j].rgbtRed = avgr;
            image[i][j].rgbtGreen = avgg;
            image[i][j].rgbtBlue = avgb;
        }
    }
    return;
}

For edges:

// Detect edges
void edges(int height, int width, RGBTRIPLE image[height][width])
{
    int redx = 0, greenx = 0, bluex = 0, gRed = 0, gGreen = 0, gBlue = 0, redy = 0, greeny = 0, bluey = 0;
    RGBTRIPLE imgCopy[height][width];

    for (int row = 0; row < height; row++)
    {
        for (int col = 0; col < width; col++)
        {
            imgCopy[row][col].rgbtRed = image[row][col].rgbtRed;
            imgCopy[row][col].rgbtGreen = image[row][col].rgbtGreen;
            imgCopy[row][col].rgbtBlue = image[row][col].rgbtBlue;
        }
    }
    for (int i = 0; i < height; i++)
    {
        for (int j = 0; j < width; j++)
        {
            //corners
            if (i == 0 && j == 0) //LHS Upper
            {
                redy = (imgCopy[1][0].rgbtRed * 2) + imgCopy[1][1].rgbtRed;
                bluey = (imgCopy[1][0].rgbtBlue * 2) + imgCopy[1][1].rgbtBlue;
                greeny = (imgCopy[1][0].rgbtGreen * 2) + imgCopy[1][1].rgbtGreen;

                redx = (imgCopy[0][1].rgbtRed * 2) + imgCopy[1][1].rgbtRed;
                greenx = (imgCopy[0][1].rgbtGreen * 2) + imgCopy[1][1].rgbtGreen;
                bluex = (imgCopy[0][1].rgbtBlue * 2) + imgCopy[1][1].rgbtBlue;
            }

            else if (i == (height - 1) && j == 0) //LHS Lower
            {
                redx = imgCopy[height - 2][1].rgbtRed + (imgCopy[height - 1][1].rgbtRed * 2);
                bluex = imgCopy[height - 2][1].rgbtBlue + (imgCopy[height - 1][1].rgbtBlue * 2);
                greenx = imgCopy[height - 2][1].rgbtGreen + (imgCopy[height - 1][1].rgbtGreen * 2);

                redy = (imgCopy[height - 2][0].rgbtRed * -2) + (imgCopy[height - 2][1].rgbtRed * -1);
                bluey = (imgCopy[height - 2][0].rgbtBlue * -2) + (imgCopy[height - 2][1].rgbtBlue * -1);
                greeny = (imgCopy[height - 2][0].rgbtGreen * -2) + (imgCopy[height - 2][1].rgbtGreen * -1);
            }

            else if (i == 0 && j == (width - 1)) //RHS Upper
            {
                redx = (imgCopy[0][width - 2].rgbtRed * -2) + (imgCopy[1][width - 2].rgbtRed * -1);
                bluex = (imgCopy[0][width - 2].rgbtBlue * -2) + (imgCopy[1][width - 2].rgbtBlue * -1);
                greenx = (imgCopy[0][width - 2].rgbtGreen * -2) + (imgCopy[1][width - 2].rgbtGreen * -1);

                redy = (imgCopy[1][width - 2].rgbtRed * 1) + (imgCopy[1][width - 1].rgbtRed * 2);
                bluey = (imgCopy[1][width - 2].rgbtBlue * 1) + (imgCopy[1][width - 1].rgbtBlue * 2);
                greeny = (imgCopy[1][width - 2].rgbtGreen * 1) + (imgCopy[1][width - 1].rgbtGreen * 2);

            }

            else if (i == (height - 1) && j == (width - 1)) //RHS Lower
            {
                redx = (imgCopy[height - 2][width - 2].rgbtRed * -1) + (imgCopy[height - 1][width - 2].rgbtRed * -2);
                bluex = (imgCopy[height - 2][width - 2].rgbtBlue * -1) + (imgCopy[height - 1][width - 2].rgbtBlue * -2);
                greenx = (imgCopy[height - 2][width - 2].rgbtGreen * -1) + (imgCopy[height - 1][width - 2].rgbtGreen * -2);

                redy = (imgCopy[height - 2][width - 2].rgbtRed * -1) + (imgCopy[height - 1][width - 1].rgbtRed * -2);
                bluey = (imgCopy[height - 2][width - 2].rgbtBlue * -1) + (imgCopy[height - 1][width - 1].rgbtBlue * -2);
                greeny = (imgCopy[height - 2][width - 2].rgbtGreen * -1) + (imgCopy[height - 1][width - 1].rgbtGreen * -2);

            }

            //edges
            else if (i == 0) //Upper
            {
                redx = (imgCopy[0][j - 1].rgbtRed * -2) + (imgCopy[0][j + 1].rgbtRed * 2) +
                       (imgCopy[1][j - 1].rgbtRed * -1) + (imgCopy[1][j + 1].rgbtRed * 1);
                bluex = (imgCopy[0][j - 1].rgbtBlue * -2) + (imgCopy[0][j + 1].rgbtBlue * 2) +
                        (imgCopy[1][j - 1].rgbtBlue * -1) + (imgCopy[1][j + 1].rgbtBlue * 1);
                greenx = (imgCopy[0][j - 1].rgbtGreen * -2) + (imgCopy[0][j + 1].rgbtGreen * 2) +
                         (imgCopy[1][j - 1].rgbtGreen * -1) + (imgCopy[1][j + 1].rgbtGreen * 1);

                redy = (imgCopy[1][j - 1].rgbtRed * 1) + (imgCopy[1][j].rgbtRed * 2) + (imgCopy[1][j + 1].rgbtRed * 1);
                bluey = (imgCopy[1][j - 1].rgbtBlue * 1) + (imgCopy[1][j].rgbtBlue * 2) + (imgCopy[1][j + 1].rgbtBlue * 1);
                greeny = (imgCopy[1][j - 1].rgbtGreen * 1) + (imgCopy[1][j].rgbtGreen * 2) + (imgCopy[1][j + 1].rgbtGreen * 1);
            }

            else if (i == (height - 1)) //Lower
            {
                redx = (imgCopy[height - 2][j - 1].rgbtRed * -1) + (imgCopy[height - 2][j + 1].rgbtRed * 1) +
                       (imgCopy[height - 1][j - 1].rgbtRed * -2)  + (imgCopy[height - 1][j + 1].rgbtRed * 2);
                bluex = (imgCopy[height - 2][j - 1].rgbtBlue * -1) + (imgCopy[height - 2][j + 1].rgbtBlue * 1) +
                        (imgCopy[height - 1][j - 1].rgbtBlue * -2)  + (imgCopy[height - 1][j + 1].rgbtBlue * 2);
                greenx = (imgCopy[height - 2][j - 1].rgbtGreen * -1) + (imgCopy[height - 2][j + 1].rgbtGreen * 1) +
                         (imgCopy[height - 1][j - 1].rgbtGreen * -2)  + (imgCopy[height - 1][j + 1].rgbtGreen * 2);

                redy = (imgCopy[height - 2][j - 1].rgbtRed * -1) + (imgCopy[height - 2][j].rgbtRed * -2) +
                       (imgCopy[height - 2][j + 1].rgbtRed * -1);
                bluey = (imgCopy[height - 2][j - 1].rgbtBlue * -1) + (imgCopy[height - 2][j].rgbtBlue * -2) +
                        (imgCopy[height - 2][j + 1].rgbtBlue * -1);
                greeny = (imgCopy[height - 2][j - 1].rgbtGreen * -1) + (imgCopy[height - 2][j].rgbtGreen * -2) +
                         (imgCopy[height - 2][j + 1].rgbtGreen * -1);
            }


            else if (j == 0) //Left
            {
                redx = imgCopy[i - 1][1].rgbtRed + (imgCopy[i][1].rgbtRed * 2) + imgCopy[i + 1][1].rgbtRed;
                bluex = imgCopy[i - 1][1].rgbtBlue + (imgCopy[i][1].rgbtBlue * 2) + imgCopy[i + 1][1].rgbtBlue;
                greenx = imgCopy[i - 1][1].rgbtGreen + (imgCopy[i][1].rgbtGreen * 2) + imgCopy[i + 1][1].rgbtGreen;

                redy = (imgCopy[i - 1][0].rgbtRed * -2) + (imgCopy[i - 1][1].rgbtRed * -1) + (imgCopy[i + 1][0].rgbtRed * 2) +
                       (imgCopy[i + 1][1].rgbtRed * 1);
                bluey = (imgCopy[i - 1][0].rgbtBlue * -2) + (imgCopy[i - 1][1].rgbtBlue * -1) + (imgCopy[i + 1][0].rgbtBlue * 2) +
                        (imgCopy[i + 1][1].rgbtBlue * 1);
                greeny = (imgCopy[i - 1][0].rgbtGreen * -2) + (imgCopy[i - 1][1].rgbtGreen * -1) + (imgCopy[i + 1][0].rgbtGreen * 2) +
                         (imgCopy[i + 1][1].rgbtGreen * 1);
            }

            else if (j == (width - 1)) //Right
            {
                redx = (imgCopy[i - 1][width - 2].rgbtRed * -1) + (imgCopy[i][width - 2].rgbtRed * -2) +
                       (imgCopy[i + 1][width - 2].rgbtRed * -1);
                bluex = (imgCopy[i - 1][width - 2].rgbtBlue * -1) + (imgCopy[i][width - 2].rgbtBlue * -2) +
                        (imgCopy[i + 1][width - 2].rgbtBlue * -1);
                greenx = (imgCopy[i - 1][width - 2].rgbtGreen * -1) + (imgCopy[i][width - 2].rgbtGreen * -2) +
                         (imgCopy[i + 1][width - 2].rgbtGreen * -1);
                        
                redy = (imgCopy[i - 1][width - 2].rgbtRed * -1) + (imgCopy[i - 1][width - 1].rgbtRed * -2) +
                       (imgCopy[i + 1][width - 2].rgbtRed * 1) + (imgCopy[i + 1][width - 1].rgbtRed * 2);
                bluey = (imgCopy[i - 1][width - 2].rgbtBlue * -1) + (imgCopy[i - 1][width - 1].rgbtBlue * -2) +
                        (imgCopy[i + 1][width - 2].rgbtBlue * 1) + (imgCopy[i + 1][width - 1].rgbtBlue * 2);
                greeny = (imgCopy[i - 1][width - 2].rgbtGreen * -1) + (imgCopy[i - 1][width - 1].rgbtGreen * -2) +
                         (imgCopy[i + 1][width - 2].rgbtGreen * 1) + (imgCopy[i + 1][width - 1].rgbtGreen * 2);
            }

            else
            {
                redx = (imgCopy[i - 1][j - 1].rgbtRed * (-1)) + (imgCopy[i - 1][j].rgbtRed * 0) + (imgCopy[i - 1][j + 1].rgbtRed * 1) +
                       (imgCopy[i][j - 1].rgbtRed * -2) + (imgCopy[i][j].rgbtRed * 0) + (imgCopy[i][j + 1].rgbtRed * 2) +
                       (imgCopy[i + 1][j - 1].rgbtRed * -1) + (imgCopy[i + 1][j].rgbtRed * 0) + (imgCopy[i + 1][j + 1].rgbtRed * 1);

                bluex = (imgCopy[i - 1][j - 1].rgbtBlue * (-1)) + (imgCopy[i - 1][j].rgbtBlue * 0) + (imgCopy[i - 1][j + 1].rgbtBlue * 1) +
                        (imgCopy[i][j - 1].rgbtBlue * -2) + (imgCopy[i][j].rgbtBlue * 0) + (imgCopy[i][j + 1].rgbtBlue * 2) +
                        (imgCopy[i + 1][j - 1].rgbtBlue * -1) + (imgCopy[i + 1][j].rgbtBlue * 0) + (imgCopy[i + 1][j + 1].rgbtBlue * 1);

                greenx = (imgCopy[i - 1][j - 1].rgbtGreen * (-1)) + (imgCopy[i - 1][j].rgbtGreen * 0) + (imgCopy[i - 1][j + 1].rgbtGreen * 1) +
                         (imgCopy[i][j - 1].rgbtGreen * -2) + (imgCopy[i][j].rgbtGreen * 0) + (imgCopy[i][j + 1].rgbtGreen * 2) +
                         (imgCopy[i + 1][j - 1].rgbtGreen * -1) + (imgCopy[i + 1][j].rgbtGreen * 0) + (imgCopy[i + 1][j + 1].rgbtGreen * 1);

                redy = (imgCopy[i - 1][j - 1].rgbtRed * (-1)) + (imgCopy[i - 1][j].rgbtRed * -2) + (imgCopy[i - 1][j + 1].rgbtRed * -1) +
                       (imgCopy[i][j - 1].rgbtRed * 0) + (imgCopy[i][j].rgbtRed * 0) + (imgCopy[i][j + 1].rgbtRed * 0) +
                       (imgCopy[i + 1][j - 1].rgbtRed * 1) + (imgCopy[i + 1][j].rgbtRed * 2) + (imgCopy[i + 1][j + 1].rgbtRed * 1);

                bluey = (imgCopy[i - 1][j - 1].rgbtBlue * (-1)) + (imgCopy[i - 1][j].rgbtBlue * -2) + (imgCopy[i - 1][j + 1].rgbtBlue * -1) +
                        (imgCopy[i][j - 1].rgbtBlue * 0) + (imgCopy[i][j].rgbtBlue * 0) + (imgCopy[i][j + 1].rgbtBlue * 0) +
                        (imgCopy[i + 1][j - 1].rgbtBlue * 1) + (imgCopy[i + 1][j].rgbtBlue * 2) + (imgCopy[i + 1][j + 1].rgbtBlue * 1);

                greeny = (imgCopy[i - 1][j - 1].rgbtGreen * (-1)) + (imgCopy[i - 1][j].rgbtGreen * -2) +
                         (imgCopy[i - 1][j + 1].rgbtGreen * -1) + (imgCopy[i][j - 1].rgbtGreen * 0) + (imgCopy[i][j].rgbtGreen * 0) +
                         (imgCopy[i][j + 1].rgbtGreen * 0) + (imgCopy[i + 1][j - 1].rgbtGreen * 1) + (imgCopy[i + 1][j].rgbtGreen * 2) +
                         (imgCopy[i + 1][j + 1].rgbtGreen * 1);
            }

            gRed = sqrt(((redx) * (redx)) + ((redy) * (redy)));
            gBlue = sqrt(((bluex) * (bluex)) + ((bluey) * (bluey)));
            gGreen = sqrt(((greenx) * (greenx)) + ((greeny) * (greeny)));

            if (gRed > 255)
            {
                gRed = 255;
            }

            if (gGreen > 255)
            {
                gGreen = 255;
            }

            if (gBlue > 255)
            {
                gBlue = 255;
            }

            image[i][j].rgbtRed = gRed;
            image[i][j].rgbtGreen = gGreen;
            image[i][j].rgbtBlue = gBlue;
        }

    }

    return;
}

cs50 error messages

3
  • Edit: fixed one line of code, made the code neater Oct 1 '20 at 18:16
  • I understand that this is hardcoded... probably should have thought of a better way to implement both algorithms. But, it is just missing by one value, so I guess that it is more of a rounding issue Oct 1 '20 at 18:20
  • If blur correctly filters both edged and corners, shouldn't it be able to filter a 3X3 / 4X4 image properly? Oct 1 '20 at 18:26

You must log in to answer this question.

Browse other questions tagged .