IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30019


Ignore:
Timestamp:
Dec 11, 2010, 8:35:56 AM (15 years ago)
Author:
eugene
Message:

add return status variable for a good fit vs bad fit : it is not an error for the data to be unfittable, but it needs to be distinguished from a failure

Location:
branches/eam_branches/ipp-20101205/psLib/src/imageops
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/psLib/src/imageops/psImageMapFit.c

    r25753 r30019  
    4848
    4949// map defines the output image dimensions and scaling.
    50 bool psImageMapFit(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
     50bool psImageMapFit(bool *goodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
    5151                   const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    5252{
    5353    // XXX Add Asserts
     54
     55    *goodFit = false;
    5456
    5557    // dimensions of the output map image
     
    8183        map->map->data.F32[0][0]   = psStatsGetValue(map->stats, mean);
    8284        map->error->data.F32[0][0] = psStatsGetValue(map->stats, stdev);
     85        *goodFit = true;
    8386        return true;
    8487    }
     
    8689    if (Nx == 1) {
    8790        bool status;
    88         status = psImageMapFit1DinY (map, mask, maskValue, x, y, f, df);
     91        status = psImageMapFit1DinY (goodFit, map, mask, maskValue, x, y, f, df);
    8992        return status;
    9093    }
    9194    if (Ny == 1) {
    9295        bool status;
    93         status = psImageMapFit1DinX (map, mask, maskValue, x, y, f, df);
     96        status = psImageMapFit1DinX (goodFit, map, mask, maskValue, x, y, f, df);
    9497        return status;
    9598    }
     
    310313
    311314    if (!psMatrixGJSolve(A, B)) {
    312         psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations.  Returning NULL.\n");
    313315        psFree (A);
    314316        psFree (B);
    315         return false;
     317        return true;
    316318    }
    317319
     
    337339    psFree (Empty);
    338340
     341    *goodFit = true;
    339342    return true;
    340343}
    341344
    342345// measure residuals on each pass and clip outliers based on stats
    343 bool psImageMapClipFit(psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue,
     346bool psImageMapClipFit(bool *goodFit, psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue,
    344347                       const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    345348{
     
    351354    psAssert(f, "impossible");
    352355
     356    *goodFit = false;
     357
    353358    // the user supplies one of various stats option pairs,
    354359    // determine the desired mean and stdev STATS options:
     
    393398        psTrace("psLib.imageops", 6, "Loop iteration %d.  Calling psImageMapFit()\n", N);
    394399        psS32 Nkeep = 0;
    395         if (!psImageMapFit(map, mask, maskValue, x, y, f, df)) {
     400        if (!psImageMapFit(goodFit, map, mask, maskValue, x, y, f, df)) {
    396401            psError(PS_ERR_UNKNOWN, false, "Could not fit image map.\n");
    397402            psFree(resid);
     
    399404            return false;
    400405        }
     406        if (!goodFit) {
     407            psWarning ("bad fit to image map, try something else");
     408            return true;
     409        }
    401410
    402411        psVector *fit = psImageMapEvalVector(map, mask, maskValue, x, y);
     
    454463    psFree(resid);
    455464    if (!inMask) psFree (mask);
     465    *goodFit = true; // XXX probably don't need to set this (set by psImageMapFit)
    456466    return true;
    457467}
    458468
    459469// map defines the output image dimensions and scaling.
    460 bool psImageMapFit1DinY(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
     470bool psImageMapFit1DinY(bool *goodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
    461471                        const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    462472{
    463473    // XXX Add Asserts
    464474    assert (map->binning->nXruff == 1);
     475
     476    *goodFit = false;
    465477
    466478    // dimensions of the output map image
     
    578590
    579591    if (!psMatrixGJSolve(A, B)) {
    580         psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations.\n");
    581592        psFree (A);
    582593        psFree (B);
    583594        psFree (Empty);
    584         return false;
     595        return true;
    585596    }
    586597
     
    602613    psFree (Empty);
    603614
     615    *goodFit = true;
    604616    return true;
    605617}
    606618
    607619// map defines the output image dimensions and scaling.
    608 bool psImageMapFit1DinX(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
     620bool psImageMapFit1DinX(bool *goodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
    609621                        const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    610622{
    611623    // XXX Add Asserts
    612624    assert (map->binning->nYruff == 1);
     625
     626    *goodFit = false;
    613627
    614628    // dimensions of the output map image
     
    726740
    727741    if (!psMatrixGJSolve(A, B)) {
    728         psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations..\n");
    729742        psFree (A);
    730743        psFree (B);
    731744        psFree (Empty);
    732         return false;
     745        return true;
    733746    }
    734747
     
    750763    psFree (Empty);
    751764
     765    *goodFit = true;
    752766    return true;
    753767}
  • branches/eam_branches/ipp-20101205/psLib/src/imageops/psImageMapFit.h

    r25753 r30019  
    88
    99// fit the image map to a set of points
    10 bool psImageMapFit(psImageMap *map,
     10bool psImageMapFit(bool *goodFit,
     11                   psImageMap *map,
    1112                   const psVector *mask,
    1213                   psVectorMaskType maskValue, //
     
    1819
    1920// fit the image map to a set of points
    20 bool psImageMapClipFit(psImageMap *map,
     21bool psImageMapClipFit(bool *goodFit,
     22                       psImageMap *map,
    2123                       psStats *stats,
    2224                       psVector *mask,  // WARNING: Mask is modified!
     
    2830    );
    2931
    30 bool psImageMapFit1DinY(psImageMap *map,
     32bool psImageMapFit1DinY(bool *goodFit,
     33                        psImageMap *map,
    3134                        const psVector *mask,
    3235                        psVectorMaskType maskValue,
     
    3740    );
    3841
    39 bool psImageMapFit1DinX(psImageMap *map,
     42bool psImageMapFit1DinX(bool *goodFit,
     43                        psImageMap *map,
    4044                        const psVector *mask,
    4145                        psVectorMaskType maskValue,
Note: See TracChangeset for help on using the changeset viewer.