IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29473


Ignore:
Timestamp:
Oct 17, 2010, 12:31:48 PM (16 years ago)
Author:
eugene
Message:

the measured centroid, with a Gaussian window, is biased by the error in the guess position; do an initial iteration on the centroid using an un-windowed measurement, then refine with the gaussian window

Location:
branches/eam_branches/ipp-20100823/psModules/src/objects
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100823/psModules/src/objects/pmSource.h

    r29472 r29473  
    249249  psF32 sigma,
    250250  psF32 minSN,
    251   psImageMaskType maskVal);
     251  psImageMaskType maskVal,
     252  float xGuess, float yGuess);
    252253
    253254pmModel *pmSourceGetModel (bool *isPSF, const pmSource *source);
  • branches/eam_branches/ipp-20100823/psModules/src/objects/pmSourceMoments.c

    r29443 r29473  
    6464void pmSourceMomentsSetVerbose(bool state){ beVerbose = state; }
    6565
    66 bool pmSourceMomentsGetCentroid(pmSource *source, psF32 radius, psF32 sigma, psF32 minSN, psImageMaskType maskVal);
    67 
    6866// if mode & EXTERNAL or mode2 & MATCHED, do not re-calculate the centroid (use peak as centroid)
    6967
     
    9694    // (int) so they can be used in the image index below.
    9795
    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)) {
    99103        return false;
    100104    }
     
    314318}
    315319
    316 bool pmSourceMomentsGetCentroid(pmSource *source, psF32 radius, psF32 sigma, psF32 minSN, psImageMaskType maskVal) {
     320bool pmSourceMomentsGetCentroid(pmSource *source, psF32 radius, psF32 sigma, psF32 minSN, psImageMaskType maskVal, float xGuess, float yGuess) {
    317321
    318322    // First Pass: calculate the first moments (these are subtracted from the coordinates below)
     
    333337    psF32 rsigma2 = 0.5 / PS_SQR(sigma);
    334338
    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
    339341
    340342    // we are guaranteed to have a valid pixel and variance at this location (right? right?)
     
    344346    // psAssert (source->variance->data.F32[yPeak][xPeak] > 0, "peak must be on valid pixel");
    345347
     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
    346353    for (psS32 row = 0; row < source->pixels->numRows ; row++) {
    347354
    348         psF32 yDiff = row - yPeak;
     355        psF32 yDiff = row + 0.5 - yPeak;
    349356        if (fabs(yDiff) > radius) continue;
    350357
     
    363370            if (isnan(*vPix)) continue;
    364371
    365             psF32 xDiff = col - xPeak;
     372            psF32 xDiff = col + 0.5 - xPeak;
    366373            if (fabs(xDiff) > radius) continue;
    367374
     
    439446        source->moments->My = source->peak->yf;
    440447    } else {
    441         source->moments->Mx = Mx + xOff + 0.5;
    442         source->moments->My = My + yOff + 0.5;
     448        source->moments->Mx = Mx + xGuess;
     449        source->moments->My = My + yGuess;
    443450    }
    444451
Note: See TracChangeset for help on using the changeset viewer.