IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 2, 2007, 5:18:21 PM (19 years ago)
Author:
magnier
Message:

moved JPEG options from the file rules to PPIMAGE recipe

File:
1 edited

Legend:

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

    r10715 r10883  
    55 *  @author EAM, IfA
    66 *
    7  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-12-14 06:27:52 $
     7 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-01-03 03:18:21 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    123123bool pmReadoutWriteJPEG (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
    124124{
     125    bool status;
    125126    PS_ASSERT_PTR_NON_NULL(readout, false);
    126127    PS_ASSERT_PTR_NON_NULL(view, false);
     
    134135    psTrace("psModules.camera", 3, "writing jpeg for readout %zd\n", (size_t) readout);
    135136
    136     // XXX we need to decide where the scale will come from in the long term
     137    psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PPIMAGE");
     138    if (!status) {
     139        psError(PS_ERR_UNKNOWN, true, "missing recipe PPIMAGE in config data");
     140        return false;
     141    }
     142
     143    psMetadata *options = psMetadataLookupMetadata(&status, recipe, file->name);
     144    if (!status) {
     145        psError(PS_ERR_UNKNOWN, true, "missing %s options in PPIMAGE recipe", file->name);
     146        return false;
     147    }
     148
    137149    float min, max;                 // Minimum and maximum for stretch
    138150    float mean, delta;
     151
     152    // measure the image statistics for scaling
    139153    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0);
    140154    psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN);
     
    159173    psFree(stats);
    160174
    161     psString mode = pmFPAfileNameFromRule (file->extrule, file, view);
    162     psString word = pmFPAfileNameFromRule (file->extxtra, file, view);
    163     psArray *range = psStringSplitArray (word, ":", false);
    164 
    165     if (!strcasecmp (mode, "RANGE") && range) {
    166         float fmin = atof(range->data[0]);
    167         float fmax = atof(range->data[1]);
     175    char *colormapName = psMemIncrRefCounter (psMetadataLookupStr (NULL, options, "COLORMAP"));
     176    if (!colormapName)
     177        colormapName = psStringCopy ("-greyscale");
     178    char *mode = psMemIncrRefCounter (psMetadataLookupStr (NULL, options, "SCALE.MODE"));
     179    if (!mode)
     180        mode = psStringCopy ("RANGE");
     181    float fmin = psMetadataLookupF32 (&status, options, "SCALE.MIN");
     182    if (!status)
     183        fmin = -3.0;
     184    float fmax = psMetadataLookupF32 (&status, options, "SCALE.MAX");
     185    if (!status)
     186        fmax = +6.0;
     187
     188    if (!strcasecmp (mode, "RANGE")) {
    168189        min = mean + fmin*delta;
    169190        max = mean + fmax*delta;
    170     } else if (!strcasecmp (mode, "FRACTION")) {
    171         float fmin = atof(range->data[0]);
    172         float fmax = atof(range->data[1]);
     191    }
     192    if (!strcasecmp (mode, "FRACTION")) {
    173193        min = fmin*mean;
    174194        max = fmax*mean;
    175     } else {
    176         min = mean - 3*delta;
    177         max = mean + 6*delta;
    178     }
    179     psFree(mode);
    180     psFree(word);
    181     psFree(range);
     195    }
     196    if (!strcasecmp (mode, "VALUE")) {
     197        min = fmin;
     198        max = fmax;
     199    }
     200
    182201
    183202    if (!isfinite(min) || !isfinite(max)) {
     
    189208    psString name = pmFPAfileNameFromRule (file->filerule, file, view);
    190209    psString newName = pmConfigConvertFilename (name, config);
    191     psString mapname = pmFPAfileNameFromRule (file->filextra, file, view);
    192     psImageJpegColormap *map = psImageJpegColormapSet (NULL, mapname);
    193     psFree(mapname);
     210
     211    psImageJpegColormap *map = psImageJpegColormapSet (NULL, colormapName);
    194212    if (!map) {
    195213        map = psImageJpegColormapSet (NULL, "-greyscale");
     
    197215
    198216    psImageJpeg (map, readout->image, newName, min, max);
     217
     218    psFree(name);
    199219    psFree(newName);
    200     psFree(name);
     220
    201221    psFree(map);
    202 
    203     return true;
    204 }
     222    psFree(colormapName);
     223    psFree(mode);
     224    return true;
     225}
Note: See TracChangeset for help on using the changeset viewer.