IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 5, 2006, 5:33:49 PM (20 years ago)
Author:
Paul Price
Message:

Enabling iteration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmShutterCorrection.c

    r9336 r9340  
    362362psImage *pmShutterCorrectionMeasure(const psVector *exptimes, // Exposure times
    363363                                    const psArray *images, // Input images
     364                                    const psArray *weights, // Weight images
    364365                                    const psArray *masks, // Mask images
    365366                                    unsigned int size, // Size of samples
     
    377378        PS_ASSERT_ARRAYS_SIZE_EQUAL(images, masks, NULL);
    378379    }
     380    if (weights) {
     381        PS_ASSERT_ARRAYS_SIZE_EQUAL(images, weights, NULL);
     382    }
    379383    long num = images->n;               // Number of images
    380384    PS_ASSERT_VECTOR_SIZE(exptimes, num, NULL);
     385    PS_ASSERT_INT_POSITIVE(nIter, 0, NULL);
     386    PS_ASSERT_FLOAT_LARGER_THAN(rej, 0.0, NULL);
    381387
    382388    // Check input sizes, generate first-pass statistics
     
    493499    psTrace("psModules.detrend", 3, "Mean reference value: %f\n", meanRef);
    494500
     501    // Check the weights
     502    if (weights && nIter > 1) {
     503        for (int i = 0; i < weights->n && nIter > 1; i++) {
     504            psImage *weight = weights->data[i]; // Weight image
     505            if (!weight) {
     506                // We don't have weights, so no realistic errors: turn off iteration
     507                if (nIter > 0) {
     508                    psWarning("Not all images have weights --- turning weighting off.\n");
     509                }
     510                nIter = 1;
     511            }
     512        }
     513    }
     514
    495515    psImage *shutter = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Shutter correction image
    496516    //psImage *pattern = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Illumination pattern
     
    503523            for (int i = 0; i < num; i++) {
    504524                psImage *image = images->data[i]; // Image of interest
     525                counts->data.F32[i] = image->data.F32[y][x] * refs->data.F32[i];
    505526                psImage *maskImage;     // Mask image
    506527                if (masks && (maskImage = masks->data[i])) {
    507528                    mask->data.U8[i] = maskImage->data.U8[y][x];
    508529                }
    509                 counts->data.F32[i] = image->data.F32[y][x] * refs->data.F32[i];
    510                 errors->data.F32[i] = sqrtf(image->data.F32[y][x]) * refs->data.F32[i];
     530                psImage *weight;        // Weight image
     531                if (weights && (weight = weights->data[i])) {
     532                    errors->data.F32[i] = sqrtf(weight->data.F32[y][x]) * refs->data.F32[i];
     533                } else {
     534                    errors->data.F32[i] = sqrtf(image->data.F32[y][x]) * refs->data.F32[i];
     535                }
    511536            }
    512537
Note: See TracChangeset for help on using the changeset viewer.