IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 6, 2007, 3:57:15 PM (18 years ago)
Author:
Paul Price
Message:

Implementing dual-convolution. This required reworking those
functions involved with calculating and solving the equations; moved
these into a separate file and made various other cleanups (e.g.,
assertions for pmSubtractionKernels). Removed the normalisation
(central pixel) term from all kernels, because this shouldn't be in
the second kernel (there's only one normalisation term between the two
kernels); the normalisation is treated explicitly in the equations,
along with the background (still only a constant background is
supported for now, but there's a lot of support for a polynomial
background for when I get around to putting it in the equations).
Tested the single convolution, and it's working; same results as
before, apparently. Haven't tested dual convolution yet.

File:
1 edited

Legend:

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

    r15562 r15756  
    66 * @author GLG, MHPCC
    77 *
    8  * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    9  * @date $Date: 2007-11-10 01:09:20 $
     8 * @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     9 * @date $Date: 2007-12-07 01:57:15 $
    1010 * Copyright 2004-207 Institute for Astronomy, University of Hawaii
    1111 */
     
    3737} pmSubtractionMasks;
    3838
    39 /// Generate a mask for use in the subtraction process
    40 psImage *pmSubtractionMask(const psImage *refMask, ///< Mask for the reference image (will be convolved)
    41                            const psImage *inMask, ///< Mask for the input image, or NULL
    42                            psMaskType maskVal, ///< Value to mask out
    43                            int size, ///< Half-size of the kernel (pmSubtractionKernels.size)
    44                            int footprint, ///< Half-size of the kernel footprint
    45                            float badFrac, ///< Maximum fraction of bad input pixels to accept
    46                            bool useFFT  ///< Use FFT to do convolution?
    47     );
     39
     40/// Number of terms in a polynomial
     41#define PM_SUBTRACTION_POLYTERMS(ORDER) (((ORDER) + 1) * ((ORDER) + 2) / 2)
     42
     43/// Set the indices for the normalisation and background terms
     44#define PM_SUBTRACTION_INDICES(NORM,BG,KERNELS) { \
     45    int numSpatial = PM_SUBTRACTION_POLYTERMS((KERNELS)->spatialOrder); /* Number of spatial terms */ \
     46    NORM = (KERNELS)->num * numSpatial; \
     47    BG = NORM + 1; \
     48}
     49
     50/// Return the index for the start of the normalisation terms
     51#define PM_SUBTRACTION_INDEX_NORM(KERNELS) \
     52    ((KERNELS)->num * PM_SUBTRACTION_POLYTERMS((KERNELS)->spatialOrder))
     53
     54/// Return the index for the start of the background terms
     55#define PM_SUBTRACTION_INDEX_BG(KERNELS) \
     56    (((KERNELS)->num * PM_SUBTRACTION_POLYTERMS((KERNELS)->spatialOrder)) + 1)
     57
    4858
    4959/// Convolve the reference stamp with the kernel components
    5060bool pmSubtractionConvolveStamp(pmSubtractionStamp *stamp, ///< Stamp to convolve
    5161                                const pmSubtractionKernels *kernels, ///< Kernel parameters
    52                                 int footprint, ///< Half-size of region over which to calculate equation
    53                                 pmSubtractionMode mode ///< Mode for subtraction (which to convolve)
    54     );
    55 
    56 /// Calculate the least-squares equation to match the image quality
    57 bool pmSubtractionCalculateEquation(pmSubtractionStampList *stamps, ///< Stamps
    58                                     const pmSubtractionKernels *kernels, ///< Kernel parameters
    59                                     int footprint, ///< Half-size of region over which to calculate equation
    60                                     pmSubtractionMode mode ///< Mode for subtraction (which to convolve)
    61                                     );
    62 
    63 /// Solve the least-squares equation to match the image quality
    64 psVector *pmSubtractionSolveEquation(psVector *solution, ///< Solution vector, or NULL
    65                                      const pmSubtractionStampList *stamps ///< Stamps
    66                                      );
    67 
    68 /// Calculate deviations
    69 psVector *pmSubtractionCalculateDeviations(pmSubtractionStampList *stamps, ///< Stamps
    70                                            const psVector *solution, ///< Solution vector
    71                                            int footprint, ///< Half-size of stamp
    72                                            const pmSubtractionKernels *kernels, ///< Kernel parameters
    73                                            pmSubtractionMode mode ///< Mode for subtraction
     62                                int footprint ///< Half-size of region over which to calculate equation
    7463    );
    7564
     
    8372
    8473/// Generate an image of the convolution kernel
    85 psImage *pmSubtractionKernelImage(const psVector *solution, ///< Solution vector
    86                                   const pmSubtractionKernels *kernels, ///< Kernel parameters
    87                                   float x, float y ///< Normalised position [-1,1] for which to generate image
     74psImage *pmSubtractionKernelImage(const pmSubtractionKernels *kernels, ///< Kernel parameters
     75                                  float x, float y,///< Normalised position [-1,1] for which to generate image
     76                                  bool wantDual ///< Calculate for the dual kernel?
    8877                                  );
    8978
     
    9584
    9685/// Convolve image in preparation for subtraction
    97 bool pmSubtractionConvolve(pmReadout *out, ///< Output image
     86bool pmSubtractionConvolve(pmReadout *out1, ///< Output image 1
     87                           pmReadout *out2, ///< Output image 2 (DUAL mode only)
    9888                           const pmReadout *ro1, // Input image 1
    9989                           const pmReadout *ro2, // Input image 2
     
    10191                           psMaskType blank, ///< Mask value for blank regions
    10292                           const psRegion *region, ///< Region to convolve (or NULL)
    103                            const psVector *solution, ///< The solution vector
    10493                           const pmSubtractionKernels *kernels, ///< Kernel parameters
    105                            pmSubtractionMode mode, ///< Mode for subtraction
    10694                           bool useFFT  ///< Use Fast Fourier Transform for the convolution?
    107     );
    108 
    109 /// Mark the non-convolved part of the image as blank
    110 bool pmSubtractionBorder(psImage *image,///< Image
    111                          psImage *weight, ///< Weight map (or NULL)
    112                          psImage *mask, ///< Mask (or NULL)
    113                          int size,      ///< Kernel half-size
    114                          psMaskType blank ///< Mask value for blank regions
    11595    );
    11696
     
    122102    );
    123103
     104/// Given (normalised) coordinates (x,y), generate a matrix where the elements (i,j) are x^i * y^j
     105psImage *p_pmSubtractionPolynomial(psImage *output, ///< Output matrix, or NULL
     106                                   int spatialOrder, ///< Maximum spatial polynomial order
     107                                   float x, float y ///< Normalised position of interest, [-1,1]
     108    );
     109
    124110/// @}
    125111#endif
Note: See TracChangeset for help on using the changeset viewer.