IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 21, 2008, 4:10:37 PM (18 years ago)
Author:
Paul Price
Message:

Reworking psImageInterpolate so that kernels are pre-calculated. Renamed a few things in the process: psImageInterpolateOptions --> psImageInterpolation (shorter), PS_INTERPOLATE_BICUBE --> PS_INTERPOLATE_BIQUADRATIC (accurate). I've moved all the interpolation kernels into 1D so that I can pre-calculate them with a reasonable amount of memory. This might be a mistake for the BIQUADRATIC kernel (doesn't have an obvious 1D kernel function), so I might revert just that one soon. Haven't checked if the speed is faster yet, but I checked something in that broke the build, so I need to check this in. Tests pass.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageInterpolate.h

    r19140 r20306  
    77 * @author Paul Price, Institute for Astronomy
    88 *
    9  * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    10  * @date $Date: 2008-08-21 01:12:44 $
     9 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     10 * @date $Date: 2008-10-22 02:10:37 $
    1111 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii
    1212 */
     
    1818/// Enumeration of options in interpolation
    1919typedef enum {
    20     PS_INTERPOLATE_NONE,               ///< no interpolate defined (error state)
    21     PS_INTERPOLATE_FLAT,               ///< Flat interpolation (nearest pixel)
    22     PS_INTERPOLATE_BILINEAR,           ///< Bilinear interpolation
    23     PS_INTERPOLATE_BICUBE,             ///< Bicubic interpolation with 3x3 region
    24     PS_INTERPOLATE_GAUSS,              ///< Gaussian inteprolation with 3x3 region
    25     PS_INTERPOLATE_LANCZOS2,           ///< Sinc interpolation with 4x4 pixel kernel
    26     PS_INTERPOLATE_LANCZOS3,           ///< Sinc interpolation with 6x6 pixel kernel
    27     PS_INTERPOLATE_LANCZOS4,           ///< Sinc interpolation with 8x8 pixel kernel
     20    PS_INTERPOLATE_NONE = 0,            ///< No interpolate defined (error state)
     21    PS_INTERPOLATE_FLAT,                ///< Flat interpolation (nearest pixel)
     22    PS_INTERPOLATE_BILINEAR,            ///< Bilinear interpolation
     23    PS_INTERPOLATE_BIQUADRATIC,         ///< Biquadratic interpolation with 3x3 region
     24    PS_INTERPOLATE_GAUSS,               ///< Gaussian inteprolation with 3x3 region
     25    PS_INTERPOLATE_LANCZOS2,            ///< Sinc interpolation with 4x4 pixel kernel
     26    PS_INTERPOLATE_LANCZOS3,            ///< Sinc interpolation with 6x6 pixel kernel
     27    PS_INTERPOLATE_LANCZOS4,            ///< Sinc interpolation with 8x8 pixel kernel
    2828} psImageInterpolateMode;
    2929
     
    5454    float poorFrac;                     ///< Fraction of flux in bad pixels before output is marked bad
    5555    bool shifting;                      ///< Shifting images? Don't interpolate if the shift is exact.
    56 } psImageInterpolateOptions;
     56    int numKernels;                     ///< Number of pre-calculated kernels
     57    const psImage *kernel, *kernel2;    ///< 1D interpolation kernel and kernel^2 (row) for each spacing
     58    const psVector *sumKernel2;         ///< Sum of kernel^2 for each spacing
     59} psImageInterpolation;
    5760
    5861
    5962/// Allocator
    60 psImageInterpolateOptions *psImageInterpolateOptionsAlloc(psImageInterpolateMode mode, // Interpolation mode
    61                                                           const psImage *image, // Input image
    62                                                           const psImage *variance,  // Variance image
    63                                                           const psImage *mask, // Mask image
    64                                                           psMaskType maskVal, // Value to mask
    65                                                           double badImage, // Value for image if bad
    66                                                           double badVariance, // Value for variance if bad
    67                                                           psMaskType badMask, // Mask value for bad pixels
    68                                                           psMaskType poorMask, // Mask value for poor pixels
    69                                                           float poorFrac // Fraction of flux for question
     63psImageInterpolation *psImageInterpolationAlloc(
     64    psImageInterpolateMode mode,        // Interpolation mode
     65    const psImage *image,               // Input image
     66    const psImage *variance,            // Variance image
     67    const psImage *mask,                // Mask image
     68    psMaskType maskVal,                 // Value to mask
     69    double badImage,                    // Value for image if bad
     70    double badVariance,                 // Value for variance if bad
     71    psMaskType badMask,                 // Mask value for bad pixels
     72    psMaskType poorMask,                // Mask value for poor pixels
     73    float poorFrac,                     // Fraction of flux for question
     74    int numKernels                      // Number of interpolation kernels to pre-calculate
    7075    ) PS_ATTR_MALLOC;
    7176
    7277
    73 
    7478/// Interpolate image pixel value given floating point coordinates.
    75 psImageInterpolateStatus psImageInterpolate(double *imageValue, ///< Return value for image
    76                                             double *varianceValue, ///< Return value for variance
    77                                             psMaskType *maskValue, ///< Return value for mask
    78                                             float x, float y, ///< Location to which to interpolate
    79                                             const psImageInterpolateOptions *options ///< Options
     79psImageInterpolateStatus psImageInterpolate(
     80    double *imageValue,                 ///< Return value for image
     81    double *varianceValue,              ///< Return value for variance
     82    psMaskType *maskValue,              ///< Return value for mask
     83    float x, float y,                   ///< Location to which to interpolate
     84    const psImageInterpolation *options ///< Options
    8085    );
    81 
    8286
    8387// Return the appropriate interpolation mode given a char string name for that mode
     
    9195/// factor.
    9296float psImageInterpolateVarianceFactor(float x, float y, ///< Position of interest
    93                                        const psImageInterpolateOptions *options ///< Interpolation options
     97                                       psImageInterpolateMode mode ///< Interpolation mode
    9498    );
    9599
Note: See TracChangeset for help on using the changeset viewer.