0

It seems it is finding edges, When I run check50 it is giving me the errors below :

:) edges correctly filters middle pixel Log testing with sample 3x3 image first row: (0, 10, 25), (0, 10, 30), (40, 60, 80) second row: (20, 30, 90), (30, 40, 100), (80, 70, 90) third row: (20, 20, 40), (30, 10, 30), (50, 40, 10) running ./testing 4 0... checking for output "210 150 60\n"... :( edges correctly filters pixel on edge expected "213 228 255\n", not "213 228 140\n" Log testing with sample 3x3 image first row: (0, 10, 25), (0, 10, 30), (40, 60, 80) second row: (20, 30, 90), (30, 40, 100), (80, 70, 90) third row: (20, 20, 40), (30, 10, 30), (50, 40, 10) running ./testing 4 1... checking for output "213 228 255\n"...

Expected Output: 213 228 255 Actual Output: 213 228 140 :( edges correctly filters pixel in corner expected "76 117 255\n", not "76 117 66\n" Log testing with sample 3x3 image first row: (0, 10, 25), (0, 10, 30), (40, 60, 80) second row: (20, 30, 90), (30, 40, 100), (80, 70, 90) third row: (20, 20, 40), (30, 10, 30), (50, 40, 10) running ./testing 4 2... checking for output "76 117 255\n"...

Expected Output: 76 117 255 Actual Output: 76 117 66 :( edges correctly filters 3x3 image expected "76 117 255\n21...", not "76 117 66\n213..." Log testing with sample 3x3 image first row: (0, 10, 25), (0, 10, 30), (40, 60, 80) second row: (20, 30, 90), (30, 40, 100), (80, 70, 90) third row: (20, 20, 40), (30, 10, 30), (50, 40, 10) running ./testing 4 3... checking for output "76 117 255\n213 228 255\n192 190 255\n114 102 255\n210 150 60\n103 108 255\n114 117 255\n200 197 255\n210 190 255\n"...

Expected Output: 76 117 255 213 228 255 192 190 255 114 102 255 210 150 60 103 108 255 114 117 255 200 197 255 210 190 255 Actual Output: 76 117 66 213 228 140 192 190 66 114 102 6 210 150 60 103 108 39 114 117 66 200 197 129 210 190 66 :( edges correctly filters 4x4 image expected "76 117 255\n21...", not "76 117 66\n213..." Log testing with sample 3x3 image first row: (0, 10, 25), (0, 10, 30), (40, 60, 80), (50, 60, 80) second row: (20, 30, 90), (30, 40, 100), (80, 70, 90), (80, 80, 90) third row: (20, 20, 40), (30, 10, 30), (50, 40, 10), (50, 40, 100) fourth row: (50, 20, 40), (50, 20, 40), (50, 40, 80), (50, 40, 80) running ./testing 4 4... checking for output "76 117 255\n213 228 255\n255 255 255\n255 255 255\n114 102 255\n210 150 60\n177 171 156\n250 247 255\n161 89 255\n126 128 181\n114 170 192\n247 220 192\n148 71 156\n133 100 121\n181 148 212\n212 170 255\n"...

Expected Output: 76 117 255 213 228 255 255 255 255 255 255 255 114 102 255 210 150 60 177 171 156 250 247 255 161 89 255 126 128 181 114 170 192 247 220 192 148 71 156 133 100 121 181 148 212 212 170 255 Actual Output: 76 117 66 213 228 140 53 39 125 32 42 112 114 102 6 210 150 60 177 171 156 250 247 16 161 89 0 126 128 181 114 170 192 247 220 192 148 71 156 133 100 121 181 148 212 212 170 14

AND HERE IS MY CODE BELOW:

void edges(int height, int width, RGBTRIPLE image[height][width]) {

float Gxblue = 0, Gxgreen = 0, Gxred = 0;
float Gyblue = 0, Gygreen = 0, Gyred = 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   }
               };

RGBTRIPLE imageExmp[height][width];


for(int a = 0; a < height; a++)
{
    for(int b = 0; b < width; b++)
    {
        imageExmp[a][b] = image[a][b];
    }
}


for(int i = 0; i < height; i++)
{
    for(int j = 0; j < width; j++)
    {
        for(int t = i-1, x = 0 ; t < ((i-1) + 3); t++, x++)
        {
            for(int k = j-1, y = 0; k < ((j-1)+3); k++, y++)
            {

                if( (t >= 0 && t < height) && (k >= 0 && k < width) )
                {
                    Gxblue = Gxblue + imageExmp[t][k].rgbtBlue * Gx[x][y];
                    Gyblue = Gyblue + imageExmp[t][k].rgbtBlue * Gy[x][y];

                    Gxgreen = Gxgreen + imageExmp[t][k].rgbtGreen * Gx[x][y];
                    Gygreen = Gygreen + imageExmp[t][k].rgbtGreen * Gy[x][y];

                    Gxred = Gxred + imageExmp[t][k].rgbtRed * Gx[x][y];
                    Gyred = Gyred + imageExmp[t][k].rgbtRed * Gy[x][y];
                }

            }
        }

        image[i][j].rgbtBlue = (int)round(sqrt(pow(Gxblue, 2) + pow(Gyblue,2))) % 256;
        image[i][j].rgbtGreen = (int)round(sqrt(pow(Gxgreen, 2) + pow(Gygreen,2))) % 256;
        image[i][j].rgbtRed = (int)round(sqrt(pow(Gxred, 2) + pow(Gyred,2))) % 256;

        Gxblue = 0, Gxgreen = 0, Gxred = 0;
        Gyblue = 0, Gygreen = 0, Gyred = 0;

    }
}

return;

}

0

I found the mistake

% 256 instead of this I should have capped it at 255 !

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .