Changeset 24113
- Timestamp:
- May 8, 2009, 12:07:28 PM (17 years ago)
- Location:
- trunk/psModules/src/detrend
- Files:
-
- 2 edited
-
pmMaskBadPixels.c (modified) (3 diffs)
-
pmMaskBadPixels.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmMaskBadPixels.c
r21183 r24113 81 81 82 82 83 bool pmMaskFlagSuspectPixels (pmReadout *output, const pmReadout *readout, float median, float stdev,84 float rej, psImageMaskType maskVal)83 bool pmMaskFlagSuspectPixelsBySigma(pmReadout *output, const pmReadout *readout, float median, float stdev, 84 float rej, psImageMaskType maskVal) 85 85 { 86 86 PS_ASSERT_PTR_NON_NULL(readout, false); … … 115 115 // If we get down here and the statistics are missing, then we should go and mask the entire image 116 116 psWarning("Missing statistics --- flagging entire image as suspect."); 117 return (psImage*)psBinaryOp(suspect, suspect, "+", psScalarAlloc(1.0, PS_TYPE_F32)); 117 psBinaryOp (suspect, suspect, "+", psScalarAlloc(1.0, PS_TYPE_F32)); 118 return true; 118 119 } 119 120 … … 128 129 for (int x = 0; x < image->numCols; x++) { 129 130 if (fabs((image->data.F32[y][x] - median) / stdev) < rej) continue; 131 if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) continue; 132 suspect->data.F32[y][x] += 1.0; 133 } 134 } 135 psFree(suspect); // Drop reference 136 137 psMetadataItem *numItem = psMetadataLookup(output->analysis, PM_MASK_ANALYSIS_NUM); // Item with number 138 assert(numItem); 139 numItem->data.S32++; 140 141 return true; 142 } 143 144 bool pmMaskFlagSuspectPixelsByValue(pmReadout *output, const pmReadout *readout, 145 float min, float max, psImageMaskType maskVal) 146 { 147 PS_ASSERT_PTR_NON_NULL(readout, false); 148 PS_ASSERT_IMAGE_NON_NULL(readout->image, false); 149 PS_ASSERT_IMAGE_NON_EMPTY(readout->image, false); 150 PS_ASSERT_IMAGE_TYPE(readout->image, PS_TYPE_F32, false); 151 if (readout->mask) { 152 PS_ASSERT_IMAGE_NON_EMPTY(readout->mask, false); 153 PS_ASSERT_IMAGES_SIZE_EQUAL(readout->image, readout->mask, false); 154 PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_IMAGE_MASK, false); 155 } 156 PS_ASSERT_PTR_NON_NULL(output, false); 157 158 bool mdok; // Status of MD lookup 159 psImage *suspect = psMetadataLookupPtr(&mdok, output->analysis, PM_MASK_ANALYSIS_SUSPECT); // Suspect img 160 if (suspect) { 161 PS_ASSERT_IMAGE_NON_EMPTY(suspect, false); 162 PS_ASSERT_IMAGE_TYPE(suspect, PS_TYPE_F32, false); 163 PS_ASSERT_IMAGES_SIZE_EQUAL(readout->image, suspect, false); 164 psMemIncrRefCounter(suspect); 165 } else { 166 suspect = psImageAlloc(readout->image->numCols, readout->image->numRows, PS_TYPE_F32); 167 psImageInit(suspect, 0); 168 psMetadataAddImage(output->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_SUSPECT, PS_META_REPLACE, 169 "Suspect pixels", suspect); 170 psMetadataAddS32(output->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_NUM, PS_META_REPLACE, 171 "Number of input images", 0); 172 } 173 174 psImage *image = readout->image; // Image of interest 175 psImage *mask = readout->mask; // Corresponding mask 176 177 psTrace ("psModules.detrend", 3, "suspect: < %f or > %f\n", min, max); 178 179 // XXX this loop could result in pixels with suspect = 0.0 but no valid input pixels (all 180 // masked). need to track the number of good as well as suspect pixels? 181 for (int y = 0; y < image->numRows; y++) { 182 for (int x = 0; x < image->numCols; x++) { 183 bool above = image->data.F32[y][x] > max; 184 bool below = image->data.F32[y][x] < min; 185 if (!above && !below) continue; 130 186 if (mask && (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) continue; 131 187 suspect->data.F32[y][x] += 1.0; -
trunk/psModules/src/detrend/pmMaskBadPixels.h
r21183 r24113 50 50 /// high value in the suspect pixels image, allowing them to be identified. The suspect pixels 51 51 /// image is of type S32. The relevant median and standard deviation must be supplied in the 52 /// readout->analysis metadata as READOUT.MEDIAN, READOUT.STDEV e53 bool pmMaskFlagSuspectPixels (pmReadout *output, ///< Output readout, optionally with suspect pixels image52 /// readout->analysis metadata as READOUT.MEDIAN, READOUT.STDEV 53 bool pmMaskFlagSuspectPixelsBySigma(pmReadout *output, ///< Output readout, optionally with suspect pixels image 54 54 const pmReadout *readout, ///< Readout to inspect 55 55 float median, ///< Image median 56 56 float stdev, ///< Image standard deviation 57 57 float rej, ///< Rejection threshold (standard deviations) 58 psImageMaskType maskVal ///< Mask value for statistics 59 ); 60 61 /// Find out-of-range pixels and flag them 62 /// 63 /// Pixels great > max or < min have the corresponding pixel in the "suspect pixels" image 64 /// incremented. After accumulating over a suitable sample of images, bad pixels should have a 65 /// high value in the suspect pixels image, allowing them to be identified. The suspect pixels 66 /// image is of type S32. The relevant median and standard deviation must be supplied in the 67 /// readout->analysis metadata as READOUT.MEDIAN, READOUT.STDEV 68 bool pmMaskFlagSuspectPixelsByValue(pmReadout *output, ///< Output readout, optionally with suspect pixels image 69 const pmReadout *readout, ///< Readout to inspect 70 float min, ///< Image min acceptable value 71 float max, ///< Image max acceptable value 58 72 psImageMaskType maskVal ///< Mask value for statistics 59 73 );
Note:
See TracChangeset
for help on using the changeset viewer.
