IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2829


Ignore:
Timestamp:
Dec 27, 2004, 10:14:29 AM (22 years ago)
Author:
gusciora
Message:

Added new specifications on readout combine operations. Still waiting on
the further clarifications for the pixel combine algorithm (Bug 227).

Location:
trunk/psModules
Files:
2 edited

Legend:

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

    r2819 r2829  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-12-24 02:39:17 $
     7 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-12-27 20:14:29 $
    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 
     23XXX: Use static vectors.
    2224 *****************************************************************************/
    2325psStatsOptions p_psDetermineNumBits(psStatsOptions data)
     
    3638}
    3739
    38 // XXX: Whats this?
    39 #define MAX_INT 10000
    4040psImage *pmReadoutCombine(psImage *output,
    4141                          const psList *inputs,
     
    4444                          const psVector *scale,
    4545                          bool applyZeroScale,
    46                           float gain,
    47                           float readnoise)
     46                          psF32 gain,
     47                          psF32 readnoise)
    4848{
    4949    PS_PTR_CHECK_NULL(inputs, NULL);
     
    6363
    6464    psStats *stats = params->stats;
    65     int i;
    66     int j;
    67     int maxInputCols = 0;
    68     int maxInputRows = 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;
    7171    psListElem *tmpInput = NULL;
    7272    psReadout *tmpReadout = NULL;
    73     int numInputs = 0;
    74     int tmpI;
     73    psS32 numInputs = 0;
     74    psS32 tmpI;
    7575    psElemType outputType = PS_TYPE_F32;
    7676
     
    153153        output = psImageAlloc(maxInputCols-minInputCols,
    154154                              maxInputRows-minInputRows, outputType);
    155         *(int *) &(output->col0) = minInputCols;
    156         *(int *) &(output->row0) = minInputRows;
     155        *(psS32 *) &(output->col0) = minInputCols;
     156        *(psS32 *) &(output->row0) = minInputRows;
    157157    } else {
    158158        if (((output->col0 + output->numCols) < maxInputCols) ||
     
    210210    for (i = output->row0; i < (output->row0 + output->numRows) ; i++) {
    211211        for (j = output->col0; j < (output->col0 + output->numCols) ; j++) {
    212             for (int r = 0; r < numInputs ; r++) {
     212            for (psS32 r = 0; r < numInputs ; r++) {
    213213                //  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]);
    214214                if ((outRowLower->data.U32[r] <= i) &&
     
    217217                        (outColUpper->data.U32[r] > j)) {
    218218
    219                     int imageRow = i - (tmpReadouts[r]->row0 +
    220                                         tmpReadouts[r]->image->row0);
    221                     int imageCol = 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);
    223223
    224224                    if ((NULL == tmpReadouts[r]->mask) ||
     
    240240
    241241            // Determine how many pixels lie between fracLow and fracHigh.
    242             int pixelCount = 0;
    243             for (int r = 0; r < numInputs ; r++) {
     242            psS32 pixelCount = 0;
     243            for (psS32 r = 0; r < numInputs ; r++) {
    244244                if (tmpPixelMask->data.U8[r] == 0) {
    245245                    if ((params->fracLow <= tmpPixels->data.F32[r]) &&
     
    254254            // that range.
    255255            if (pixelCount >= params->nKeep) {
    256                 for (int r = 0; r < numInputs ; r++) {
     256                for (psS32 r = 0; r < numInputs ; r++) {
    257257                    if (tmpPixelMask->data.U8[r] == 0) {
    258258                        if ((params->fracLow <= tmpPixels->data.F32[r]) &&
     
    266266            }
    267267
    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                    }
    295321                }
    296322            }
     
    309335                return(NULL);
    310336            } 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;
    312338            }
    313339        }
  • trunk/psModules/test/tst_pmReadoutCombine.c

    r2816 r2829  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-12-24 00:58:08 $
     7 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-12-27 20:14:29 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    118118           minOutRow, minOutCol, maxOutRow, maxOutCol);
    119119
    120     output = pmReadoutCombine(output, list, params, zero, scale, true, 1.0, 0.0);
     120    output = pmReadoutCombine(output, list, params, zero, scale, true, 0.0, 0.0);
    121121    psF32 NR = (psF32) NUM_READOUTS;
    122     psF32 expectedPixel = ((((NR-1.0) * (NR/2.0)) / NR) + VEC_ZERO) * VEC_SCALE;
     122    //    psF32 expectedPixel = ((((NR-1.0) * (NR/2.0)) / NR) + VEC_ZERO) * VEC_SCALE;
     123    psF32 expectedPixel = ((NR/2.0) * (VEC_ZERO + (VEC_ZERO + VEC_SCALE * (NR - 1)))) / NR;
     124
    123125    VerifyTheOutput(output, expectedPixel);
    124126
     
    179181        zero->data.F32[i] = 3.0;
    180182        zeroBig->data.F32[i] = 3.0;
     183        zero->data.F32[i] = VEC_ZERO;
     184        zeroBig->data.F32[i] = VEC_ZERO;
    181185    }
    182186    for (i=0;i<NUM_READOUTS;i++) {
    183187        scale->data.F32[i] = 6.0;
    184188        scaleBig->data.F32[i] = 6.0;
     189        scale->data.F32[i] = VEC_SCALE;
     190        scaleBig->data.F32[i] = VEC_SCALE;
    185191    }
    186192
     
    220226    printf("----------------------------------------------------------------------------\n");
    221227    printf("Calling pmReadoutCombine() with NULL zero vector.\n");
    222     rc = pmReadoutCombine(NULL, list, params, NULL, scale, true, 1.0, 0.0);
    223     if (rc == NULL) {
    224         //XXX: We should verify the output image here.
     228    rc = pmReadoutCombine(NULL, list, params, NULL, scale, true, 0.0, 0.0);
     229    if (rc != NULL) {
     230        psF32 NR = (psF32) NUM_READOUTS;
     231        psF32 expectedPixel = ((NR/2.0) * (0.0 + (0.0 + VEC_SCALE * (NR - 1)))) / NR;
     232        if (false == VerifyTheOutput(rc, expectedPixel)) {
     233            testStatus = false;
     234        }
     235
     236        if (rc->type.type != scale->type.type) {
     237            printf("ERROR: output readout->image has incorrect type.\n");
     238            testStatus = false;
     239        }
     240        psFree(rc);
     241    } else {
    225242        printf("ERROR: pmReadoutCombine() returned NULL\n");
    226243        testStatus = false;
    227     }
    228     if (rc->type.type != scale->type.type) {
    229         printf("ERROR: output readout->image has incorrect type.\n");
    230         testStatus = false;
    231     }
    232     psFree(rc);
     244
     245    }
    233246
    234247    printf("----------------------------------------------------------------------------\n");
    235248    printf("Calling pmReadoutCombine() with incorrect length zero vector (too small).  Should generate error.\n");
    236     rc = pmReadoutCombine(NULL, list, params, zeroHalf, scale, true, 1.0, 0.0);
     249    rc = pmReadoutCombine(NULL, list, params, zeroHalf, scale, true, 0.0, 0.0);
    237250    if (rc != NULL) {
    238251        printf("ERROR: pmReadoutCombine() did not return NULL\n");
     
    242255    printf("----------------------------------------------------------------------------\n");
    243256    printf("Calling pmReadoutCombine() with incorrect type zero vector.  Should generate error.\n");
    244     rc = pmReadoutCombine(NULL, list, params, zeroF64, scale, true, 1.0, 0.0);
     257    rc = pmReadoutCombine(NULL, list, params, zeroF64, scale, true, 0.0, 0.0);
    245258    if (rc != NULL) {
    246259        printf("ERROR: pmReadoutCombine() did not return NULL\n");
     
    250263    printf("----------------------------------------------------------------------------\n");
    251264    printf("Calling pmReadoutCombine() with incorrect length zero vector (too big).  Should generate warning.\n");
    252     rc = pmReadoutCombine(output, list, params, zeroBig, scale, true, 1.0, 0.0);
    253     if (rc != NULL) {
    254         if (false == VerifyTheOutput(rc, 45.0)) {
     265    rc = pmReadoutCombine(output, list, params, zeroBig, scale, true, 0.0, 0.0);
     266    if (rc != NULL) {
     267        psF32 NR = (psF32) NUM_READOUTS;
     268        psF32 expectedPixel = ((NR/2.0) * (VEC_ZERO + (VEC_ZERO + VEC_SCALE * (NR - 1)))) / NR;
     269
     270        if (false == VerifyTheOutput(rc, expectedPixel)) {
    255271            testStatus = false;
    256272        }
     
    264280    printf("----------------------------------------------------------------------------\n");
    265281    printf("Calling pmReadoutCombine() with NULL scale vector.\n");
    266     rc = pmReadoutCombine(output, list, params, zero, NULL, true, 1.0, 0.0);
    267     if (rc == NULL) {
    268         //XXX: We should verify the output image here.
     282    rc = pmReadoutCombine(output, list, params, zero, NULL, true, 0.0, 0.0);
     283
     284    if (rc != NULL) {
     285        psF32 NR = (psF32) NUM_READOUTS;
     286        psF32 expectedPixel = ((NR/2.0) * (VEC_ZERO + (VEC_ZERO + 1.0 * (NR - 1)))) / NR;
     287        if (false == VerifyTheOutput(rc, expectedPixel)) {
     288            testStatus = false;
     289        }
     290
     291        if (rc->type.type != scale->type.type) {
     292            printf("ERROR: output readout->image has incorrect type.\n");
     293            testStatus = false;
     294        }
     295        psFree(rc);
     296    } else {
    269297        printf("ERROR: pmReadoutCombine() returned NULL\n");
    270298        testStatus = false;
    271     }
    272     psFree(rc);
     299
     300    }
    273301
    274302    printf("----------------------------------------------------------------------------\n");
    275303    printf("Calling pmReadoutCombine() with incorrect length scale vector (too small).  Should generate error.\n");
    276     rc = pmReadoutCombine(output, list, params, zero, scaleHalf, true, 1.0, 0.0);
     304    rc = pmReadoutCombine(output, list, params, zero, scaleHalf, true, 0.0, 0.0);
    277305    if (rc != NULL) {
    278306        printf("ERROR: pmReadoutCombine() did not return NULL\n");
     
    282310    printf("----------------------------------------------------------------------------\n");
    283311    printf("Calling pmReadoutCombine() with incorrect type scale vector.  Should generate error.\n");
    284     rc = pmReadoutCombine(output, list, params, zero, scaleF64, true, 1.0, 0.0);
     312    rc = pmReadoutCombine(output, list, params, zero, scaleF64, true, 0.0, 0.0);
    285313    if (rc != NULL) {
    286314        printf("ERROR: pmReadoutCombine() did not return NULL\n");
     
    290318    printf("----------------------------------------------------------------------------\n");
    291319    printf("Calling pmReadoutCombine() with incorrect length scale vector (too big).  Should generate warning.\n");
    292     rc = pmReadoutCombine(output, list, params, zero, scaleBig, true, 1.0, 0.0);
    293     if (rc != NULL) {
    294         if (false == VerifyTheOutput(rc, 45.0)) {
     320    rc = pmReadoutCombine(output, list, params, zero, scaleBig, true, 0.0, 0.0);
     321    if (rc != NULL) {
     322        psF32 NR = (psF32) NUM_READOUTS;
     323        psF32 expectedPixel = ((NR/2.0) * (VEC_ZERO + (VEC_ZERO + VEC_SCALE * (NR - 1)))) / NR;
     324
     325        if (false == VerifyTheOutput(rc, expectedPixel)) {
    295326            testStatus = false;
    296327        }
     
    305336    printf("Calling pmReadoutCombine() insufficient size output image.  Should generate error, return NULL.\n");
    306337    output = psImageAlloc(1, 1, PS_TYPE_F32);
    307     rc = pmReadoutCombine(output, list, params, zero, scale, true, 1.0, 0.0);
     338    rc = pmReadoutCombine(output, list, params, zero, scale, true, 0.0, 0.0);
    308339    if (rc != NULL) {
    309340        printf("ERROR: pmReadoutCombine() did not return NULL\n");
     
    315346    printf("----------------------------------------------------------------------------\n");
    316347    printf("Calling pmReadoutCombine() with NULL input list.  Should generate error, return NULL.\n");
    317     rc = pmReadoutCombine(output, NULL, params, zero, scale, true, 1.0, 0.0);
     348    rc = pmReadoutCombine(output, NULL, params, zero, scale, true, 0.0, 0.0);
    318349    if (rc != NULL) {
    319350        printf("ERROR: pmReadoutCombine() did not return NULL\n");
     
    323354    printf("----------------------------------------------------------------------------\n");
    324355    printf("Calling pmReadoutCombine() with NULL params.  Should generate error, return NULL.\n");
    325     rc = pmReadoutCombine(output, list, NULL, zero, scale, true, 1.0, 0.0);
     356    rc = pmReadoutCombine(output, list, NULL, zero, scale, true, 0.0, 0.0);
    326357    if (rc != NULL) {
    327358        printf("ERROR: pmReadoutCombine() did not return NULL\n");
     
    332363    psStatsOptions oldStatsOpts = params->stats->options |= PS_STAT_MIN;
    333364    printf("Calling pmReadoutCombine() with multiple stats->options.  Should generate error, return NULL.\n");
    334     rc = pmReadoutCombine(output, list, params, zero, scale, true, 1.0, 0.0);
     365    rc = pmReadoutCombine(output, list, params, zero, scale, true, 0.0, 0.0);
    335366    if (rc != NULL) {
    336367        printf("ERROR: pmReadoutCombine() did not return NULL\n");
     
    342373    psStats *oldStats = params->stats;
    343374    printf("Calling pmReadoutCombine() with NULL param->stats.  Should generate error, return NULL.\n");
    344     rc = pmReadoutCombine(output, list, params, zero, scale, true, 1.0, 0.0);
     375    rc = pmReadoutCombine(output, list, params, zero, scale, true, 0.0, 0.0);
    345376    if (rc != NULL) {
    346377        printf("ERROR: pmReadoutCombine() did not return NULL\n");
Note: See TracChangeset for help on using the changeset viewer.