IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 8, 2008, 6:10:14 PM (18 years ago)
Author:
Paul Price
Message:

Discovered a problem with threaded implementation of pmDarkApply --- the polynomial is altered within pmDarkApplyScan, so it should not be global across threads. Checked and cleaned up the other threaded detrending functions.

File:
1 edited

Legend:

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

    r19299 r19432  
    2323    PS_ASSERT_THREAD_JOB_NON_NULL(job, false);
    2424    pmReadout *in = job->args->data[0];
    25     pmReadout *sub = job->args->data[1];
     25    const pmReadout *sub = job->args->data[1];
    2626    float scale  = PS_SCALAR_VALUE(job->args->data[2],F32);
    2727    int xOffset  = PS_SCALAR_VALUE(job->args->data[3],S32);
     
    2929    int rowStart = PS_SCALAR_VALUE(job->args->data[5],S32);
    3030    int rowStop  = PS_SCALAR_VALUE(job->args->data[6],S32);
    31     bool status = pmBiasSubtractScan (in, sub, scale, xOffset, yOffset, rowStart, rowStop);
    32     return status;
    33 }
    34 
    35 bool pmBiasSubtractScan (pmReadout *in, pmReadout *sub, float scale, int xOffset, int yOffset, int rowStart, int rowStop) {
    36 
     31    return pmBiasSubtractScan(in, sub, scale, xOffset, yOffset, rowStart, rowStop);
     32}
     33
     34bool pmBiasSubtractScan(pmReadout *in, const pmReadout *sub, float scale,
     35                        int xOffset, int yOffset, int rowStart, int rowStop)
     36{
    3737    psImage *inImage  = in->image;      // The input image
    3838    psImage *inMask   = in->mask;       // The input mask
    39     psImage *subImage = sub->image;    // The image to be subtracted
    40     psImage *subMask  = sub->mask;      // The mask for the subtraction image
     39    const psImage *subImage = sub->image; // The image to be subtracted
     40    const psImage *subMask  = sub->mask; // The mask for the subtraction image
    4141
    4242    if (scale == 1.0) {
     
    6262}
    6363
    64 // pmBiasSubtractFrame(): this routine will take as input a readout for the input image and a readout for the bias
     64// pmBiasSubtractFrame():
     65// this routine will take as input a readout for the input image and a readout for the bias
    6566// image.  The bias image is subtracted in place from the input image.
    6667bool pmBiasSubtractFrame(pmReadout *in, // Input readout
     
    129130
    130131    for (int rowStart = 0; rowStart < inImage->numRows; rowStart += scanRows) {
    131       int rowStop = PS_MIN (rowStart + scanRows, inImage->numRows);
    132 
    133       if (threaded) {
    134           // allocate a job, construct the arguments for this job
    135           psThreadJob *job = psThreadJobAlloc ("PSMODULES_DETREND_BIAS");
    136           psArrayAdd (job->args, 1, in);
    137           psArrayAdd (job->args, 1, sub);
    138           PS_ARRAY_ADD_SCALAR (job->args, scale, PS_TYPE_F32);
    139           PS_ARRAY_ADD_SCALAR (job->args, xOffset, PS_TYPE_S32);
    140           PS_ARRAY_ADD_SCALAR (job->args, yOffset, PS_TYPE_S32);
    141           PS_ARRAY_ADD_SCALAR (job->args, rowStart, PS_TYPE_S32);
    142           PS_ARRAY_ADD_SCALAR (job->args, rowStop, PS_TYPE_S32);
    143 
    144           // ppImageDetrendReadout(config, options, view)
    145           if (!psThreadJobAddPending (job)) {
    146               psFree(job);
    147               return false;
    148           }
    149           psFree(job);
    150       } else {
    151           pmBiasSubtractScan (in, sub, scale, xOffset, yOffset, rowStart, rowStop);
    152       }
     132        int rowStop = PS_MIN(rowStart + scanRows, inImage->numRows);
     133
     134        if (threaded) {
     135            // allocate a job, construct the arguments for this job
     136            psThreadJob *job = psThreadJobAlloc("PSMODULES_DETREND_BIAS");
     137            psArrayAdd(job->args, 1, in);
     138            psArrayAdd(job->args, 1, sub);
     139            PS_ARRAY_ADD_SCALAR(job->args, scale, PS_TYPE_F32);
     140            PS_ARRAY_ADD_SCALAR(job->args, xOffset, PS_TYPE_S32);
     141            PS_ARRAY_ADD_SCALAR(job->args, yOffset, PS_TYPE_S32);
     142            PS_ARRAY_ADD_SCALAR(job->args, rowStart, PS_TYPE_S32);
     143            PS_ARRAY_ADD_SCALAR(job->args, rowStop, PS_TYPE_S32);
     144
     145            if (!psThreadJobAddPending(job)) {
     146                psFree(job);
     147                return false;
     148            }
     149            psFree(job);
     150        } else if (!pmBiasSubtractScan(in, sub, scale, xOffset, yOffset, rowStart, rowStop)) {
     151            psError(PS_ERR_UNKNOWN, false, "Unable to apply bias correction.");
     152            return false;
     153        }
    153154    }
    154155
    155156    if (threaded) {
    156157        // wait here for the threaded jobs to finish
    157         if (!psThreadPoolWait(false)) {
    158             psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
    159             return false;
    160         }
    161         fprintf (stderr, "success for threaded jobs\n");
    162 
    163         // each job records its own goodPixel values; sum them here
    164         // we have only supplied one type of job, so we can assume the types here
    165         psThreadJob *job = NULL;
    166         while ((job = psThreadJobGetDone()) != NULL) {
    167             psFree (job);
     158        if (!psThreadPoolWait(true)) {
     159            psError(PS_ERR_UNKNOWN, false, "Unable to apply bias correction.");
     160            return false;
    168161        }
    169162    }
Note: See TracChangeset for help on using the changeset viewer.