Changeset 10883
- Timestamp:
- Jan 2, 2007, 5:18:21 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPA_JPEG.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPA_JPEG.c
r10715 r10883 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $8 * @date $Date: 200 6-12-14 06:27:52$7 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2007-01-03 03:18:21 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 123 123 bool pmReadoutWriteJPEG (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, pmConfig *config) 124 124 { 125 bool status; 125 126 PS_ASSERT_PTR_NON_NULL(readout, false); 126 127 PS_ASSERT_PTR_NON_NULL(view, false); … … 134 135 psTrace("psModules.camera", 3, "writing jpeg for readout %zd\n", (size_t) readout); 135 136 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 137 149 float min, max; // Minimum and maximum for stretch 138 150 float mean, delta; 151 152 // measure the image statistics for scaling 139 153 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); 140 154 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); … … 159 173 psFree(stats); 160 174 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")) { 168 189 min = mean + fmin*delta; 169 190 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")) { 173 193 min = fmin*mean; 174 194 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 182 201 183 202 if (!isfinite(min) || !isfinite(max)) { … … 189 208 psString name = pmFPAfileNameFromRule (file->filerule, file, view); 190 209 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); 194 212 if (!map) { 195 213 map = psImageJpegColormapSet (NULL, "-greyscale"); … … 197 215 198 216 psImageJpeg (map, readout->image, newName, min, max); 217 218 psFree(name); 199 219 psFree(newName); 200 psFree(name); 220 201 221 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.
