Changeset 42481
- Timestamp:
- Aug 2, 2023, 2:58:41 PM (3 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmSourceMoments.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmSourceMoments.c
r38873 r42481 231 231 } 232 232 233 // we only update the centroid if the position is not supplied from elsewhere 234 bool skipCentroid = false; 235 skipCentroid |= (source->mode & PM_SOURCE_MODE_EXTERNAL); // skip externally supplied positions 236 skipCentroid |= (source->mode2 & PM_SOURCE_MODE2_MATCHED); // skip sources defined by other image positions 237 233 238 // if we have less than (1/4) of the possible pixels (in circle or box), force a retry 234 239 int minPixels = PS_MIN(0.75*R2, source->pixels->numCols*source->pixels->numRows/4.0); 235 240 236 241 // XXX EAM - the limit is a bit arbitrary. make it user defined? 237 if ( (numPixels < minPixels) || (Sum <= 0)) {242 if (numPixels < minPixels) { 238 243 psTrace ("psModules.objects", 3, "insufficient valid pixels (%d vs %d; %f) for source\n", numPixels, minPixels, Sum); 244 return (false); 245 } 246 247 // only skip negative sum sources if the sources are not forced 248 if (!skipCentroid && (Sum <= 0)) { 249 psTrace ("psModules.objects", 3, "insufficient significant pixels (%d vs %d; %f) for source\n", numPixels, minPixels, Sum); 239 250 return (false); 240 251 } … … 243 254 float Mx = X1/Sum; 244 255 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 256 if ((fabs(Mx) > 2.0) || (fabs(My) > 2.0)) { 250 257 psTrace ("psModules.objects", 3, " big centroid swing; ok peak? %d, %d\n", source->peak->x, source->peak->y); 251 258 } 252 253 259 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); 254 260 … … 258 264 // 0.5 PIX: moments are calculated using the pixel index and converted here to pixel coords 259 265 260 // we only update the centroid if the position is not supplied from elsewhere261 bool skipCentroid = false;262 skipCentroid |= (source->mode & PM_SOURCE_MODE_EXTERNAL); // skip externally supplied positions263 skipCentroid |= (source->mode2 & PM_SOURCE_MODE2_MATCHED); // skip sources defined by other image positions264 265 266 if (skipCentroid) { 266 267 source->moments->Mx = source->peak->xf; 267 268 source->moments->My = source->peak->yf; 268 269 } else { 270 if ((fabs(Mx) > radius) || (fabs(My) > radius)) { 271 psTrace ("psModules.objects", 3, "extreme centroid swing; invalid peak %d, %d\n", source->peak->x, source->peak->y); 272 return (false); 273 } 269 274 source->moments->Mx = Mx + xGuess; 270 275 source->moments->My = My + yGuess;
Note:
See TracChangeset
for help on using the changeset viewer.
