Mercurial > hg > wm
comparison Meerwald/wm_bruyn_e.c @ 8:f83ef905a63d
fixing many warnings
increase capacity for coordinates in bruyn
fix some uninit. variables
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Tue, 22 Apr 2008 13:36:05 +0200 |
| parents | be303a3f5ea8 |
| children | 4987db85cfae |
comparison
equal
deleted
inserted
replaced
| 7:2b350281f8b0 | 8:f83ef905a63d |
|---|---|
| 35 gray **block; | 35 gray **block; |
| 36 gray **zone; | 36 gray **zone; |
| 37 gray **category1, **category2; | 37 gray **category1, **category2; |
| 38 gray maxval; | 38 gray maxval; |
| 39 double *slope; | 39 double *slope; |
| 40 int rows, cols, colors, format; | 40 int rows, cols, format; |
| 41 int c; | 41 int c; |
| 42 int i, j; | 42 int i, j; |
| 43 int r; | |
| 44 int n; | 43 int n; |
| 45 int col, row; | 44 int col, row; |
| 46 int bwidth, bheight; | |
| 47 int n_block; | 45 int n_block; |
| 48 int skipping = 0; | 46 int skipping = 0; |
| 49 | 47 |
| 50 char signature_name[MAXPATHLEN]; | 48 char signature_name[MAXPATHLEN]; |
| 51 char input_name[MAXPATHLEN] = "(stdin)"; | 49 char input_name[MAXPATHLEN] = "(stdin)"; |
| 147 usage(); | 145 usage(); |
| 148 exit(1); | 146 exit(1); |
| 149 } | 147 } |
| 150 | 148 |
| 151 // open input image file or read from stdin | 149 // open input image file or read from stdin |
| 152 if (argc == 1 && *argv[0] != '-') | 150 if (argc == 1 && *argv[0] != '-') { |
| 153 if ((in = fopen(argv[0], "rb")) == NULL) { | 151 if ((in = fopen(argv[0], "rb")) == NULL) { |
| 154 fprintf(stderr, "%s: unable to open input file %s\n", progname, argv[0]); | 152 fprintf(stderr, "%s: unable to open input file %s\n", progname, argv[0]); |
| 155 exit(1); | 153 exit(1); |
| 156 } | 154 } |
| 157 else | 155 else |
| 158 strcpy(input_name, argv[0]); | 156 strcpy(input_name, argv[0]); |
| 159 | 157 } |
| 158 | |
| 160 // read signature file and set options | 159 // read signature file and set options |
| 161 // command line options override signature file options | 160 // command line options override signature file options |
| 162 if (sig) { | 161 if (sig) { |
| 163 char line[128]; | 162 char line[128]; |
| 164 fgets(line, sizeof(line), sig); | 163 fgets(line, sizeof(line), sig); |
| 211 fprintf(stderr, "%s: signature file not specified, use -s file option\n", progname); | 210 fprintf(stderr, "%s: signature file not specified, use -s file option\n", progname); |
| 212 exit(1); | 211 exit(1); |
| 213 } | 212 } |
| 214 | 213 |
| 215 if (pattern1 <= 0 || pattern2 <= 0 || pattern1 > NPATTERN || pattern2 > NPATTERN) { | 214 if (pattern1 <= 0 || pattern2 <= 0 || pattern1 > NPATTERN || pattern2 > NPATTERN) { |
| 216 fprintf(stderr, "%s: invalid pattern type specified\n"); | 215 fprintf(stderr, "%s: invalid pattern type specified\n", progname); |
| 217 exit(1); | 216 exit(1); |
| 218 } | 217 } |
| 219 | 218 |
| 220 // read dimensions of input image file | 219 // read dimensions of input image file |
| 221 pgm_readpgminit(in, &cols, &rows, &maxval, &format); | 220 pgm_readpgminit(in, &cols, &rows, &maxval, &format); |
| 228 } | 227 } |
| 229 n_block = blocksize * blocksize; | 228 n_block = blocksize * blocksize; |
| 230 | 229 |
| 231 // allocate structure to remember which blocks we already touched, | 230 // allocate structure to remember which blocks we already touched, |
| 232 // allow plenty of room to skip over blocks | 231 // allow plenty of room to skip over blocks |
| 233 if ((coords = alloc_coords(nbit_signature * 2)) == NULL) { | 232 if ((coords = alloc_coords(nbit_signature * 16)) == NULL) { |
| 234 fprintf(stderr, "%s: unable to allocate memory\n", progname); | 233 fprintf(stderr, "%s: unable to allocate memory\n", progname); |
| 235 exit(1); | 234 exit(1); |
| 236 } | 235 } |
| 237 | 236 |
| 238 // read in input image file | 237 // read in input image file |
| 378 fprintf(stderr, "\n"); | 377 fprintf(stderr, "\n"); |
| 379 } | 378 } |
| 380 | 379 |
| 381 // calculate mean values for zone/categories | 380 // calculate mean values for zone/categories |
| 382 mean_1A = mean_1B = mean_2A = mean_2B = mean_1 = mean_2 = 0.0; | 381 mean_1A = mean_1B = mean_2A = mean_2B = mean_1 = mean_2 = 0.0; |
| 382 mean__1A = mean__1B = mean__2A = mean__2B = 0.0; | |
| 383 n_1A = n_1B = n_2A = n_2B = n_1 = n_2 = 0; | 383 n_1A = n_1B = n_2A = n_2B = n_1 = n_2 = 0; |
| 384 for (i = 0; i < blocksize; i++) | 384 for (i = 0; i < blocksize; i++) |
| 385 for (j = 0; j < blocksize; j++) { | 385 for (j = 0; j < blocksize; j++) { |
| 386 gray pixel = image[yb * blocksize + j][xb * blocksize + i]; | 386 gray pixel = image[yb * blocksize + j][xb * blocksize + i]; |
| 387 int pixel_zone = zone[j][i]; | 387 int pixel_zone = zone[j][i]; |
