IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 30, 2005, 7:05:28 AM (21 years ago)
Author:
eugene
Message:

cleanups, segfault fixes, etc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppImage/src/ppImageDetrendPedestal.c

    r5857 r5858  
    11# include "ppImage.h"
    22
    3 psImage *ppDetrendPedestal (pmCell *input, psImage *bias, psImage *dark, ppRecipe *options) {
     3// XXX check on image overlaps, as well as image sizes
     4// XXX what constraints do we put on the detrend images?
     5// XXX this function is much easier if we can assume all detrend images
     6//     should have the same size and represent the same pixels...
    47
    5     psImage *pedestal = NULL;       // Pedestal image (bias + scaled dark)
     8pmReadout *ppDetrendPedestal (pmReadout *pedestal, pmCell *input, pmReadout *bias, pmReadout *dark, float darkTime, ppOptions *options) {
    69
    710#ifdef PRODUCTION
     11    static float lastExptime = 0.0;
     12    bool reusePedestal = true;
     13
    814    if (options->doDark) {
    915        // Dark time for input image
     
    1420            exit(EXIT_FAILURE);
    1521        }
    16         pedestal = (psImage*)psBinaryOp(NULL, dark, "*", psScalarAlloc(inputTime * darkTime, PS_TYPE_F32));
     22
     23        if (inputTime != lastExptime) {
     24            // this will create a new pedestal if the input one is NULL
     25            // XXX EAM : this function had darkTime * inputTime, which is wrong, yes?
     26            if (pedestal == NULL) {
     27                pedestal = pmReadoutAlloc (NULL);
     28            }
     29            pedestal->col0    = dark->col0;
     30            pedestal->row0    = dark->row0;
     31            pedestal->colBins = dark->colBins;
     32            pedestal->rowBins = dark->rowBins;
     33
     34            pedestal->image   = (psImage *) psBinaryOp(pedestal->image, dark->image, "*", psScalarAlloc(inputTime / darkTime, PS_TYPE_F32));
     35            reusePedestal = false;
     36            lastExptime = inputTime
     37        }
    1738    }
    18     if (options->doBias) {
    19         if (pedestal) {
    20             if (bias->numRows != dark->numRows ||
    21                 bias->numCols != dark->numCols) {
    22                 psError(PS_ERR_IO, true, "Bias and dark images have different dimensions: "
    23                         "%dx%d vs %dx%d\n", bias->numCols, bias->numRows,
    24                         dark->numCols, dark->numRows);
    25                 exit(EXIT_FAILURE);
    26             }
    27             (void)psBinaryOp(pedestal, pedestal, "+", bias);
    28         } else {
     39
     40    // no bias image, return dark pedestal or NULL
     41    if (!options->doBias) {
     42        return pedestal;
     43    }
     44
     45    // no dark image, return bias pedestal, or reuse
     46    if (!options->doDark) {
     47        if (!pedestal) {
    2948            pedestal = psMemIncrRefCounter(bias);
    3049        }
     50        return pedestal;
    3151    }
     52
     53    if (reusePedestal) {
     54        return pedestal;
     55    }
     56
     57    if (bias->image->numRows != dark->image->numRows ||
     58        bias->image->numCols != dark->image->numCols) {
     59        psError(PS_ERR_IO, true, "Bias and dark images have different dimensions: %dx%d vs %dx%d\n",
     60                bias->image->numCols, bias->image->numRows,
     61                dark->image->numCols, dark->image->numRows);
     62        exit(EXIT_FAILURE);
     63    }
     64
     65    psBinaryOp(pedestal->image, pedestal->image, "+", bias->image);
     66    return pedestal;
     67#else
     68    return NULL;
    3269#endif
    33 
    34     return pedestal;
    3570}
    3671
     72// creates a new pedestal image for this readout
     73// if the current exptime is the same as the last exptime,
     74// reuses the supplied pedestal
Note: See TracChangeset for help on using the changeset viewer.