Changeset 10715
- Timestamp:
- Dec 13, 2006, 8:27:52 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPA_JPEG.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPA_JPEG.c
r10421 r10715 5 5 * @author EAM, IfA 6 6 * 7 * @version $Revision: 1.1 4$ $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 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 117 117 } 118 118 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. 120 123 bool pmReadoutWriteJPEG (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, pmConfig *config) 121 124 { … … 129 132 } 130 133 134 psTrace("psModules.camera", 3, "writing jpeg for readout %zd\n", (size_t) readout); 135 131 136 // 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; 132 139 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); 133 140 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); 134 141 stats->nSubsample = 10000; 135 142 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; 140 157 } 141 158 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); 150 160 151 161 psString mode = pmFPAfileNameFromRule (file->extrule, file, view); … … 156 166 float fmin = atof(range->data[0]); 157 167 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; 160 170 } else if (!strcasecmp (mode, "FRACTION")) { 161 171 float fmin = atof(range->data[0]); 162 172 float fmax = atof(range->data[1]); 163 min = fmin* stats->robustMedian;164 max = fmax* stats->robustMedian;173 min = fmin*mean; 174 max = fmax*mean; 165 175 } else { 166 min = stats->robustMedian - 3*delta;167 max = stats->robustMedian + 6*delta;176 min = mean - 3*delta; 177 max = mean + 6*delta; 168 178 } 169 179 psFree(mode); 170 180 psFree(word); 171 181 psFree(range); 172 psFree(stats);173 182 174 183 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; 177 187 } 178 188
Note:
See TracChangeset
for help on using the changeset viewer.
