0

In pset4 Filter problem when I write blur function I get Invalid or Unsopported Image Format Error. The program compiles without errors and in check50 it also works fine. This is my code. I would appreciate your help

#include "helpers.h" #include <math.h> #include <stdlib.h> #include <stdio.h> void blur(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE newimage[height][width]; int redsum=0,bluesum=0,greensum=0,c=0; for (int i=0; i < height; i++) {

    for(int j=0; j< width; j++)
    {
        c=0;
        redsum=0;
        bluesum=0;
        greensum=0;
        for(int a=0; a<height; a++)
        {
            for(int b=0; b<width; b++)
            {
                if(abs(a-i)<=1 && abs(b-j)<=1)
                {
                    c++;
                    redsum+=image[a][b].rgbtRed;
                    bluesum+=image[a][b].rgbtBlue;
                    greensum+=image[a][b].rgbtGreen;
                }
            }
        }



        if(c!=0)
        {
            newimage[i][j].rgbtRed=round((float)redsum/(float)c);
            newimage[i][j].rgbtBlue=round((float)bluesum/(float)c);
            newimage[i][j].rgbtGreen=round((float)greensum/(float)c);
        }








    }
}

for(int i=0;i<height;i++)
{
    for(int j=0;j<width;j++)
    {
        image[i][j]=newimage[i][j];
    }
}
return;

}

You must log in to answer this question.

Browse other questions tagged .