Changeset 27249 for trunk/psLib
- Timestamp:
- Mar 11, 2010, 9:20:14 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/fits/psFitsScale.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/fits/psFitsScale.c
r27097 r27249 122 122 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); 123 123 psStats *stats = psStatsAlloc(MEAN_STAT | STDEV_STAT); // Statistics object 124 psVector *sample = NULL; // Sample of pixels125 124 double mean, stdev; // Mean and standard deviation 126 if (!psImageBackground(stats, &sample, image, mask, maskVal, rng)) {125 if (!psImageBackground(stats, NULL, image, mask, maskVal, rng)) { 127 126 // It could be because the image is entirely masked, in which case we don't want to error 128 if (sample->n == 0) { 127 bool good = false; // Any good pixels? 128 129 130 // Find good pixels in an image, by image type 131 #define GOOD_PIXELS_CASE(TYPE) \ 132 case PS_TYPE_##TYPE: \ 133 for (int y = 0; y < image->numRows && !good; y++) { \ 134 for (int x = 0; x < image->numCols && !good; x++) { \ 135 if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) { \ 136 continue; \ 137 } \ 138 if (!isfinite(image->data.TYPE[y][x])) { \ 139 continue; \ 140 } \ 141 good = true; \ 142 } \ 143 } \ 144 break; 145 146 switch (image->type.type) { 147 GOOD_PIXELS_CASE(F32); 148 GOOD_PIXELS_CASE(F64); 149 default: 150 psAbort("Unsupported case: %x", image->type.type); 151 } 152 153 if (!good) { 129 154 psLogMsg("psLib.fits", PS_LOG_DETAIL, "Image has no good pixels, setting BSCALE = 1, BZERO = 0"); 130 155 psErrorClear(); … … 133 158 psFree(rng); 134 159 psFree(stats); 135 psFree(sample);136 160 return true; 137 161 } 162 163 // There are some good pixels in there somewhere; psImageBackground just didn't find them 138 164 psLogMsg("psLib.fits", PS_LOG_DETAIL, 139 165 "Couldn't measure background statistics for image quantisation; retrying."); … … 151 177 psFree(rng); 152 178 psFree(stats); 153 psFree(sample);154 179 return false; 155 180 } else { … … 168 193 stdev = psStatsGetValue(stats, STDEV_STAT); 169 194 } 170 psFree(sample);171 195 psFree(rng); 172 196 psFree(stats);
Note:
See TracChangeset
for help on using the changeset viewer.
