Changeset 42511
- Timestamp:
- Aug 17, 2023, 3:27:26 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20230313/psModules/src/objects/pmSourceMoments.c
r38873 r42511 231 231 } 232 232 233 // For faint externally-supplied sources, the centroids are unreliable. 234 // In those cases, we should keep the peak position instead of the centroid position. 235 bool skipCentroid = false; 236 skipCentroid |= (source->mode & PM_SOURCE_MODE_EXTERNAL); // skip externally supplied positions 237 skipCentroid |= (source->mode2 & PM_SOURCE_MODE2_MATCHED); // skip sources defined by other image positions 238 233 239 // if we have less than (1/4) of the possible pixels (in circle or box), force a retry 234 240 int minPixels = PS_MIN(0.75*R2, source->pixels->numCols*source->pixels->numRows/4.0); 235 241 236 242 // XXX EAM - the limit is a bit arbitrary. make it user defined? 237 if ( (numPixels < minPixels) || (Sum <= 0)) {243 if (numPixels < minPixels) { 238 244 psTrace ("psModules.objects", 3, "insufficient valid pixels (%d vs %d; %f) for source\n", numPixels, minPixels, Sum); 245 return (false); 246 } 247 248 // Skip negative-sum sources, but only if the sources are not forced (externally supplied) 249 if (!skipCentroid && (Sum <= 0)) { 250 psTrace ("psModules.objects", 3, "insufficient significant pixels (%d vs %d; %f) for source\n", numPixels, minPixels, Sum); 239 251 return (false); 240 252 } … … 243 255 float Mx = X1/Sum; 244 256 float My = Y1/Sum; 245 if ((fabs(Mx) > radius) || (fabs(My) > radius)) {246 psTrace ("psModules.objects", 3, "extreme centroid swing; invalid peak %d, %d\n", source->peak->x, source->peak->y);247 return (false);248 }249 257 if ((fabs(Mx) > 2.0) || (fabs(My) > 2.0)) { 250 258 psTrace ("psModules.objects", 3, " big centroid swing; ok peak? %d, %d\n", source->peak->x, source->peak->y); 251 259 } 252 253 260 psTrace ("psModules.objects", 5, "id: %d, sky: %f Mx: %f My: %f Sum: %f X1: %f Y1: %f Npix: %d\n", source->id, sky, Mx, My, Sum, X1, Y1, numPixels); 261 262 // XXX EAM : I need to move this block so I can use SN to choose if we keep the centroids or not 263 source->moments->Sum = Sum; 264 source->moments->SN = Sum / sqrt(Var); 265 source->moments->Peak = peakPixel; 266 source->moments->nPixels = numPixels; 254 267 255 268 // add back offset of peak in primary image … … 258 271 // 0.5 PIX: moments are calculated using the pixel index and converted here to pixel coords 259 272 260 // we only update the centroid if the position is not supplied from elsewhere 261 bool skipCentroid = false; 262 skipCentroid |= (source->mode & PM_SOURCE_MODE_EXTERNAL); // skip externally supplied positions 263 skipCentroid |= (source->mode2 & PM_SOURCE_MODE2_MATCHED); // skip sources defined by other image positions 264 265 if (skipCentroid) { 273 // XXX for a test, do NOT skip the centroid for relatively strong sources, even if forced 274 // XXX this is a somewhat arbitrary limit. use PSF_SN_LIM (see below) instead? 275 if (skipCentroid && (source->moments->SN < 25)) { 266 276 source->moments->Mx = source->peak->xf; 267 277 source->moments->My = source->peak->yf; 268 278 } else { 279 if ((fabs(Mx) > radius) || (fabs(My) > radius)) { 280 psTrace ("psModules.objects", 3, "extreme centroid swing; invalid peak %d, %d\n", source->peak->x, source->peak->y); 281 282 // XXX should we really be rejecting these sources, or just keeping the peak position? 283 return (false); 284 285 source->moments->Mx = source->peak->xf; 286 source->moments->My = source->peak->yf; 287 return (true); 288 } 269 289 source->moments->Mx = Mx + xGuess; 270 290 source->moments->My = My + yGuess; 271 291 } 272 273 source->moments->Sum = Sum;274 source->moments->SN = Sum / sqrt(Var);275 source->moments->Peak = peakPixel;276 source->moments->nPixels = numPixels;277 292 278 293 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
