Changeset 5743 for trunk/stac/src/stacRejection.c
- Timestamp:
- Dec 7, 2005, 2:57:14 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/stac/src/stacRejection.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/stac/src/stacRejection.c
r3667 r5743 74 74 psTrace("stac.rejection", 1, "Mapping rejection masks back to source....\n"); 75 75 76 // Vectors for calculating the mean gradient 77 psVector *grads = psVectorAlloc(nImages, PS_TYPE_F32); // Gradient for each image 78 psVector *gradsMask = psVectorAlloc(nImages, PS_TYPE_U8); // Mask for gradient vector 79 76 80 // Transform rejection masks back to source 77 81 psArray *inputRej = psArrayAlloc(nImages); … … 107 111 // calculate derivatives of the map, and use that as a buffer around the transformed position 108 112 // in the input image. 113 psStats *median = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); 109 114 for (int y = 0; y < nyInput; y++) { 110 115 for (int x = 0; x < nxInput; x++) { … … 135 140 (yPix >= 0) && (yPix <= ((psImage*)(inputs->data[j]))->numRows - 1)) { 136 141 // Calculate the gradient 137 meanGrads += stacGradient(inputs->data[j], xPix, yPix); 142 grads->data.F32[j] = stacGradient(inputs->data[j], xPix, yPix); 143 gradsMask->data.U8[j] = 0; 138 144 numGrads++; 145 } else { 146 gradsMask->data.U8[j] = 1; // Mask this one 139 147 } 148 } else { 149 gradsMask->data.U8[j] = 1; // Mask this one 140 150 } 141 151 } 142 152 if (numGrads > 0) { 143 meanGrads /= (float)numGrads; 153 (void)psVectorStats(median, grads, NULL, gradsMask, (psU8)1); 154 meanGrads = median->sampleMedian; 144 155 } else { 145 meanGrads = 0 ;156 meanGrads = 0.0; 146 157 } 147 158 148 159 #ifdef TESTING 149 gradient->data.F32[y][x] = stacGradient(inputs->data[i], x, y) / meanGrads; 150 #endif 151 152 if (stacGradient(inputs->data[i], x, y) < grad * meanGrads) { 160 //gradient->data.F32[y][x] = stacGradient(inputs->data[i], x, y) / meanGrads; 161 gradient->data.F32[y][x] = meanGrads; 162 #endif 163 164 //if (stacGradient(inputs->data[i], x, y) < grad * meanGrads) { 165 if (meanGrads > grad) { 153 166 mask->data.U8[y][x] = 1; 154 167 nBad++; … … 173 186 } 174 187 } // Iterating over pixels 188 psFree(median); 175 189 176 190 #ifdef CRFLUX … … 194 208 psFits *rejmapFile = psFitsAlloc(rejmapName); 195 209 psFits *gradFile = psFitsAlloc(gradName); 196 if (!psFitsWriteImage(maskFile, NULL, mask, 0 , NULL)) {210 if (!psFitsWriteImage(maskFile, NULL, mask, 0)) { 197 211 psErrorStackPrint(stderr, "Unable to write image: %s\n", maskName); 198 212 } 199 213 psTrace("stac", 1, "Mask image written to %s\n", maskName); 200 if (!psFitsWriteImage(rejmapFile, NULL, rejmap, 0 , NULL)) {214 if (!psFitsWriteImage(rejmapFile, NULL, rejmap, 0)) { 201 215 psErrorStackPrint(stderr, "Unable to write image: %s\n", rejmapName); 202 216 } 203 217 psTrace("stac", 1, "Rejection map written to %s\n", rejmapName); 204 if (!psFitsWriteImage(gradFile, NULL, gradient, 0 , NULL)) {218 if (!psFitsWriteImage(gradFile, NULL, gradient, 0)) { 205 219 psErrorStackPrint(stderr, "Unable to write image: %s\n", gradName); 206 220 } … … 218 232 } 219 233 234 psFree(grads); 235 psFree(gradsMask); 220 236 221 237 psFree(inCoords);
Note:
See TracChangeset
for help on using the changeset viewer.
