#include #include #include #define BLACK '1' #define WHITE '0' char **img_alloc(int, int); void img_free(char **,int, int); void img_write(char **, int, int); char **img_read(FILE *, int *x, int *y); char **img_dilate(char **pbm, int x, int y); char **img_erode(char **pbm, int x, int y); int main(int argc, char *argv[]){ char **pbm1, **pbm2; int i, ix,iy, num; FILE *fp; /* 引数の数をチェック */ if(argc < 2 || argc > 3){ fprintf(stderr, "Usage: %s -[ed...] [filename]\n", argv[0]); exit(2); } /* 第1引数 */ if(argv[1][0] != '-'){ fprintf(stderr, "Error: Invalid operation '%c'\n", argv[1][0]); fprintf(stderr, "Usage: %s -[ed...] [filename]\n", argv[0]); exit(3); } /* 第2引数 */ if(argc == 3){ fp = fopen(argv[2],"r"); if(fp==NULL){ fprintf(stderr, "Error: Could not open file: %s\n",argv[2]); exit(4); } } else { fp=stdin; } pbm1 = img_read(fp, &ix,&iy); for(i=1;i