IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10715


Ignore:
Timestamp:
Dec 13, 2006, 8:27:52 PM (20 years ago)
Author:
magnier
Message:

test output from stats to ensure jpeg is written

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPA_JPEG.c

    r10421 r10715  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-12-03 18:48:10 $
     7 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-12-14 06:27:52 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    117117}
    118118
    119 // read in all readout-level Objects files for this cell
     119// write JPEG image for readout
     120// note that this function will try as hard a possible to write out a jpeg.  it will not fail
     121// just because the values are in a poor range.  it is more convenient to know you are getting
     122// a jpeg which is weird than to fail to get the file at all.
    120123bool pmReadoutWriteJPEG (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    121124{
     
    129132    }
    130133
     134    psTrace("psModules.camera", 3, "writing jpeg for readout %zd\n", (size_t) readout);
     135
    131136    // XXX we need to decide where the scale will come from in the long term
     137    float min, max;                 // Minimum and maximum for stretch
     138    float mean, delta;
    132139    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0);
    133140    psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN);
    134141    stats->nSubsample = 10000;
    135142    if (!psImageBackground(stats, readout->image, NULL, 0, rng)) {
    136         psError(PS_ERR_UNKNOWN, false, "Unable to write JPEG of readout.\n");
    137         psFree(rng);
    138         psFree(stats);
    139         return false;
     143        psStats *statsAlt = psStatsAlloc(PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV);
     144        stats->nSubsample = 10000;
     145        if (!psImageBackground(stats, readout->image, NULL, 0, rng)) {
     146            psLogMsg("jpeg", PS_LOG_WARN, "Unable to measure statistics for image, writing blank jpeg\n");
     147            mean = 0;
     148            delta = 1;
     149        } else {
     150            mean = statsAlt->sampleMean;
     151            delta = 2*statsAlt->sampleStdev;
     152        }
     153        psFree(statsAlt);
     154    } else {
     155        mean = stats->robustMedian;
     156        delta = stats->robustUQ - stats->robustLQ;
    140157    }
    141158    psFree(rng);
    142 
    143     if (!isfinite(stats->robustMedian) || !isfinite(stats->robustUQ) || !isfinite(stats->robustLQ)) {
    144         psError(PS_ERR_UNKNOWN, false, "Unable to measure statistics for image.\n");
    145         psFree(stats);
    146         return false;
    147     }
    148     float delta = stats->robustUQ - stats->robustLQ; // Inter-quartile range
    149     float min, max;                 // Minimum and maximum for stretch
     159    psFree(stats);
    150160
    151161    psString mode = pmFPAfileNameFromRule (file->extrule, file, view);
     
    156166        float fmin = atof(range->data[0]);
    157167        float fmax = atof(range->data[1]);
    158         min = stats->robustMedian + fmin*delta;
    159         max = stats->robustMedian + fmax*delta;
     168        min = mean + fmin*delta;
     169        max = mean + fmax*delta;
    160170    } else if (!strcasecmp (mode, "FRACTION")) {
    161171        float fmin = atof(range->data[0]);
    162172        float fmax = atof(range->data[1]);
    163         min = fmin*stats->robustMedian;
    164         max = fmax*stats->robustMedian;
     173        min = fmin*mean;
     174        max = fmax*mean;
    165175    } else {
    166         min = stats->robustMedian - 3*delta;
    167         max = stats->robustMedian + 6*delta;
     176        min = mean - 3*delta;
     177        max = mean + 6*delta;
    168178    }
    169179    psFree(mode);
    170180    psFree(word);
    171181    psFree(range);
    172     psFree(stats);
    173182
    174183    if (!isfinite(min) || !isfinite(max)) {
    175         psError(PS_ERR_UNKNOWN, true, "The stretch parameters are not both finite.\n");
    176         return false;
     184        psLogMsg("jpeg", PS_LOG_WARN, "The stretch parameters are not both finite, writing blank jpeg\n");
     185        min = 0;
     186        max = 1;
    177187    }
    178188
Note: See TracChangeset for help on using the changeset viewer.