IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 19, 2007, 4:22:26 PM (19 years ago)
Author:
Paul Price
Message:

Extensive changes to APIs to allow use of a nominated value to mask
against (the maskVal). Previously, the mask values were either
hard-coded (e.g., PM_MASK_SAT) or taken as anything non-zero. The
code is tested under psphot (which has similar changes) and does not
crash, but neither is it successful in marking all bad pixels (EAM
will investigate). For this reason, I have left the "gutter" pixels
(cell gaps) set to 0 instead of NAN in pmFPAMosaic.

File:
1 edited

Legend:

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

    r13803 r13898  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-06-13 23:41:51 $
     8 *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-06-20 02:22:26 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6060    tmp->radiusFit = 0;
    6161    tmp->flags = PM_MODEL_STATUS_NONE;
    62     tmp->residuals = NULL;              // XXX should the model own this memory?
     62    tmp->residuals = NULL;              // XXX should the model own this memory?
    6363
    6464    psS32 Nparams = pmModelParameterCount(type);
     
    105105/******************************************************************************
    106106    pmModelEval(source, level, row): evaluates the model function at the specified coords.
    107  
     107
    108108    NOTE: The coords are in subImage source->pixel coords, not image coords.
    109  
     109
    110110    XXX: Use static vectors for x (NO: needs to be thread safe)
    111111*****************************************************************************/
     
    132132}
    133133
    134 bool AddOrSubModel(psImage *image,
    135                    psImage *mask,
    136                    pmModel *model,
    137                    pmModelOpMode mode,
    138                    bool add
    139                       )
     134static bool AddOrSubModel(psImage *image,
     135                          psImage *mask,
     136                          pmModel *model,
     137                          pmModelOpMode mode,
     138                          bool add,
     139                          psMaskType maskVal
     140    )
    140141{
    141142    psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     
    151152    psS32 imageRow;
    152153    psF32 pixelValue;
    153    
     154
    154155    // save original values; restore before returning
    155156    // use the true source position for the residual model
     
    161162
    162163    if (mode & PM_MODEL_OP_NORM) {
    163         params->data.F32[PM_PAR_I0] = 1.0;
     164        params->data.F32[PM_PAR_I0] = 1.0;
    164165    }
    165166    if (!(mode & PM_MODEL_OP_SKY)) {
    166         params->data.F32[PM_PAR_SKY] = 0.0;
     167        params->data.F32[PM_PAR_SKY] = 0.0;
    167168    }
    168169    if (mode & PM_MODEL_OP_CENTER) {
    169         params->data.F32[PM_PAR_XPOS] = image->col0 + 0.5*image->numCols;
    170         params->data.F32[PM_PAR_YPOS] = image->row0 + 0.5*image->numRows;
     170        params->data.F32[PM_PAR_XPOS] = image->col0 + 0.5*image->numCols;
     171        params->data.F32[PM_PAR_YPOS] = image->row0 + 0.5*image->numRows;
    171172    }
    172173
     
    185186    psImageInterpolateOptions *Ry = NULL;
    186187    if (model->residuals && (mode & (PM_MODEL_OP_RES0 | PM_MODEL_OP_RES1))) {
    187         Ro = psImageInterpolateOptionsAlloc(
    188             PS_INTERPOLATE_BILINEAR,
    189             model->residuals->Ro, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
    190         Rx = psImageInterpolateOptionsAlloc(
    191             PS_INTERPOLATE_BILINEAR,
    192             model->residuals->Rx, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
    193         Ry = psImageInterpolateOptionsAlloc(
    194             PS_INTERPOLATE_BILINEAR,
    195             model->residuals->Ry, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
    196 
    197         xBin = model->residuals->xBin;
    198         yBin = model->residuals->yBin;
    199         xResidCenter = model->residuals->xCenter;
    200         yResidCenter = model->residuals->yCenter;
     188        Ro = psImageInterpolateOptionsAlloc(
     189            PS_INTERPOLATE_BILINEAR,
     190            model->residuals->Ro, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
     191        Rx = psImageInterpolateOptionsAlloc(
     192            PS_INTERPOLATE_BILINEAR,
     193            model->residuals->Rx, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
     194        Ry = psImageInterpolateOptionsAlloc(
     195            PS_INTERPOLATE_BILINEAR,
     196            model->residuals->Ry, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
     197
     198        xBin = model->residuals->xBin;
     199        yBin = model->residuals->yBin;
     200        xResidCenter = model->residuals->xCenter;
     201        yResidCenter = model->residuals->yCenter;
    201202    }
    202203
    203204    for (psS32 iy = 0; iy < image->numRows; iy++) {
    204205        for (psS32 ix = 0; ix < image->numCols; ix++) {
    205             if ((mask != NULL) && mask->data.U8[iy][ix])
     206            if ((mask != NULL) && (mask->data.U8[iy][ix] & maskVal))
    206207                continue;
    207208
    208209            // Convert i/j to image coord space:
    209             // XXX should we use using 0.5 pixel offset?
    210             imageCol = ix + image->col0;
    211             imageRow = iy + image->row0;
     210            // XXX should we use using 0.5 pixel offset?
     211            imageCol = ix + image->col0;
     212            imageRow = iy + image->row0;
    212213
    213214            x->data.F32[0] = (float) imageCol;
    214215            x->data.F32[1] = (float) imageRow;
    215216
    216             pixelValue = 0.0;
     217            pixelValue = 0.0;
    217218
    218219            // add in the desired components for this coordinate
    219220            if (mode & PM_MODEL_OP_FUNC) {
    220221                pixelValue += modelFunc (NULL, params, x);
    221             } 
    222 
    223             // get the contribution from the residual model
    224             if (Ro) {
    225                 // fractional image position
    226                 float ox = xBin*(imageCol + 0.5 - xCenter) + xResidCenter;
    227                 float oy = yBin*(imageRow + 0.5 - yCenter) + yResidCenter;
    228 
    229                 if (mode & PM_MODEL_OP_RES0) {
    230                     psU8 mflux = 0;
    231                     double Fo = 0.0;
    232                     psImageInterpolate (&Fo, NULL, &mflux, ox, oy, Ro);
    233                     if (!mflux && isfinite(Fo)) {
    234                         pixelValue += Io*Fo;
    235                     }
    236                 }
    237                 if (mode & PM_MODEL_OP_RES1) {
    238                     psU8 mflux = 0;
    239                     double Fx = 0.0;
    240                     double Fy = 0.0;
    241                     psImageInterpolate (&Fx, NULL, &mflux, ox, oy, Rx);
    242                     psImageInterpolate (&Fy, NULL, &mflux, ox, oy, Ry);
    243                     if (!mflux && isfinite(Fx) && isfinite(Fy)) {
    244                         pixelValue += Io*(xPos*Fx + yPos*Fy);
    245                     }
    246                 }
    247             }
     222            }
     223
     224            // get the contribution from the residual model
     225            if (Ro) {
     226                // fractional image position
     227                float ox = xBin*(imageCol + 0.5 - xCenter) + xResidCenter;
     228                float oy = yBin*(imageRow + 0.5 - yCenter) + yResidCenter;
     229
     230                if (mode & PM_MODEL_OP_RES0) {
     231                    psU8 mflux = 0;
     232                    double Fo = 0.0;
     233                    psImageInterpolate (&Fo, NULL, &mflux, ox, oy, Ro);
     234                    if (!mflux && isfinite(Fo)) {
     235                        pixelValue += Io*Fo;
     236                    }
     237                }
     238                if (mode & PM_MODEL_OP_RES1) {
     239                    psU8 mflux = 0;
     240                    double Fx = 0.0;
     241                    double Fy = 0.0;
     242                    psImageInterpolate (&Fx, NULL, &mflux, ox, oy, Rx);
     243                    psImageInterpolate (&Fy, NULL, &mflux, ox, oy, Ry);
     244                    if (!mflux && isfinite(Fx) && isfinite(Fy)) {
     245                        pixelValue += Io*(xPos*Fx + yPos*Fy);
     246                    }
     247                }
     248            }
    248249
    249250            // add or subtract the value
     
    275276                psImage *mask,
    276277                pmModel *model,
    277                 pmModelOpMode mode)
    278 {
    279     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
    280     psBool rc = AddOrSubModel(image, mask, model, mode, true);
     278                pmModelOpMode mode,
     279                psMaskType maskVal)
     280{
     281    psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     282    psBool rc = AddOrSubModel(image, mask, model, mode, true, maskVal);
    281283    psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc);
    282284    return(rc);
     
    288290                psImage *mask,
    289291                pmModel *model,
    290                 pmModelOpMode mode)
    291 {
    292     psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
    293     psBool rc = AddOrSubModel(image, mask, model, mode, false);
     292                pmModelOpMode mode,
     293                psMaskType maskVal)
     294{
     295    psTrace("psModules.objects", 3, "---- %s() begin ----\n", __func__);
     296    psBool rc = AddOrSubModel(image, mask, model, mode, false, maskVal);
    294297    psTrace("psModules.objects", 3, "---- %s(%d) end ----\n", __func__, rc);
    295298    return(rc);
Note: See TracChangeset for help on using the changeset viewer.