Changeset 2829 for trunk/psModules/src/pmReadoutCombine.c
- Timestamp:
- Dec 27, 2004, 10:14:29 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmReadoutCombine.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmReadoutCombine.c
r2819 r2829 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-12-2 4 02:39:17$7 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-12-27 20:14:29 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 20 20 p_psDetermineNumBits(data): This routine takes an enum psStatsOptions as an 21 21 argument and returns the number of non-zero bits. 22 23 XXX: Use static vectors. 22 24 *****************************************************************************/ 23 25 psStatsOptions p_psDetermineNumBits(psStatsOptions data) … … 36 38 } 37 39 38 // XXX: Whats this?39 #define MAX_INT 1000040 40 psImage *pmReadoutCombine(psImage *output, 41 41 const psList *inputs, … … 44 44 const psVector *scale, 45 45 bool applyZeroScale, 46 floatgain,47 floatreadnoise)46 psF32 gain, 47 psF32 readnoise) 48 48 { 49 49 PS_PTR_CHECK_NULL(inputs, NULL); … … 63 63 64 64 psStats *stats = params->stats; 65 inti;66 intj;67 intmaxInputCols = 0;68 intmaxInputRows = 0;69 int minInputCols = MAX_INT;70 int minInputRows = MAX_INT;65 psS32 i; 66 psS32 j; 67 psS32 maxInputCols = 0; 68 psS32 maxInputRows = 0; 69 psS32 minInputCols = PS_MAX_S32; 70 psS32 minInputRows = PS_MAX_S32; 71 71 psListElem *tmpInput = NULL; 72 72 psReadout *tmpReadout = NULL; 73 intnumInputs = 0;74 inttmpI;73 psS32 numInputs = 0; 74 psS32 tmpI; 75 75 psElemType outputType = PS_TYPE_F32; 76 76 … … 153 153 output = psImageAlloc(maxInputCols-minInputCols, 154 154 maxInputRows-minInputRows, outputType); 155 *( int*) &(output->col0) = minInputCols;156 *( int*) &(output->row0) = minInputRows;155 *(psS32 *) &(output->col0) = minInputCols; 156 *(psS32 *) &(output->row0) = minInputRows; 157 157 } else { 158 158 if (((output->col0 + output->numCols) < maxInputCols) || … … 210 210 for (i = output->row0; i < (output->row0 + output->numRows) ; i++) { 211 211 for (j = output->col0; j < (output->col0 + output->numCols) ; j++) { 212 for ( intr = 0; r < numInputs ; r++) {212 for (psS32 r = 0; r < numInputs ; r++) { 213 213 // printf("[%d][%d]: [%d][%d] to [%d][%d]\n", i, j, outRowLower->data.U32[r], outColLower->data.U32[r], outRowUpper->data.U32[r], outColUpper->data.U32[r]); 214 214 if ((outRowLower->data.U32[r] <= i) && … … 217 217 (outColUpper->data.U32[r] > j)) { 218 218 219 intimageRow = i - (tmpReadouts[r]->row0 +220 tmpReadouts[r]->image->row0);221 intimageCol = j - (tmpReadouts[r]->col0 +222 tmpReadouts[r]->image->col0);219 psS32 imageRow = i - (tmpReadouts[r]->row0 + 220 tmpReadouts[r]->image->row0); 221 psS32 imageCol = j - (tmpReadouts[r]->col0 + 222 tmpReadouts[r]->image->col0); 223 223 224 224 if ((NULL == tmpReadouts[r]->mask) || … … 240 240 241 241 // Determine how many pixels lie between fracLow and fracHigh. 242 intpixelCount = 0;243 for ( intr = 0; r < numInputs ; r++) {242 psS32 pixelCount = 0; 243 for (psS32 r = 0; r < numInputs ; r++) { 244 244 if (tmpPixelMask->data.U8[r] == 0) { 245 245 if ((params->fracLow <= tmpPixels->data.F32[r]) && … … 254 254 // that range. 255 255 if (pixelCount >= params->nKeep) { 256 for ( intr = 0; r < numInputs ; r++) {256 for (psS32 r = 0; r < numInputs ; r++) { 257 257 if (tmpPixelMask->data.U8[r] == 0) { 258 258 if ((params->fracLow <= tmpPixels->data.F32[r]) && … … 266 266 } 267 267 268 // XXX: Is this correct? 269 // We scale the pixels by the scale vector, if not-NULL. 270 if (scale != NULL) { 271 for (int r = 0; r < numInputs ; r++) { 272 tmpPixels->data.F32[r]*= scale->data.F32[r]; 273 } 274 } 275 276 // XXX: Is this correct? 277 // We add the zero vector, if non-NULL. 278 if (zero != NULL) { 279 for (int r = 0; r < numInputs ; r++) { 280 tmpPixels->data.F32[r]+= zero->data.F32[r]; 281 } 282 } 283 284 // XXX: Is this correct? 285 if (gain > 0.0) { 286 for (int r = 0; r < numInputs ; r++) { 287 tmpPixels->data.F32[r]*= gain; 288 } 289 } 290 291 // XXX: Is this correct? 292 if (!(readnoise < 0.0)) { 293 for (int r = 0; r < numInputs ; r++) { 294 tmpPixels->data.F32[r]+= readnoise; 268 // XXX: Still waiting on clarification of the algorithm. 269 #define SOME_FUNC(X, SIGMA) ((X)) 270 if ((gain > 0.0) && (readnoise >= 0.0)) 271 { 272 psF32 x; 273 psF32 sigma; 274 if (applyZeroScale == true) { 275 for (psS32 r = 0; r < numInputs ; r++) { 276 if (zero != NULL) { 277 x = zero->data.F32[r]; 278 } else { 279 x = 0.0; 280 } 281 if (scale != NULL) { 282 x+= tmpPixels->data.F32[r] * scale->data.F32[r]; 283 } else { 284 x+= tmpPixels->data.F32[r]; 285 } 286 sigma = PS_SQRT_F32((readnoise*readnoise) + gain * x) / gain; 287 288 tmpPixels->data.F32[r]= SOME_FUNC(x, sigma); 289 } 290 } else { 291 for (psS32 r = 0; r < numInputs ; r++) { 292 x= tmpPixels->data.F32[r]; 293 294 if (zero != NULL) { 295 sigma = zero->data.F32[r]; 296 } else { 297 sigma = 0.0; 298 } 299 if (scale != NULL) { 300 sigma+= tmpPixels->data.F32[r] * scale->data.F32[r]; 301 } else { 302 sigma+= tmpPixels->data.F32[r]; 303 } 304 sigma = PS_SQRT_F32((readnoise*readnoise) + (gain * sigma)) / gain; 305 306 tmpPixels->data.F32[r]= SOME_FUNC(x, sigma); 307 } 308 } 309 } else { 310 if (scale != NULL) { 311 for (psS32 r = 0; r < numInputs ; r++) { 312 tmpPixels->data.F32[r]*= scale->data.F32[r]; 313 } 314 } 315 316 // We add the zero vector, if non-NULL. 317 if (zero != NULL) { 318 for (psS32 r = 0; r < numInputs ; r++) { 319 tmpPixels->data.F32[r]+= zero->data.F32[r]; 320 } 295 321 } 296 322 } … … 309 335 return(NULL); 310 336 } else { 311 output->data.F32[i-output->row0][j-output->col0] = ( float) statValue;337 output->data.F32[i-output->row0][j-output->col0] = (psF32) statValue; 312 338 } 313 339 }
Note:
See TracChangeset
for help on using the changeset viewer.
