/* Program for Filtering an Image with a specified Filter */ #include #include #include /* Function Prototype */ void Load_Raw_Image(const char *filename, double **image, int ix, int iy); void Save_Raw_Image(char *filename, double **image, int ix, int iy); double** Load_Filter(char *filename, int *hx, int *hy); void Filter_Image(double **image,int ix,int iy,double **filter,int hx,int hy, double **outimg); double** Allocate_Matrix(int ix, int iy); double **image=NULL, **filter=NULL, **outimage=NULL, **tempimage=NULL; int main(int argc, char *argv[]) { char in_filename[50],out_filename[50],junk[10],filter_filename[50]; int ix,iy,hx,hy,i,j; printf("\nFILTER IMAGE\n"); //-------------------------------------------------------------// // Parse the arguments otherwise get them if(argc<6) { printf("\nUseage: filter \n"); printf("Enter Arguments : "); scanf("%s %d %d %s %s",in_filename,&ix,&iy,filter_filename,out_filename); gets(junk); } else { strcpy(in_filename,argv[1]); ix = atoi(argv[2]); iy = atoi(argv[3]); strcpy(filter_filename,argv[4]); strcpy(out_filename,argv[5]); } /*-------------------------------------------------------------*/ /* Allocate Memory for the Input and Output Images */ printf("\t| Allocating Memory ........................ "); image = Allocate_Matrix(ix,iy); outimage = Allocate_Matrix(ix,iy); printf("COMPLETE\n"); /*-------------------------------------------------------------*/ /* Load the image */ printf("\t| Loading Image ............................ "); Load_Raw_Image(in_filename,image,ix,iy); printf("COMPLETE\n"); /* Load the Filter while allocating the filter within the function */ printf("\t| Loading Filter ........................... "); filter = Load_Filter(filter_filename,&hx, &hy); printf("COMPLETE\n"); printf("%d %d\n",hx,hy); for(i=0;i