IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 7, 2008, 12:46:39 PM (18 years ago)
Author:
Paul Price
Message:

Making convolution inputs a bit more flexible with mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmSubtraction.c

    r17321 r17370  
    44 *  @author GLG, MHPCC
    55 *
    6  *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2008-04-04 23:03:42 $
     6 *  @version $Revision: 1.85 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2008-04-07 22:46:39 $
    88 *
    99 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    637637                           const pmSubtractionKernels *kernels, bool doBG, bool useFFT)
    638638{
    639     PM_ASSERT_READOUT_NON_NULL(out1, false);
    640     PM_ASSERT_READOUT_NON_NULL(out2, false);
     639    if (kernels->mode != PM_SUBTRACTION_MODE_2) {
     640        PM_ASSERT_READOUT_NON_NULL(out1, false);
     641    }
     642    if (kernels->mode != PM_SUBTRACTION_MODE_1) {
     643        PM_ASSERT_READOUT_NON_NULL(out2, false);
     644    }
    641645    PM_ASSERT_READOUT_NON_NULL(ro1, false);
    642646    PM_ASSERT_READOUT_NON_NULL(ro2, false);
     
    695699    psImage *convMask = NULL;           // Convolved mask image (common to inputs 1 and 2)
    696700    if (subMask) {
    697         if (!out1->mask) {
    698             out1->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
    699         }
    700         convMask = out1->mask;
     701        if (kernels->mode == PM_SUBTRACTION_MODE_1 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
     702            if (!out1->mask) {
     703                out1->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     704            }
     705            convMask = out1->mask;
     706        }
     707        if (kernels->mode == PM_SUBTRACTION_MODE_2 || kernels->mode == PM_SUBTRACTION_MODE_DUAL) {
     708            if (convMask) {
     709                if (out2->mask) {
     710                    psFree(out2->mask);
     711                }
     712                out2->mask = psMemIncrRefCounter(convMask);
     713            } else {
     714                if (!out2->mask) {
     715                    out2->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
     716                }
     717                convMask = out2->mask;
     718            }
     719        }
    701720        psImageInit(convMask, 0);
    702         if (out2->mask) {
    703             psFree(out2->mask);
    704         }
    705         out2->mask = psMemIncrRefCounter(convMask);
    706721    }
    707722
     
    794809    switch (kernels->mode) {
    795810      case PM_SUBTRACTION_MODE_1:
    796         out2->image = psMemIncrRefCounter(ro2->image);
    797         out2->weight = psMemIncrRefCounter(ro2->weight);
    798         out2->mask = psMemIncrRefCounter(ro2->mask);
     811        if (out2) {
     812            out2->image = psMemIncrRefCounter(ro2->image);
     813            out2->weight = psMemIncrRefCounter(ro2->weight);
     814            out2->mask = psMemIncrRefCounter(ro2->mask);
     815        }
    799816        break;
    800817      case PM_SUBTRACTION_MODE_2:
    801         out1->image = psMemIncrRefCounter(ro1->image);
    802         out1->weight = psMemIncrRefCounter(ro1->weight);
    803         out1->mask = psMemIncrRefCounter(ro1->mask);
     818        if (out1) {
     819            out1->image = psMemIncrRefCounter(ro1->image);
     820            out1->weight = psMemIncrRefCounter(ro1->weight);
     821            out1->mask = psMemIncrRefCounter(ro1->mask);
     822        }
    804823        break;
    805824      case PM_SUBTRACTION_MODE_DUAL:
Note: See TracChangeset for help on using the changeset viewer.