|
#include<stdio.h>
#define imag_size_row 256
#define imag_size_col 256
#define one 255
#define zero 0
unsigned char origin_image[imag_size_row][imag_size_col];
unsigned char result_image[imag_size_row][imag_size_col];
void main(int argc,char *argv[])
{
FILE *I_file,*O_file;
char origin_image_file_name[80];
char result_image_file_name[80];
int i,j;
printf("origin_image_file_name-->");
scanf("%s",origin_image_file_name);
printf("\n");
printf("result_image_file_name-->");
scanf("%s",result_image_file_name);
printf("\n");
if(!(I_file=fopen(origin_image_file_name,"rb")))
{printf(" origin file open error!");}
if(!(O_file=fopen(result_image_file_name,"wb")))
{printf("result file open error!");}
for(i=0;i<imag_size_row;i++)
fread(origin_image[i],sizeof(unsigned char),imag_size_col,I_file);
fclose(I_file);
for(i=0;i<imag_size_row;i++)
for(j=0;j<imag_size_col;j++)
{result_image[i][j]=(result_image[i][j]==0)?zero:one;
}
for(i=0;i<imag_size_row;i++)
fwrite(result_image[i],sizeof(unsigned char),imag_size_col,O_file);
fclose(O_file);
} |
|