IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 15, 2005, 10:09:03 AM (20 years ago)
Author:
gusciora
Message:

SubtractBias was recoded. Significant mods to removeBadPixels.
Additional mods to other files.

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

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmReadoutCombine.c

    r5170 r5516  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-09-28 20:43:52 $
     7 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-11-15 20:09:03 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    374374    return(output);
    375375}
     376
     377
     378/* This function measures the robust median at each of the minimum and maximum
     379 * coordinates and determines the difference and mean of the two values. The size
     380 * of the box used to make the measurement at each point is specified by the
     381 * configuration variable FRINGE_SQUARE_RADIUS. From the collection of
     382 * differences, the robust median is calculated, and returned as part of the
     383 * fringe statistics. For each fringe point, the values of delta and midValue are
     384 * also assigned and available to the user on return.
     385 */
     386
     387psStats *pmFringeStats(
     388    psArray *fringePoints,
     389    psImage *image,
     390    psMetadata *config)
     391{
     392    PS_ASSERT_PTR_NON_NULL(fringePoints, NULL);
     393    //    for (psS32 i = 0 ; i < fringePoints->n ; i++) {
     394    //        if (!psMemCheckFringePoint((pmFringePoint *) fringePoints->data[i])) {
     395    //            psError(PS_ERR_UNKNOWN, true, "fringePoints->data[%d] is not of type pmFringePoint.\n");
     396    //            return(NULL);
     397    //        }
     398    //    }
     399    PS_ASSERT_IMAGE_NON_NULL(image, NULL);
     400    PS_ASSERT_IMAGE_NON_EMPTY(image, NULL);
     401    PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, NULL);
     402    PS_ASSERT_PTR_NON_NULL(config, NULL);
     403
     404    psBool rc;
     405    psF32 frSquareRadius = psMetadataLookupF32(&rc, config, "FRINGE_SQUARE_RADIUS");
     406    if (!rc) {
     407        psError(PS_ERR_UNKNOWN, true, "Could not determing the fringe radius from the metadata.\n");
     408    }
     409
     410    psRegion minRegion;
     411    psRegion maxRegion;
     412    psStats *minStats = psStatsAlloc(PS_STAT_ROBUST_MEAN);
     413    psStats *maxStats = psStatsAlloc(PS_STAT_ROBUST_MEAN);
     414    psStats *diffStats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN);
     415    psVector *diffs = psVectorAlloc(fringePoints->n, PS_TYPE_F32);
     416
     417    //
     418    // Loop through each fringe point.  Determine the robust mean around
     419    // the min and max for that fringe point.  Save the difference between
     420    // those two numbers in psVector diffs.
     421    //
     422    // XXX: Ensure you have the radius correct.  (add 1 to x1 and y1?)
     423    //
     424    for (psS32 i = 0 ; i < fringePoints->n ; i++) {
     425        pmFringePoint *fp = (pmFringePoint *) fringePoints->data[i];
     426        minRegion.x0 = fp->xMin - frSquareRadius;
     427        minRegion.x1 = fp->xMin + frSquareRadius;
     428        minRegion.y0 = fp->yMin - frSquareRadius;
     429        minRegion.y1 = fp->yMin + frSquareRadius;
     430        psImage *minSubImage = psImageSubset(image, minRegion);
     431        minStats = psImageStats(minStats, minSubImage, NULL, 0);
     432
     433        maxRegion.x0 = fp->xMax - frSquareRadius;
     434        maxRegion.x1 = fp->xMax + frSquareRadius;
     435        maxRegion.y0 = fp->yMax - frSquareRadius;
     436        maxRegion.y1 = fp->yMax + frSquareRadius;
     437        psImage *maxSubImage = psImageSubset(image, maxRegion);
     438        maxStats = psImageStats(maxStats, maxSubImage, NULL, 0);
     439
     440        if ((minStats == NULL) || (maxStats == NULL)) {
     441            psError(PS_ERR_UNKNOWN, true, "Could not determine robust mean on subimage.\n");
     442            psFree(minStats);
     443            psFree(maxStats);
     444            return(NULL);
     445        }
     446
     447        fp->midValue = 0.5 * (maxStats->robustMean + minStats->robustMean);
     448        fp->delta = maxStats->robustMean - minStats->robustMean;
     449        diffs->data.F32[i] = fp->delta;
     450    }
     451    psFree(minStats);
     452    psFree(maxStats);
     453
     454    diffStats = psVectorStats(diffStats, diffs, NULL, NULL, 0);
     455    psFree(diffs);
     456    if (diffStats == NULL) {
     457        psError(PS_ERR_UNKNOWN, true, "Could not determine robust median of the differences.\n");
     458        return(NULL);
     459    }
     460    return(diffStats);
     461}
     462
  • trunk/psModules/src/imcombine/pmReadoutCombine.h

    r5170 r5516  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2005-09-28 20:43:52 $
     7 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2005-11-15 20:09:03 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4444                          float readnoise);
    4545
     46/**
     47 *
     48 * This function measures the robust median at each of the minimum and maximum
     49 * coordinates and determines the difference and mean of the two values. The size
     50 * of the box used to make the measurement at each point is specified by the
     51 * configuration variable FRINGE_SQUARE_RADIUS. From the collection of
     52 * differences, the robust median is calculated, and returned as part of the
     53 * fringe statistics. For each fringe point, the values of delta and midValue are
     54 * also assigned and available to the user on return.
     55 *
     56 */
     57psStats *pmFringeStats(
     58    psArray *fringePoints,
     59    psImage *image,
     60    psMetadata *config
     61);
     62
     63typedef struct
     64{
     65    psF64 xMin;
     66    psF64 yMin;
     67    psF64 xMax;
     68    psF64 yMax;
     69    psF64 delta;
     70    psF64 midValue;
     71}
     72pmFringePoint;
     73
    4674#endif
Note: See TracChangeset for help on using the changeset viewer.