Changeset 41806 for branches/eam_branches/ipp-dev-20210817/psModules
- Timestamp:
- Sep 8, 2021, 10:03:37 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-dev-20210817/psModules/src/detrend/pmPattern.c
r41804 r41806 171 171 return true; 172 172 } 173 174 # if (0) 173 175 float lower = stats->robustMedian - thresh * stats->robustStdev; // Lower bound for data 174 176 float upper = stats->robustMedian + thresh * stats->robustStdev; // Upper bound for data 175 177 float background = stats->robustMedian; 178 # else 179 180 // the signal we are looking for is a small variation on top of the background. if 181 // the background is uniform with only read noise + sky noise, then the pixel-to-pixel 182 // stdev should only be due to known noise sources and predictable. If the 183 // pixel-to-pixel variations are from other features, then those variations will 184 // probably dominate the row-by-row bias variations. 185 186 // instead of using the image pixel statistics to measure the stdev, lets assume only 187 // dark noise plus poisson sky noise. we are not carrying in the read noise, but it is 188 // fairly modest for GPC1 (~10 DN) 189 190 // if we assume a gain of 1 and the read noise of 10 DN, then a sky of 200 would have 191 // a noise of N = sqrt (1 * 200 + 10^2) = sqrt (300) ~ 17 192 193 // if the gain were as much as 2, then the noise in DN would be N = sqrt(2 * (200 + 100)) / 2 = sqrt(300) / sqrt(2) 194 // so smaller by a factor of 1.4 than what we predict, which is not very large 195 196 # define READNOISE 10 197 float sigma = sqrt(stats->robustMedian + PS_SQR(READNOISE)); 198 float lower = stats->robustMedian - thresh * sigma; // Lower bound for data 199 float upper = stats->robustMedian + thresh * sigma; // Upper bound for data 200 float background = stats->robustMedian; 201 # endif 202 203 // the expected amplitude of the 2nd order term is 204 // if the predicted sky poisson signal is larger than 205 206 // I want to add a constraint to the fit so the amplitude or coeffs are |value| < x 207 176 208 psFree(stats); 177 209 psFree(rng); … … 212 244 psVectorInit(yaxisMask, 0); 213 245 #endif 246 247 // we really need more than order + 1 points (= 4). 248 // this should be tunable, but let's try 5 - 10% 249 int validNmin = numCols * 0.1; 250 214 251 for (int y = 0; y < numRows; y++) { 215 252 psVectorInit(clipMask, 0); 216 253 data = psImageRow(data, image, y); 217 254 int num = 0; // Number of good pixels 255 256 // if the unmasked pixels only span a small range in x then we cannot fit the 257 // 2nd order polynomial variations very well. Require a minimum fractional range 258 float validXmin = +1; 259 float validXmax = -1; 260 218 261 for (int x = 0; x < numCols; x++) { 219 262 if ((mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) || … … 223 266 clipMask->data.PS_TYPE_VECTOR_MASK_DATA[x] = 0; 224 267 num++; 268 validXmin = PS_MIN(indices->data.F32[x], validXmin); 269 validXmax = PS_MAX(indices->data.F32[x], validXmax); 225 270 } 226 271 } 227 if (num < order + 1) { 272 273 if (num < validNmin) { 228 274 // Not enough points to fit 229 275 patternMaskRow(ro, y, maskBad); … … 234 280 continue; 235 281 } 282 // XXX does this need to be a clipped fit if we are clipping based on the median poisson noise? 236 283 if (!psVectorClipFitPolynomial1D(poly, clip, clipMask, 0xFF, data, NULL, indices)) { 237 284 psWarning("Unable to fit polynomial to row %d", y);
Note:
See TracChangeset
for help on using the changeset viewer.
