Changeset 2832
- Timestamp:
- Dec 27, 2004, 1:16:51 PM (22 years ago)
- Location:
- trunk/psModules
- Files:
-
- 2 edited
-
src/pmReadoutCombine.c (modified) (14 diffs)
-
test/tst_pmReadoutCombine.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmReadoutCombine.c
r2829 r2832 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-12-27 2 0:14:29$7 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-12-27 23:16:51 $ 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.24 22 *****************************************************************************/ 25 psStatsOptions p_psDetermineNumBits(psStatsOptions data)23 psStatsOptions DetermineNumBits(psStatsOptions data) 26 24 { 27 25 psS32 i; … … 38 36 } 39 37 38 /****************************************************************************** 39 p_psDetermineNumBits(data): This routine takes an enum psStatsOptions as an 40 argument and returns the number of non-zero bits. 41 42 XXX: Must add support for S16 and S32 types. F32 currently supported. 43 *****************************************************************************/ 40 44 psImage *pmReadoutCombine(psImage *output, 41 45 const psList *inputs, … … 52 56 if (zero != NULL) { 53 57 PS_VECTOR_CHECK_TYPE(zero, PS_TYPE_F32, NULL); 58 // PS_VECTOR_CHECK_TYPE_S16_S32_F32(zero, NULL); 54 59 } 55 60 if (scale != NULL) { 56 61 PS_VECTOR_CHECK_TYPE(scale, PS_TYPE_F32, NULL); 62 // PS_VECTOR_CHECK_TYPE_S16_S32_F32(scale, NULL); 57 63 } 58 64 if ((zero != NULL) && (scale != NULL)) { 59 65 PS_VECTOR_CHECK_TYPE_EQUAL(zero, scale, NULL); 60 // XXX: Currently only type F32 is implemented.61 66 // PS_VECTOR_CHECK_TYPE_S16_S32_F32(scale, NULL); 62 67 } … … 75 80 psElemType outputType = PS_TYPE_F32; 76 81 77 if (1 < p_psDetermineNumBits(params->stats->options)) {82 if (1 < DetermineNumBits(params->stats->options)) { 78 83 psError(PS_ERR_UNKNOWN, true, 79 84 "Multiple statistical options have been requested.\n"); … … 92 97 // output->row0 + output->numRows 93 98 // to determine if the output image actually stores that pixel. A similar 94 // thing is done for the minimu lrow and column.99 // thing is done for the minimum row and column. 95 100 // 96 101 tmpInput = (psListElem *) inputs->head; … … 120 125 121 126 // We ensure that the zero vector is of the proper size. 122 123 127 if (zero != NULL) { 124 128 PS_VECTOR_CHECK_TYPE(zero, PS_TYPE_F32, NULL); … … 166 170 167 171 if ((output->col0 > minInputCols) || (output->row0 > minInputRows)) { 168 //XXX ERROR "Output image offset is larger then input image offset.\n"); 172 psError(PS_ERR_UNKNOWN, true, 173 "Output image offset is larger then input image offset.\n"); 169 174 return(NULL); 170 175 } … … 172 177 173 178 psVector *tmpPixels = psVectorAlloc(numInputs, PS_TYPE_F32); 179 psVector *tmpPixelErrors = psVectorAlloc(numInputs, PS_TYPE_F32); 174 180 psVector *tmpPixelMask = psVectorAlloc(numInputs, PS_TYPE_U8); 175 181 psVector *tmpPixelMaskNKeep = psVectorAlloc(numInputs, PS_TYPE_U8); … … 266 272 } 267 273 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 { 274 if ((gain > 0.0) && (readnoise >= 0.0)) { 272 275 psF32 x; 273 276 psF32 sigma; … … 286 289 sigma = PS_SQRT_F32((readnoise*readnoise) + gain * x) / gain; 287 290 288 tmpPixels->data.F32[r]= SOME_FUNC(x, sigma); 291 tmpPixelErrors->data.F32[r] = sigma; 292 tmpPixels->data.F32[r]= x; 289 293 } 290 294 } else { … … 304 308 sigma = PS_SQRT_F32((readnoise*readnoise) + (gain * sigma)) / gain; 305 309 306 tmpPixels->data.F32[r]= SOME_FUNC(x, sigma); 307 } 308 } 310 tmpPixelErrors->data.F32[r] = sigma; 311 tmpPixels->data.F32[r]= x; 312 } 313 } 314 // Calculate the specified statistic on the stack of pixels. 315 stats = psVectorStats(stats, 316 tmpPixels, 317 tmpPixelErrors, 318 tmpPixelMaskNKeep, 319 1); 309 320 } else { 310 321 if (scale != NULL) { … … 320 331 } 321 332 } 322 } 323 324 // Calculate the specified statistic on the stack of pixels. 325 stats = psVectorStats(stats, 326 tmpPixels, 327 NULL, 328 tmpPixelMaskNKeep, 329 1); 333 334 // Calculate the specified statistic on the stack of pixels. 335 stats = psVectorStats(stats, 336 tmpPixels, 337 NULL, 338 tmpPixelMaskNKeep, 339 1); 340 } 341 330 342 331 343 // Set the pixel value in the output image to the stat value. 332 344 double statValue; 333 345 if (!p_psGetStatValue(stats, &statValue)) { 334 //XXX ERROR: "Could not determine stats value.\n"346 psError(PS_ERR_UNKNOWN, true, "Could not determine stats value.\n"); 335 347 return(NULL); 336 348 } else { … … 341 353 342 354 psFree(tmpPixels); 355 psFree(tmpPixelErrors); 343 356 psFree(tmpPixelMask); 344 357 psFree(tmpPixelMaskNKeep); -
trunk/psModules/test/tst_pmReadoutCombine.c
r2829 r2832 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-12-27 2 0:14:29$7 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-12-27 23:16:51 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 11 * 12 * XXX: Untested: 13 * S16, S32 types 14 * Multiple input readouts with varying sizes and offsets. 15 * params->fracLow and params->fracHigh 16 * params->nKeep 17 * (gain > 0.0) && (readnoise >= 0.0) (applyZeroScale == true) 18 * (gain > 0.0) && (readnoise >= 0.0) (applyZeroScale == false) 19 * 11 20 */ 12 21 … … 23 32 24 33 #define NUM_READOUTS 10 25 #define INPUT_NUM_ROWS 1026 #define INPUT_NUM_COLS 1034 #define INPUT_NUM_ROWS 20 35 #define INPUT_NUM_COLS 20 27 36 #define VEC_ZERO 1.0 28 37 #define VEC_SCALE 2.0 … … 50 59 } 51 60 52 int doit() 61 /****************************************************************************** 62 simpleCombineNoOverlap(): this routine creates a list of NUM_READOUTS input 63 readouts and calls pmReadoutCombine(). 64 *****************************************************************************/ 65 66 int simpleCombineNoOverlap(psS32 numInputCols, psS32 numInputRows) 53 67 { 54 68 int i; … … 94 108 baseRows[r] = 0; 95 109 baseCols[r] = 0; 96 numRows[r] = INPUT_NUM_ROWS;97 numCols[r] = INPUT_NUM_COLS;110 numRows[r] = numInputRows; 111 numCols[r] = numInputCols; 98 112 99 113 psImage *tmpImage = psImageAlloc(numCols[r], numRows[r], PS_TYPE_F32); … … 146 160 int testStatus = 0; 147 161 148 testStatus |= doit(); 162 testStatus |= simpleCombineNoOverlap(1, 1); 163 testStatus |= simpleCombineNoOverlap(INPUT_NUM_COLS, 1); 164 testStatus |= simpleCombineNoOverlap(1, INPUT_NUM_ROWS); 165 testStatus |= simpleCombineNoOverlap(INPUT_NUM_COLS, INPUT_NUM_ROWS); 149 166 150 167 return(testStatus); … … 345 362 346 363 printf("----------------------------------------------------------------------------\n"); 364 printf("Calling pmReadoutCombine() row0/col0 too large. Should generate error, return NULL.\n"); 365 output = psImageAlloc(1, 1, PS_TYPE_F32); 366 *(psS32*)&output->row0 = 10000; 367 *(psS32*)&output->col0 = 10000; 368 rc = pmReadoutCombine(output, list, params, zero, scale, true, 0.0, 0.0); 369 if (rc != NULL) { 370 printf("ERROR: pmReadoutCombine() did not return NULL\n"); 371 testStatus = false; 372 } 373 psFree(output); 374 output = NULL; 375 376 printf("----------------------------------------------------------------------------\n"); 347 377 printf("Calling pmReadoutCombine() with NULL input list. Should generate error, return NULL.\n"); 348 378 rc = pmReadoutCombine(output, NULL, params, zero, scale, true, 0.0, 0.0);
Note:
See TracChangeset
for help on using the changeset viewer.
