0
void edges(int height, int width, RGBTRIPLE image[height][width])
{
    RGBTRIPLE tmpGx[height][width];
    RGBTRIPLE tmpGy[height][width];
    int redtemp;
    int bluetemp;
    int greentemp;
    
    for ( int i = 0 ; i< height ; i++)
    {
        for (int j = 0 ; j < width ; j++)
        {
            tmpGx[i][j] = GX( i, j, height, width, image);
            tmpGy[i][j] = GY( i, j, height, width, image);
        }
    }
    
    for ( int i = 0 ; i< height ; i++)
    {
        for (int j = 0 ; j < width ; j++)
        {
            
            
            
            redtemp= round(sqrt((double)(tmpGx[i][j].rgbtRed*tmpGx[i][j].rgbtRed + tmpGy[i][j].rgbtRed*tmpGy[i][j].rgbtRed )));
            bluetemp = round(sqrt((double)(tmpGx[i][j].rgbtBlue*tmpGx[i][j].rgbtBlue + tmpGy[i][j].rgbtBlue*tmpGy[i][j].rgbtBlue))); 
            greentemp = round(sqrt((double)(tmpGx[i][j].rgbtGreen*tmpGx[i][j].rgbtGreen + tmpGy[i][j].rgbtGreen*tmpGy[i][j].rgbtGreen )));
            
            if( redtemp  <= 255 )
            {
                image[i][j].rgbtRed = redtemp;
            }
            else
            {
                image[i][j].rgbtRed = 255;
            }
            
             if( bluetemp  <= 255 )
            {
                image[i][j].rgbtBlue = bluetemp;
            }
            else
            {
                image[i][j].rgbtBlue = 255;
            }
            
             if( greentemp  <= 255 )
            {
                image[i][j].rgbtGreen = greentemp;
            }
            else
            {
                image[i][j].rgbtGreen = 255;
            }
        }
    }

    return;
}
RGBTRIPLE GX(int a, int b, int height, int width, RGBTRIPLE image[height][width])
{
    RGBTRIPLE GXRGB;
    int rsum = 0;
    int bsum = 0;
    int gsum = 0;
    
    for (int i = -1; i < 2 ; i++)
    {
        if (a+i >= 0 && a+i < height)
        {
            
        
            for (int j = -1; j < 2 ; j++)
            {
                if (b+j >= 0 && b+j < width && i != 0)
                {
                    rsum += j*image[a+i][b+j].rgbtRed ;
                    bsum += j*image[a+i][b+j].rgbtBlue ;
                    gsum += j*image[a+i][b+j].rgbtGreen ;
                    
                }
                if (b+j >= 0 && b+j < width && i == 0)
                {
                    rsum += 2*j*image[a+i][b+j].rgbtRed ;
                    bsum += 2*j*image[a+i][b+j].rgbtBlue ;
                    gsum += 2*j*image[a+i][b+j].rgbtGreen ;
                    
                }
            
            }
        }
    }
    GXRGB.rgbtRed = rsum ;
    GXRGB.rgbtBlue = bsum ;
    GXRGB.rgbtGreen = gsum ;
    

    return GXRGB;
}
RGBTRIPLE GY(int a, int b, int height, int width, RGBTRIPLE image[height][width])
{
    RGBTRIPLE GYRGB;
    int rsum = 0;
    int bsum = 0;
    int gsum = 0;
    
    for (int i = -1; i < 2 ; i++)
    {
        if (a+i >= 0 && a+i < height)
        {
            
        
            for (int j = -1; j < 2 ; j++)
            {
                if (b+j >= 0 && b+j < width && j != 0)
                {
                    rsum += i*image[a+i][b+j].rgbtRed ;
                    bsum += i*image[a+i][b+j].rgbtBlue ;
                    gsum += i*image[a+i][b+j].rgbtGreen ;
                    
                }
                if (b+j >= 0 && b+j < width && j == 0)
                {
                    rsum += 2*i*image[a+i][b+j].rgbtRed ;
                    bsum += 2*i*image[a+i][b+j].rgbtBlue ;
                    gsum += 2*i*image[a+i][b+j].rgbtGreen ;
                    
                }
            
            }
        }
    }
    GYRGB.rgbtRed = rsum ;
    GYRGB.rgbtBlue = bsum ;
    GYRGB.rgbtGreen = gsum ;
    

    return GYRGB;
}

below are what I got from the check50

:( edges correctly filters middle pixel expected "210 150 60\n", not "210 255 203\n" :( edges correctly filters pixel on edge expected "213 228 255\n", not "213 228 166\n" :( edges correctly filters pixel in corner expected "76 117 255\n", not "76 117 162\n" :( edges correctly filters 3x3 image expected "76 117 255\n21...", not "76 117 162\n21..." :( edges correctly filters 4x4 image expected "76 117 255\n21...", not "76 117 162\n21..."

You must log in to answer this question.

Browse other questions tagged .