IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15587


Ignore:
Timestamp:
Nov 11, 2007, 11:49:18 AM (18 years ago)
Author:
eugene
Message:

fix case of mismatch between image/mask and residual sizes

File:
1 edited

Legend:

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

    r15562 r15587  
    66 *  @author EAM, IfA
    77 *
    8  *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-11-10 01:09:20 $
     8 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-11-11 21:49:18 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    218218    float yResidCenter = 0.0;
    219219
     220    psImage *myRo = NULL;
     221    psImage *myRx = NULL;
     222    psImage *myRy = NULL;
    220223    psImageInterpolateOptions *Ro = NULL;
    221224    psImageInterpolateOptions *Rx = NULL;
    222225    psImageInterpolateOptions *Ry = NULL;
    223226    if (model->residuals && (mode & (PM_MODEL_OP_RES0 | PM_MODEL_OP_RES1))) {
    224         Ro = psImageInterpolateOptionsAlloc(
    225             PS_INTERPOLATE_BILINEAR,
    226             model->residuals->Ro, NULL, mask, 0, 0.0, 0.0, 1, 0, 0.0);
    227         Rx = psImageInterpolateOptionsAlloc(
    228             PS_INTERPOLATE_BILINEAR,
    229             model->residuals->Rx, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
    230         Ry = psImageInterpolateOptionsAlloc(
    231             PS_INTERPOLATE_BILINEAR,
    232             model->residuals->Ry, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
     227        // if the residual image and object image don't match,
     228        // supply an appropriately overlapped residual image
     229        psImage *inRo = model->residuals->Ro;
     230        psImage *inRx = model->residuals->Rx;
     231        psImage *inRy = model->residuals->Ry;
     232        if ((image->numCols != inRo->numCols) ||
     233            (image->numRows != inRo->numRows)) {
     234            myRo = psImageAlloc (image->numCols, image->numRows, PS_TYPE_F32);
     235            myRx = psImageAlloc (image->numCols, image->numRows, PS_TYPE_F32);
     236            myRy = psImageAlloc (image->numCols, image->numRows, PS_TYPE_F32);
     237            dx = (int)(inRx->numCols / 2) - (xPos - image->col0);
     238            dy = (int)(inRx->numCols / 2) - (xPos - image->col0);
     239            for (int iy = 0; iy < myRo->numRows; iy++) {
     240                int jy = iy + dy;
     241                if ((jy < 0) || (jy >= inRo->numRows)) {
     242                    for (int ix = 0; ix < myRo->numCols; ix++) {
     243                        myRo->data.F32[iy][ix] = 0.0;
     244                        myRx->data.F32[iy][ix] = 0.0;
     245                        myRy->data.F32[iy][ix] = 0.0;
     246                    }
     247                    continue;
     248                }
     249                for (int ix = 0; ix < myRo->numCols; ix++) {
     250                    int jx = ix + dx;
     251                    if ((jx < 0) || (jx >= inRo->numCols)) {
     252                        myRo->data.F32[iy][ix] = 0.0;
     253                        myRx->data.F32[iy][ix] = 0.0;
     254                        myRy->data.F32[iy][ix] = 0.0;
     255                    } else {
     256                        myRo->data.F32[iy][ix] = inRo->data.F32[jy][jx];
     257                        myRx->data.F32[iy][ix] = inRx->data.F32[jy][jx];
     258                        myRy->data.F32[iy][ix] = inRy->data.F32[jy][jx];
     259                    }
     260                }
     261            }           
     262        } else {
     263            myRo = psMemIncrRefCounter (inRo);
     264            myRx = psMemIncrRefCounter (inRx);
     265            myRy = psMemIncrRefCounter (inRy);
     266        }
     267
     268        Ro = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BILINEAR, myRo, NULL, mask, 0, 0.0, 0.0, 1, 0, 0.0);
     269        Rx = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BILINEAR, myRx, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
     270        Ry = psImageInterpolateOptionsAlloc(PS_INTERPOLATE_BILINEAR, myRy, NULL, NULL, 0, 0.0, 0.0, 1, 0, 0.0);
    233271
    234272        xBin = model->residuals->xBin;
     
    303341    psFree(Rx);
    304342    psFree(Ry);
     343    psFree(myRo);
     344    psFree(myRx);
     345    psFree(myRy);
    305346    psTrace("psModules.objects", 3, "---- %s(true) end ----\n", __func__);
    306347    return(true);
Note: See TracChangeset for help on using the changeset viewer.