Changeset 29473
- Timestamp:
- Oct 17, 2010, 12:31:48 PM (16 years ago)
- Location:
- branches/eam_branches/ipp-20100823/psModules/src/objects
- Files:
-
- 2 edited
-
pmSource.h (modified) (1 diff)
-
pmSourceMoments.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100823/psModules/src/objects/pmSource.h
r29472 r29473 249 249 psF32 sigma, 250 250 psF32 minSN, 251 psImageMaskType maskVal); 251 psImageMaskType maskVal, 252 float xGuess, float yGuess); 252 253 253 254 pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source); -
branches/eam_branches/ipp-20100823/psModules/src/objects/pmSourceMoments.c
r29443 r29473 64 64 void pmSourceMomentsSetVerbose(bool state){ beVerbose = state; } 65 65 66 bool pmSourceMomentsGetCentroid(pmSource *source, psF32 radius, psF32 sigma, psF32 minSN, psImageMaskType maskVal);67 68 66 // if mode & EXTERNAL or mode2 & MATCHED, do not re-calculate the centroid (use peak as centroid) 69 67 … … 96 94 // (int) so they can be used in the image index below. 97 95 98 if (!pmSourceMomentsGetCentroid (source, radius, sigma, minSN, maskVal)) { 96 // do 2 passes : the first pass should use a somewhat smaller radius and no sigma window to 97 // get an unbiased (but probably noisy) centroid 98 if (!pmSourceMomentsGetCentroid (source, 0.75*radius, 0.0, minSN, maskVal, source->peak->xf, source->peak->yf)) { 99 return false; 100 } 101 // second pass applies the Gaussian window and uses the centroid from the first pass 102 if (!pmSourceMomentsGetCentroid (source, radius, sigma, minSN, maskVal, source->moments->Mx, source->moments->My)) { 99 103 return false; 100 104 } … … 314 318 } 315 319 316 bool pmSourceMomentsGetCentroid(pmSource *source, psF32 radius, psF32 sigma, psF32 minSN, psImageMaskType maskVal ) {320 bool pmSourceMomentsGetCentroid(pmSource *source, psF32 radius, psF32 sigma, psF32 minSN, psImageMaskType maskVal, float xGuess, float yGuess) { 317 321 318 322 // First Pass: calculate the first moments (these are subtracted from the coordinates below) … … 333 337 psF32 rsigma2 = 0.5 / PS_SQR(sigma); 334 338 335 int xOff = source->peak->x; 336 int yOff = source->peak->y; 337 int xPeak = source->peak->x - source->pixels->col0; // coord of peak in subimage 338 int yPeak = source->peak->y - source->pixels->row0; // coord of peak in subimage 339 float xPeak = xGuess - source->pixels->col0; // coord of peak in subimage 340 float yPeak = yGuess - source->pixels->row0; // coord of peak in subimage 339 341 340 342 // we are guaranteed to have a valid pixel and variance at this location (right? right?) … … 344 346 // psAssert (source->variance->data.F32[yPeak][xPeak] > 0, "peak must be on valid pixel"); 345 347 348 // the moments [Sum(x*f) / Sum(f)] are calculated in pixel index values, and should 349 // not depend on the fractional pixel location of the source. However, the aperture 350 // (radius) and the Gaussian window (sigma) depend subtly on the fractional pixel 351 // position of the expected centroid 352 346 353 for (psS32 row = 0; row < source->pixels->numRows ; row++) { 347 354 348 psF32 yDiff = row - yPeak;355 psF32 yDiff = row + 0.5 - yPeak; 349 356 if (fabs(yDiff) > radius) continue; 350 357 … … 363 370 if (isnan(*vPix)) continue; 364 371 365 psF32 xDiff = col - xPeak;372 psF32 xDiff = col + 0.5 - xPeak; 366 373 if (fabs(xDiff) > radius) continue; 367 374 … … 439 446 source->moments->My = source->peak->yf; 440 447 } else { 441 source->moments->Mx = Mx + x Off + 0.5;442 source->moments->My = My + y Off + 0.5;448 source->moments->Mx = Mx + xGuess; 449 source->moments->My = My + yGuess; 443 450 } 444 451
Note:
See TracChangeset
for help on using the changeset viewer.
