IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2832


Ignore:
Timestamp:
Dec 27, 2004, 1:16:51 PM (22 years ago)
Author:
gusciora
Message:

Added an errors argument to the psVectorStats() call.

Location:
trunk/psModules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/pmReadoutCombine.c

    r2829 r2832  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-12-27 20:14:29 $
     7 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-12-27 23:16:51 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2020p_psDetermineNumBits(data): This routine takes an enum psStatsOptions as an
    2121argument and returns the number of non-zero bits.
    22  
    23 XXX: Use static vectors.
    2422 *****************************************************************************/
    25 psStatsOptions p_psDetermineNumBits(psStatsOptions data)
     23psStatsOptions DetermineNumBits(psStatsOptions data)
    2624{
    2725    psS32 i;
     
    3836}
    3937
     38/******************************************************************************
     39p_psDetermineNumBits(data): This routine takes an enum psStatsOptions as an
     40argument and returns the number of non-zero bits.
     41 
     42XXX: Must add support for S16 and S32 types.  F32 currently supported.
     43 *****************************************************************************/
    4044psImage *pmReadoutCombine(psImage *output,
    4145                          const psList *inputs,
     
    5256    if (zero != NULL) {
    5357        PS_VECTOR_CHECK_TYPE(zero, PS_TYPE_F32, NULL);
     58        //        PS_VECTOR_CHECK_TYPE_S16_S32_F32(zero, NULL);
    5459    }
    5560    if (scale != NULL) {
    5661        PS_VECTOR_CHECK_TYPE(scale, PS_TYPE_F32, NULL);
     62        //        PS_VECTOR_CHECK_TYPE_S16_S32_F32(scale, NULL);
    5763    }
    5864    if ((zero != NULL) && (scale != NULL)) {
    5965        PS_VECTOR_CHECK_TYPE_EQUAL(zero, scale, NULL);
    60         // XXX: Currently only type F32 is implemented.
    6166        // PS_VECTOR_CHECK_TYPE_S16_S32_F32(scale, NULL);
    6267    }
     
    7580    psElemType outputType = PS_TYPE_F32;
    7681
    77     if (1 < p_psDetermineNumBits(params->stats->options)) {
     82    if (1 < DetermineNumBits(params->stats->options)) {
    7883        psError(PS_ERR_UNKNOWN, true,
    7984                "Multiple statistical options have been requested.\n");
     
    9297    //     output->row0 + output->numRows
    9398    // to determine if the output image actually stores that pixel.  A similar
    94     // thing is done for the minimul row and column.
     99    // thing is done for the minimum row and column.
    95100    //
    96101    tmpInput = (psListElem *) inputs->head;
     
    120125
    121126    // We ensure that the zero vector is of the proper size.
    122 
    123127    if (zero != NULL) {
    124128        PS_VECTOR_CHECK_TYPE(zero, PS_TYPE_F32, NULL);
     
    166170
    167171        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");
    169174            return(NULL);
    170175        }
     
    172177
    173178    psVector *tmpPixels = psVectorAlloc(numInputs, PS_TYPE_F32);
     179    psVector *tmpPixelErrors = psVectorAlloc(numInputs, PS_TYPE_F32);
    174180    psVector *tmpPixelMask = psVectorAlloc(numInputs, PS_TYPE_U8);
    175181    psVector *tmpPixelMaskNKeep = psVectorAlloc(numInputs, PS_TYPE_U8);
     
    266272            }
    267273
    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)) {
    272275                psF32 x;
    273276                psF32 sigma;
     
    286289                        sigma = PS_SQRT_F32((readnoise*readnoise) + gain * x) / gain;
    287290
    288                         tmpPixels->data.F32[r]= SOME_FUNC(x, sigma);
     291                        tmpPixelErrors->data.F32[r] = sigma;
     292                        tmpPixels->data.F32[r]= x;
    289293                    }
    290294                } else {
     
    304308                        sigma = PS_SQRT_F32((readnoise*readnoise) + (gain * sigma)) / gain;
    305309
    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);
    309320            } else {
    310321                if (scale != NULL) {
     
    320331                    }
    321332                }
    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
    330342
    331343            // Set the pixel value in the output image to the stat value.
    332344            double statValue;
    333345            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");
    335347                return(NULL);
    336348            } else {
     
    341353
    342354    psFree(tmpPixels);
     355    psFree(tmpPixelErrors);
    343356    psFree(tmpPixelMask);
    344357    psFree(tmpPixelMaskNKeep);
  • trunk/psModules/test/tst_pmReadoutCombine.c

    r2829 r2832  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-12-27 20:14:29 $
     7 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-12-27 23:16:51 $
    99 *
    1010 *  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 *
    1120 */
    1221
     
    2332
    2433#define NUM_READOUTS  10
    25 #define INPUT_NUM_ROWS 10
    26 #define INPUT_NUM_COLS 10
     34#define INPUT_NUM_ROWS 20
     35#define INPUT_NUM_COLS 20
    2736#define VEC_ZERO 1.0
    2837#define VEC_SCALE 2.0
     
    5059}
    5160
    52 int doit()
     61/******************************************************************************
     62simpleCombineNoOverlap(): this routine creates a list of NUM_READOUTS input
     63readouts and calls pmReadoutCombine().
     64 *****************************************************************************/
     65
     66int simpleCombineNoOverlap(psS32 numInputCols, psS32 numInputRows)
    5367{
    5468    int i;
     
    94108        baseRows[r] = 0;
    95109        baseCols[r] = 0;
    96         numRows[r] = INPUT_NUM_ROWS;
    97         numCols[r] = INPUT_NUM_COLS;
     110        numRows[r] = numInputRows;
     111        numCols[r] = numInputCols;
    98112
    99113        psImage *tmpImage = psImageAlloc(numCols[r], numRows[r], PS_TYPE_F32);
     
    146160    int testStatus = 0;
    147161
    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);
    149166
    150167    return(testStatus);
     
    345362
    346363    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");
    347377    printf("Calling pmReadoutCombine() with NULL input list.  Should generate error, return NULL.\n");
    348378    rc = pmReadoutCombine(output, NULL, params, zero, scale, true, 0.0, 0.0);
Note: See TracChangeset for help on using the changeset viewer.