IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 18, 2006, 12:20:45 PM (20 years ago)
Author:
Paul Price
Message:

Updating to use psLib rel11. Main problem was that vector and array lengths ('n' element) are no longer set to equal the number of allocated values ('nalloc' element) when allocated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/stac/src/stacErrorImages.c

    r3666 r6887  
    44
    55psArray *stacErrorImages(psArray *inputs, // Array of input images
    6                          float gain,    // Gain, in e/ADU
    7                          float rn       // Read noise, in e
     6                         float gain,    // Gain, in e/ADU
     7                         float rn       // Read noise, in e
    88    )
    99{
    10     float invGain = 1.0/gain;           // Inverse square root of gain
    11     rn /= gain;                         // Read noise in ADU
     10    float invGain = 1.0/gain;           // Inverse square root of gain
     11    rn /= gain;                         // Read noise in ADU
    1212    psArray *errors = psArrayAlloc(inputs->n);
     13    errors->n = inputs->n;
    1314
    1415    psTrace("stac.errors", 1, "Calculating error images....\n");
     
    1617    // Iterate over the input images
    1718    for (int i = 0; i < inputs->n; i++) {
    18         psTrace("stac.errors",5,"Working on image #%d\n",i);
     19        psTrace("stac.errors",5,"Working on image #%d\n",i);
    1920
    20         psImage *image = inputs->data[i]; // Pull out the image of interest
    21         int numRows = image->numRows;   // Number of rows
    22         int numCols = image->numCols;   // Number of columns   
    23         psImage *error = psImageAlloc(numCols, numRows, PS_TYPE_F32); // The error image
     21        psImage *image = inputs->data[i]; // Pull out the image of interest
     22        int numRows = image->numRows;   // Number of rows
     23        int numCols = image->numCols;   // Number of columns
     24        psImage *error = psImageAlloc(numCols, numRows, PS_TYPE_F32); // The error image
    2425
    25         // Iterate over the pixels
    26         for (int r = 0; r < numRows; r++) {
    27             for (int c = 0; c < numCols; c++) {
    28                 // We actually calculate the variance
    29                 error->data.F32[r][c] = image->data.F32[r][c]*invGain + rn*rn;
    30             }
    31         }
     26        // Iterate over the pixels
     27        for (int r = 0; r < numRows; r++) {
     28            for (int c = 0; c < numCols; c++) {
     29                // We actually calculate the variance
     30                error->data.F32[r][c] = image->data.F32[r][c]*invGain + rn*rn;
     31            }
     32        }
    3233
    33         // Put image onto the array
    34         errors->data[i] = error;
     34        // Put image onto the array
     35        errors->data[i] = error;
    3536    }
    3637
Note: See TracChangeset for help on using the changeset viewer.