IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9843


Ignore:
Timestamp:
Nov 3, 2006, 5:21:15 AM (20 years ago)
Author:
magnier
Message:

I added code to pmSourcePhotometryAper to shift the source so the
centroid fractional-pixel position matches the centroid of the growth
curve reference object. I make a temporary copy of the object pixels,
then use bilinear interpolation to shift the pixels by the desired
about. Bilinear interpolation is probably too coarse for this step: i
still see a few tenths of a mag error for a 2pixel radius aperture.
note that I added a temporary verion of psImageShift because the
existing code has an error (it seems to be confused about the 0.5
pixel center, or is inconsistent wrt psImageInterpolate).

Location:
trunk/psModules/src/objects
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmSourcePhotometry.c

    r9810 r9843  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-10-31 19:38:44 $
     5 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-11-03 15:21:15 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    182182}
    183183
     184// XXX the implemented version of psImageShift does not work (is inconsistent wrt psImageInterpolate frac pix def?)
     185psImage *tmp_psImageShift (psImage *in, float dx, float dy)
     186{
     187
     188    int nx = in->numCols;
     189    int ny = in->numRows;
     190
     191    psImage *out = psImageAlloc (nx, ny, PS_TYPE_F32);
     192
     193    // we define an integer shift and a (positive) fractional shift
     194    int dxi = floor(dx);
     195    int dyi = floor(dy);
     196    float dxf = dx - dxi;  // +2.3 -> 2 and 0.3; -2.3 -> -3 and +0.7
     197    float dyf = dy - dyi;  // +2.3 -> 2 and 0.3; -2.3 -> -3 and +0.7
     198
     199    // apply the integer shift
     200    int DXin = (dxi < 0) ? -dxi : 0;
     201    int DXot = (dxi < 0) ?   0  : dxi;
     202    int DYin = (dyi < 0) ? -dyi : 0;
     203    int DYot = (dyi < 0) ?   0  : dyi;
     204
     205    for (int j = 0; j < ny - abs(dyi); j++) {
     206        for (int i = 0; i < nx - abs(dxi); i++) {
     207            out->data.F32[j+DYot][i+DXot] = in->data.F32[j+DYin][i+DXin];
     208        }
     209        // fill in the exposed x-border with 0.0
     210        int pix = (dxi > 0) ? 0 : nx - abs(dxi);
     211        for (int i = 0; i < abs(dxi); i++, pix++) {
     212            out->data.F32[j+DYot][pix] = 0.0;
     213        }
     214    }
     215
     216    // fill in the exposed y-border with 0.0
     217    int pix = (dyi > 0) ? 0 : ny - abs(dyi);
     218    for (int j = 0; j < abs(dyi); j++, pix++) {
     219        for (int i = 0; i < nx; i++) {
     220            out->data.F32[pix][i] = 0.0;
     221        }
     222    }
     223
     224    // apply the fractional shift
     225    if ((dxf > 0) || (dyf > 0)) {
     226        float value;
     227
     228        double f00 =    dxf *   dyf;
     229        double f01 =    dxf *(1-dyf);
     230        double f10 = (1-dxf)*   dyf;
     231        double f11 = (1-dxf)*(1-dyf);
     232
     233        for (int j = ny - 2; j >= 0; j--) {
     234            psF32 *V0 = out->data.F32[j+0];
     235            psF32 *V1 = out->data.F32[j+1];
     236            for (int i = nx - 2; i >= 0; i--, V0--, V1--) {
     237                value  = V0[0] * f00;
     238                value += V0[1] * f10;
     239                value += V1[0] * f01;
     240                value += V1[1] * f11;
     241                V1[1] = value;
     242            }
     243        }
     244    }
     245    return out;
     246}
     247
    184248// return source aperture magnitude
     249// interpolate the image pixels to place the center at xi+0.5,yi+0.5
    185250bool pmSourcePhotometryAper (float *apMag, pmModel *model, psImage *image, psImage *mask)
    186251{
     
    199264    }
    200265
     266    // shift image to have centroid at xi+0.5, yi+0.5
     267    # if (1)
     268        float dx = 0.5 - model->params->data.F32[PM_PAR_XPOS] + (int)model->params->data.F32[PM_PAR_XPOS];
     269    float dy = 0.5 - model->params->data.F32[PM_PAR_YPOS] + (int)model->params->data.F32[PM_PAR_YPOS];
     270    psImage *tmpImage = tmp_psImageShift (image, dx, dy);
     271    # else
     272
     273        psImage *tmpImage = psImageCopy (NULL, image, PS_TYPE_F32);
     274    # endif
     275
    201276    // measure apMag
    202277    for (int ix = 0; ix < image->numCols; ix++) {
     
    204279            if (mask->data.U8[iy][ix])
    205280                continue;
    206             apSum += image->data.F32[iy][ix] - sky;
    207         }
    208     }
     281            apSum += tmpImage->data.F32[iy][ix] - sky;
     282        }
     283    }
     284    psFree (tmpImage);
    209285    if (apSum <= 0)
    210286        return false;
  • trunk/psModules/src/objects/pmSourcePhotometry.h

    r9527 r9843  
    33 *  @author EAM, IfA; GLG, MHPCC
    44 *
    5  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2006-10-13 02:24:34 $
     5 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2006-11-03 15:21:15 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5151bool pmSourcePixelWeight (float *pixWeight, pmModel *model, psImage *image, psImage *mask);
    5252
     53psImage *tmp_psImageShift (psImage *in, float dx, float dy);
     54
    5355# endif /* PM_SOURCE_PHOTOMETRY_H */
Note: See TracChangeset for help on using the changeset viewer.