Changeset 15374
- Timestamp:
- Oct 25, 2007, 10:17:34 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/ppStats/src/ppStatsReadout.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStats/src/ppStatsReadout.c
r14430 r15374 119 119 bool get_nSatPixels = false; 120 120 bool get_fSatPixels = false; 121 bool findNumGood = false; // Return the number of good pixels? 122 bool findFracGood = false; // Return the fraction of good pixels? 121 123 122 124 psListIterator *iterator = psListIteratorAlloc(data->summary, PS_LIST_HEAD, false); 123 125 psString choice; 124 126 while ((choice = psListGetAndIncrement(iterator))) { 125 if (!strcasecmp (choice, "SAT_PIXEL_NUM")) get_nSatPixels = true; 126 if (!strcasecmp (choice, "SAT_PIXEL_FRAC")) get_fSatPixels = true; 127 } 128 129 if (!get_nSatPixels && !get_fSatPixels) { 130 goto readoutDone; 131 } 132 133 // Get the "concepts" of interest 134 float saturation = psMetadataLookupF32(&mdok, readout->parent->concepts, "CELL.SATURATION"); // Saturation level 135 if (!mdok || isnan(saturation)) { 136 psLogMsg(__func__, PS_LOG_WARN, "CELL.SATURATION is not set --- unable to measure N_SAT_PIXELS.\n"); 137 if (get_nSatPixels) psMetadataAddS32(readoutResults, PS_LIST_TAIL, "SAT_PIXEL_NUM", 0, NULL, 0); 138 if (get_fSatPixels) psMetadataAddF32(readoutResults, PS_LIST_TAIL, "SAT_PIXEL_FRAC", 0, NULL, NAN); 139 goto readoutDone; 140 } 141 142 int nSatPixels = 0; 143 for (int j = 0; j < readout->image->numRows; j++) { 144 for (int i = 0; i < readout->image->numCols; i++) { 145 if (readout->image->data.F32[j][i] >= saturation) { 146 nSatPixels ++; 127 if (!strcasecmp(choice, "SAT_PIXEL_NUM")) get_nSatPixels = true; 128 if (!strcasecmp(choice, "SAT_PIXEL_FRAC")) get_fSatPixels = true; 129 if (!strcasecmp(choice, "GOOD_PIXEL_NUM")) findNumGood = true; 130 if (!strcasecmp(choice, "GOOD_PIXEL_NUM")) findFracGood = true; 131 } 132 133 if (get_nSatPixels || get_fSatPixels) { 134 // Find the saturation point 135 float saturation = psMetadataLookupF32(&mdok, readout->parent->concepts, 136 "CELL.SATURATION"); // Saturation level 137 if (!mdok || isnan(saturation)) { 138 psWarning("CELL.SATURATION is not set --- unable to measure N_SAT_PIXELS.\n"); 139 if (get_nSatPixels) { 140 psMetadataAddS32(readoutResults, PS_LIST_TAIL, "SAT_PIXEL_NUM", 0, NULL, 0); 141 } 142 if (get_fSatPixels) { 143 psMetadataAddF32(readoutResults, PS_LIST_TAIL, "SAT_PIXEL_FRAC", 0, NULL, NAN); 144 } 145 } else { 146 int nSatPixels = 0; 147 for (int j = 0; j < readout->image->numRows; j++) { 148 for (int i = 0; i < readout->image->numCols; i++) { 149 if (readout->image->data.F32[j][i] >= saturation) { 150 nSatPixels ++; 151 } 152 } 153 } 154 if (get_nSatPixels) { 155 psMetadataAddS32(readoutResults, PS_LIST_TAIL, "SAT_PIXEL_NUM", 0, 156 "Number of saturated pixels", nSatPixels); 157 } 158 if (get_fSatPixels) { 159 psMetadataAddF32(readoutResults, PS_LIST_TAIL, "SAT_PIXEL_FRAC", 0, 160 "Fraction of saturated pixels", 161 nSatPixels / (float)(readout->image->numRows * readout->image->numCols)); 147 162 } 148 163 } 149 164 } 150 if (get_nSatPixels) psMetadataAddS32(readoutResults, PS_LIST_TAIL, "SAT_PIXEL_NUM", 0, NULL, nSatPixels); 151 if (get_fSatPixels) psMetadataAddF32(readoutResults, PS_LIST_TAIL, "SAT_PIXEL_FRAC", 0, NULL, nSatPixels / (double)(readout->image->numRows * readout->image->numCols)); 165 166 if (findNumGood || findFracGood) { 167 if (!readout->mask || data->maskVal == 0) { 168 psWarning("Number or fraction of good pixels requested, but no mask provided"); 169 if (findNumGood) { 170 psMetadataAddS32(readoutResults, PS_LIST_TAIL, "GOOD_PIXEL_NUM", 0, NULL, 0); 171 } 172 if (findFracGood) { 173 psMetadataAddF32(readoutResults, PS_LIST_TAIL, "GOOD_PIXEL_FRAC", 0, NULL, NAN); 174 } 175 } else { 176 int numBad = 0; // Number of bad pixels 177 for (int j = 0; j < readout->mask->numRows; j++) { 178 for (int i = 0; i < readout->mask->numCols; i++) { 179 if (readout->mask->data.PS_TYPE_MASK_DATA[j][i] & data->maskVal) { 180 numBad++; 181 } 182 } 183 } 184 185 int numTotal = readout->mask->numRows * readout->mask->numCols; // Total number of pixels 186 int numGood = numTotal - numBad; // Number of good pixels 187 if (findNumGood) { 188 psMetadataAddS32(readoutResults, PS_LIST_TAIL, "GOOD_PIXEL_NUM", 0, 189 "Number of good pixels", numGood); 190 } 191 if (findFracGood) { 192 psMetadataAddF32(readoutResults, PS_LIST_TAIL, "GOOD_PIXEL_FRAC", 0, 193 "Fraction of good pixels", numGood / (float)numTotal); 194 } 195 } 196 } 152 197 } 153 198
Note:
See TracChangeset
for help on using the changeset viewer.
