Changeset 3375 for trunk/stac/src/stacRejection.c
- Timestamp:
- Mar 4, 2005, 11:37:01 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/stac/src/stacRejection.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/stac/src/stacRejection.c
r2765 r3375 1 1 #include <stdio.h> 2 #include <assert.h> 2 3 #include "pslib.h" 3 4 #include "stac.h" … … 34 35 // Get the median 35 36 psStats *stats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); 36 (void)psVectorStats(stats, pixels, mask, 1);37 (void)psVectorStats(stats, pixels, NULL, mask, 1); 37 38 float median = stats->sampleMedian; 38 39 psFree(stats); … … 53 54 54 55 // Check inputs 55 if (inputs->n != rejected->n) { 56 psError("stac.rejection", "Number of input images (%d) and rejection masks (%d) does not match.\n", 57 inputs->n, rejected->n); 58 return NULL; 59 } 60 if (inputs->n != regions->n) { 61 psError("stac.rejection", "Number of input images (%d) and region masks (%d) does not match.\n", 62 inputs->n, regions->n); 63 return NULL; 64 } 65 if (inputs->n != maps->n) { 66 psError("stac.rejection", "Number of input images (%d) and transformation maps (%d) does " 67 "not match.\n", inputs->n, maps->n); 68 return NULL; 69 } 70 if (inputs->n != inverseMaps->n) { 71 psError("stac.rejection", "Number of input images (%d) and inverse transformation maps (%d) does " 72 "not match.\n", inputs->n, inverseMaps->n); 73 return NULL; 74 } 56 assert(inputs->n == rejected->n); 57 assert(inputs->n == regions->n); 58 assert(inputs->n == maps->n); 59 assert(inputs->n == inverseMaps->n); 60 75 61 for (int i = 0; i < nImages; i++) { 76 if ((((psImage*)(inputs->data[i]))->numRows != ((psImage*)(regions->data[i]))->numRows) || 77 (((psImage*)(inputs->data[i]))->numCols != ((psImage*)(regions->data[i]))->numCols)) { 78 psError("stac.rejection", 79 "Sizes of input image (%dx%d) and region mask (%dx%d) for input %d do not match.\n", 80 ((psImage*)(inputs->data[i]))->numCols, ((psImage*)(inputs->data[i]))->numRows, 81 ((psImage*)(regions->data[i]))->numCols, ((psImage*)(regions->data[i]))->numRows, i); 82 return NULL; 83 } 62 psImage *input = inputs->data[i]; 63 psImage *region = regions->data[i]; 64 assert(input->numRows == region->numRows && input->numCols == region->numCols); 84 65 } 85 66 … … 114 95 sprintf(crfile,"%s.cr",config->inputs->data[i]); 115 96 if ((crs = fopen(crfile, "w")) == NULL) { 116 psError("stac.rejection","Unable to open file for detailed output, %s\n");97 fprintf(stderr, "Unable to open file for detailed output, %s\n"); 117 98 return NULL; 118 99 } … … 198 179 #ifdef TESTING 199 180 // Write error image out to check 200 char maskfile[MAXCHAR]; // Filename of mask image 201 char rejmapfile[MAXCHAR]; // Filename of rejection image 202 char gradfile[MAXCHAR]; // Filename of gradient image 203 sprintf(maskfile,"%s.mask",config->inputs->data[i]); 204 sprintf(rejmapfile,"%s.rejmap",config->inputs->data[i]); 205 sprintf(gradfile,"%s.grad",config->inputs->data[i]); 206 psImageWriteSection(mask,0,0,0,NULL,0,maskfile); 207 psImageWriteSection(rejmap,0,0,0,NULL,0,rejmapfile); 208 psImageWriteSection(grad,0,0,0,NULL,0,gradfile); 181 char maskName[MAXCHAR]; // Filename of mask image 182 char rejmapName[MAXCHAR]; // Filename of rejection image 183 char gradName[MAXCHAR]; // Filename of gradient image 184 sprintf(maskName,"%s.mask",config->inputs->data[i]); 185 sprintf(rejmapName,"%s.rejmap",config->inputs->data[i]); 186 sprintf(gradName,"%s.grad",config->inputs->data[i]); 187 188 psFits *maskFile = psFitsAlloc(maskName); 189 psFits *rejmapFile = psFitsAlloc(rejmapName); 190 psFits *gradFile = psFitsAlloc(gradName); 191 if (!psFitsWriteImage(maskFile, NULL, mask, 0, NULL)) { 192 psErrorStackPrint(stderr, "Unable to write image: %s\n", maskName); 193 } 194 psTrace("stac", 1, "Mask image written to %s\n", maskName); 195 if (!psFitsWriteImage(rejmapFile, NULL, rejmap, 0, NULL)) { 196 psErrorStackPrint(stderr, "Unable to write image: %s\n", rejmapName); 197 } 198 psTrace("stac", 1, "Rejection map written to %s\n", rejmapName); 199 if (!psFitsWriteImage(gradFile, NULL, grad, 0, NULL)) { 200 psErrorStackPrint(stderr, "Unable to write image: %s\n", gradName); 201 } 202 psTrace("stac", 1, "Gradient image written to %s\n", gradName); 203 psFree(maskFile); 204 psFree(rejmapFile); 205 psFree(gradFile); 209 206 psFree(rejmap); 210 207 psFree(grad);
Note:
See TracChangeset
for help on using the changeset viewer.
