IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 20, 2010, 2:30:45 PM (16 years ago)
Author:
watersc1
Message:

Attempting to bring branch in sync with trunk

Location:
branches/czw_branch/20101203
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/czw_branch/20101203

  • branches/czw_branch/20101203/psLib/src/imageops

  • branches/czw_branch/20101203/psLib/src/imageops/psImageMapFit.c

    r25753 r30118  
    4848
    4949// map defines the output image dimensions and scaling.
    50 bool psImageMapFit(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
     50bool psImageMapFit(bool *pGoodFit, 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    *pGoodFit = 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        if (isfinite(map->map->data.F32[0][0]) && isfinite( map->error->data.F32[0][0])) {
     86            *pGoodFit = true;
     87        }
    8388        return true;
    8489    }
     
    8691    if (Nx == 1) {
    8792        bool status;
    88         status = psImageMapFit1DinY (map, mask, maskValue, x, y, f, df);
     93        status = psImageMapFit1DinY (pGoodFit, map, mask, maskValue, x, y, f, df);
    8994        return status;
    9095    }
    9196    if (Ny == 1) {
    9297        bool status;
    93         status = psImageMapFit1DinX (map, mask, maskValue, x, y, f, df);
     98        status = psImageMapFit1DinX (pGoodFit, map, mask, maskValue, x, y, f, df);
    9499        return status;
    95100    }
     
    310315
    311316    if (!psMatrixGJSolve(A, B)) {
    312         psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations.  Returning NULL.\n");
    313317        psFree (A);
    314318        psFree (B);
    315         return false;
     319        return true;
    316320    }
    317321
     
    337341    psFree (Empty);
    338342
     343    *pGoodFit = true;
    339344    return true;
    340345}
    341346
    342347// measure residuals on each pass and clip outliers based on stats
    343 bool psImageMapClipFit(psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue,
     348bool psImageMapClipFit(bool *pGoodFit, psImageMap *map, psStats *stats, psVector *inMask, psVectorMaskType maskValue,
    344349                       const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    345350{
     
    351356    psAssert(f, "impossible");
    352357
     358    *pGoodFit = false;
     359
    353360    // the user supplies one of various stats option pairs,
    354361    // determine the desired mean and stdev STATS options:
     
    393400        psTrace("psLib.imageops", 6, "Loop iteration %d.  Calling psImageMapFit()\n", N);
    394401        psS32 Nkeep = 0;
    395         if (!psImageMapFit(map, mask, maskValue, x, y, f, df)) {
     402        if (!psImageMapFit(pGoodFit, map, mask, maskValue, x, y, f, df)) {
    396403            psError(PS_ERR_UNKNOWN, false, "Could not fit image map.\n");
    397404            psFree(resid);
     
    399406            return false;
    400407        }
     408        if (!*pGoodFit) {
     409            psWarning ("bad fit to image map, try something else");
     410            return true;
     411        }
    401412
    402413        psVector *fit = psImageMapEvalVector(map, mask, maskValue, x, y);
     
    454465    psFree(resid);
    455466    if (!inMask) psFree (mask);
     467    *pGoodFit = true; // XXX probably don't need to set this (set by psImageMapFit)
    456468    return true;
    457469}
    458470
    459471// map defines the output image dimensions and scaling.
    460 bool psImageMapFit1DinY(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
     472bool psImageMapFit1DinY(bool *pGoodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
    461473                        const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    462474{
    463475    // XXX Add Asserts
    464476    assert (map->binning->nXruff == 1);
     477
     478    *pGoodFit = false;
    465479
    466480    // dimensions of the output map image
     
    578592
    579593    if (!psMatrixGJSolve(A, B)) {
    580         psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations.\n");
    581594        psFree (A);
    582595        psFree (B);
    583596        psFree (Empty);
    584         return false;
     597        return true;
    585598    }
    586599
     
    602615    psFree (Empty);
    603616
     617    *pGoodFit = true;
    604618    return true;
    605619}
    606620
    607621// map defines the output image dimensions and scaling.
    608 bool psImageMapFit1DinX(psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
     622bool psImageMapFit1DinX(bool *pGoodFit, psImageMap *map, const psVector *mask, psVectorMaskType maskValue,
    609623                        const psVector *x, const psVector *y, const psVector *f, const psVector *df)
    610624{
    611625    // XXX Add Asserts
    612626    assert (map->binning->nYruff == 1);
     627
     628    *pGoodFit = false;
    613629
    614630    // dimensions of the output map image
     
    726742
    727743    if (!psMatrixGJSolve(A, B)) {
    728         psError(PS_ERR_UNKNOWN, false, "Could not solve linear equations..\n");
    729744        psFree (A);
    730745        psFree (B);
    731746        psFree (Empty);
    732         return false;
     747        return true;
    733748    }
    734749
     
    750765    psFree (Empty);
    751766
     767    *pGoodFit = true;
    752768    return true;
    753769}
Note: See TracChangeset for help on using the changeset viewer.