IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21457


Ignore:
Timestamp:
Feb 12, 2009, 9:33:30 AM (17 years ago)
Author:
Paul Price
Message:

Adding modification of variance map by the shutter correction.

Location:
trunk/psModules/src/detrend
Files:
3 edited

Legend:

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

    r21456 r21457  
    4747
    4848    {
    49         psThreadTask *task = psThreadTaskAlloc("PSMODULES_DETREND_SHUTTER", 7);
     49        psThreadTask *task = psThreadTaskAlloc("PSMODULES_DETREND_SHUTTER", 8);
    5050        task->function = &pmShutterCorrectionApplyScan_Threaded;
    5151        psThreadTaskAdd(task);
  • trunk/psModules/src/detrend/pmShutterCorrection.c

    r21363 r21457  
    659659    PS_ASSERT_THREAD_JOB_NON_NULL(job, false);
    660660
    661     psImage *image        = job->args->data[0];
    662     const psImage *shutterImage = job->args->data[1];
    663     psImage *mask         = job->args->data[2];
    664 
    665     float exptime    = PS_SCALAR_VALUE(job->args->data[3],F32);
    666     psImageMaskType blank = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA);
    667     int rowStart     = PS_SCALAR_VALUE(job->args->data[5],S32);
    668     int rowStop      = PS_SCALAR_VALUE(job->args->data[6],S32);
    669     return pmShutterCorrectionApplyScan (image, shutterImage, mask, exptime, blank, rowStart, rowStop);
    670 }
    671 
    672 bool pmShutterCorrectionApplyScan(psImage *image, const psImage *shutterImage, psImage *mask, float exptime,
     661    psImage *image = job->args->data[0];
     662    psImage *mask  = job->args->data[1];
     663    psImage *var   = job->args->data[2];
     664    const psImage *shutterImage = job->args->data[3];
     665
     666    float exptime    = PS_SCALAR_VALUE(job->args->data[4], F32);
     667    psImageMaskType blank = PS_SCALAR_VALUE(job->args->data[5], PS_TYPE_IMAGE_MASK_DATA);
     668    int rowStart     = PS_SCALAR_VALUE(job->args->data[6], S32);
     669    int rowStop      = PS_SCALAR_VALUE(job->args->data[7], S32);
     670    return pmShutterCorrectionApplyScan(image, mask, var, shutterImage, exptime, blank, rowStart, rowStop);
     671}
     672
     673bool pmShutterCorrectionApplyScan(psImage *image, psImage *mask, psImage *var,
     674                                  const psImage *shutterImage, float exptime,
    673675                                  psImageMaskType blank, int rowStart, int rowStop)
    674676{
     677    // Neglecting asserts because inputs should have been checked already
     678
     679    int numCols = image->numCols;       // Number of columns
     680
    675681    for (int y = rowStart; y < rowStop; y++) {
    676         for (int x = 0; x < image->numCols; x++) {
     682        for (int x = 0; x < numCols; x++) {
    677683            if (mask && !isfinite(shutterImage->data.F32[y][x])) {
    678684                mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= blank;
    679685                image->data.F32[y][x] = NAN;
     686                if (var) {
     687                    var->data.F32[y][x] = NAN;
     688                }
    680689                continue;
    681690            }
    682             image->data.F32[y][x] *= exptime / (exptime + shutterImage->data.F32[y][x]);
     691            float correction = exptime / (exptime + shutterImage->data.F32[y][x]); // Correction factor
     692            image->data.F32[y][x] *= correction;
     693            if (var) {
     694                var->data.F32[y][x] *= PS_SQR(correction);
     695            }
    683696        }
    684697    }
     
    688701bool pmShutterCorrectionApply(pmReadout *readout, const pmReadout *shutter, psImageMaskType blank)
    689702{
    690     PS_ASSERT_PTR_NON_NULL(readout, false);
    691     PS_ASSERT_PTR_NON_NULL(shutter, false);
    692     PS_ASSERT_IMAGE_NON_NULL(readout->image, false);
    693     PS_ASSERT_IMAGE_NON_NULL(shutter->image, false);
    694     PS_ASSERT_IMAGE_TYPE(readout->image, PS_TYPE_F32, false);
    695     PS_ASSERT_IMAGE_TYPE(shutter->image, PS_TYPE_F32, false);
     703    PM_ASSERT_READOUT_NON_NULL(readout, false);
     704    PM_ASSERT_READOUT_NON_NULL(shutter, false);
     705    PM_ASSERT_READOUT_IMAGE(readout, false);
     706    PM_ASSERT_READOUT_IMAGE(shutter, false);
    696707
    697708    psRegion region = psRegionSet(readout->col0, readout->col0 + readout->image->numCols,
     
    731742    psImage *image = readout->image;    // Image to correct
    732743    psImage *mask = readout->mask;      // Corresponding mask
     744    psImage *var = readout->variance;   // Corresponding variance map
    733745
    734746    bool threaded = true;
     
    766778                psThreadJob *job = psThreadJobAlloc("PSMODULES_DETREND_SHUTTER");
    767779                psArrayAdd(job->args, 1, image);
     780                psArrayAdd(job->args, 1, mask);
     781                psArrayAdd(job->args, 1, var);
    768782                psArrayAdd(job->args, 1, shutterImage);
    769                 psArrayAdd(job->args, 1, mask);
    770783                PS_ARRAY_ADD_SCALAR(job->args, exptime, PS_TYPE_F32);
    771784                PS_ARRAY_ADD_SCALAR(job->args, blank, PS_TYPE_IMAGE_MASK);
     
    778791                }
    779792                psFree(job);
    780             } else if (!pmShutterCorrectionApplyScan(image, shutterImage, mask, exptime, blank,
     793            } else if (!pmShutterCorrectionApplyScan(image, mask, var, shutterImage, exptime, blank,
    781794                                                     rowStart, rowStop)) {
    782795                psError(PS_ERR_UNKNOWN, false, "Unable to apply shutter correction.");
  • trunk/psModules/src/detrend/pmShutterCorrection.h

    r21183 r21457  
    55 * @author Paul Price, IfA
    66 *
    7  * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    8  * @date $Date: 2009-01-27 06:39:38 $
     7 * @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2009-02-12 19:33:30 $
    99 * Copyright 2006 Institute for Astronomy, University of Hawaii
    1010 */
     
    9191    float offref,                       ///< Reference time offset
    9292    int nIter,                          ///< Number of iterations
    93     float rej                           ///< Rejection threshold (sigma)
     93    float rej                           ///< Rejection threshold (sigma)
    9494    );
    9595
     
    131131bool pmShutterCorrectionApplyScan(
    132132    psImage *image,                     ///< Input image to correct
     133    psImage *mask,                      ///< Input mask image
     134    psImage *var,                       ///< Input variance image
    133135    const psImage *shutterImage,        ///< Shutter correction image
    134     psImage *mask,                      ///< Input mask image
    135136    float exptime,                      ///< Exposure time to which to correct
    136137    psImageMaskType blank,                   ///< Mask value to give blank pixels
Note: See TracChangeset for help on using the changeset viewer.