IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13483


Ignore:
Timestamp:
May 22, 2007, 4:55:01 PM (19 years ago)
Author:
Paul Price
Message:

Adding psImageInterpolateStatus, a status enum which is returned by psImageInterpolate to indicate the relative success. Relatively small API change should leave most implimentations unaffected.

Location:
trunk/psLib/src/imageops
Files:
2 edited

Legend:

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

    r12802 r13483  
    77 *  @author Paul Price, IfA
    88 *
    9  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2007-04-11 19:54:47 $
     9 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2007-05-23 02:55:01 $
    1111 *
    1212 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    6565
    6666// Interpolation engine for flat mode (nearest pixel)
    67 static inline bool interpolateFlat(double *imageValue, double *varianceValue, psMaskType *maskValue,
    68                                    float x, float y, const psImageInterpolateOptions *options)
     67static inline psImageInterpolateStatus interpolateFlat(double *imageValue, double *varianceValue,
     68                                                       psMaskType *maskValue, float x, float y,
     69                                                       const psImageInterpolateOptions *options)
    6970{
    7071    // Parameters have been checked by psImageInterpolate()
     
    8788            *maskValue = options->badMask;
    8889        }
     90
     91        return PS_INTERPOLATE_STATUS_OFF;
    8992    } else {
    9093
     
    115118            psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unrecognised type for image: %x",
    116119                    options->image->type.type);
    117             return false;
     120            return PS_INTERPOLATE_STATUS_ERROR;
    118121        }
    119122
     
    122125        }
    123126    }
    124     return true;
     127    return PS_INTERPOLATE_STATUS_GOOD;
    125128}
    126129
    127130// Interpolation engine using interpolation kernel
    128 static bool interpolateKernel(double *imageValue, double *varianceValue, psMaskType *maskValue,
    129                                float x, float y, const psImageInterpolateOptions *options)
     131static psImageInterpolateStatus interpolateKernel(double *imageValue, double *varianceValue,
     132                                                  psMaskType *maskValue, float x, float y,
     133                                                  const psImageInterpolateOptions *options)
    130134{
    131135    // Parameters have been checked by psImageInterpolate()
     
    171175            *maskValue = options->badMask;
    172176        }
    173         return true;
     177        return PS_INTERPOLATE_STATUS_OFF;
    174178    }
    175179    double kernel[yNum][xNum];          // Interpolation kernel for straight interpolation
     
    259263            psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unrecognised type for image: %x",
    260264                    image->type.type);
    261             return false;
     265            return PS_INTERPOLATE_STATUS_ERROR;
    262266        }
    263267    }
     
    265269    // Check the mask value
    266270    const psImage *mask = options->mask; // Image mask
     271    psImageInterpolateStatus status = PS_INTERPOLATE_STATUS_GOOD; // Status of interpolation
    267272    if (maskValue && mask) {
    268273        *maskValue = 0;
     
    285290            if (badContrib / totContrib >= options->poorFrac) {
    286291                *maskValue |= options->badMask;
     292                status = PS_INTERPOLATE_STATUS_BAD;
    287293            } else {
    288294                *maskValue |= options->poorMask;
     295            status = PS_INTERPOLATE_STATUS_POOR;
    289296            }
    290297        }
     
    321328            psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unrecognised type for image: %x",
    322329                    image->type.type);
    323             return false;
    324         }
    325     }
    326 
    327     return true;
     330            return PS_INTERPOLATE_STATUS_ERROR;
     331        }
     332    }
     333
     334    return status;
    328335}
    329336
     
    364371
    365372// Interpolation engine for separable interpolation kernels (either for good reasons or for practical reasons)
    366 static bool interpolateSeparate(double *imageValue, double *varianceValue, psMaskType *maskValue,
    367                                float x, float y, const psImageInterpolateOptions *options)
     373static psImageInterpolateStatus interpolateSeparate(double *imageValue, double *varianceValue,
     374                                               psMaskType *maskValue, float x, float y,
     375                                               const psImageInterpolateOptions *options)
    368376{
    369377    // Parameters have been checked by psImageInterpolate()
     
    406414            *maskValue = options->badMask;
    407415        }
    408         return true;
     416        return PS_INTERPOLATE_STATUS_OFF;
    409417    }
    410418
     
    477485            psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unrecognised type for image: %x",
    478486                    image->type.type);
    479             return false;
     487            return PS_INTERPOLATE_STATUS_ERROR;
    480488        }
    481489    }
     
    483491    // Check the mask value
    484492    const psImage *mask = options->mask; // Image mask
     493    psImageInterpolateStatus status = PS_INTERPOLATE_STATUS_GOOD; // Status of interpolation
    485494    if (maskValue && mask) {
    486495        psMaskType maskVal = options->maskVal; // Mask value
     
    509518            if (badContrib / totContrib >= options->poorFrac) {
    510519                *maskValue |= options->badMask;
     520                status = PS_INTERPOLATE_STATUS_BAD;
    511521            } else {
    512522                *maskValue |= options->poorMask;
     523                status = PS_INTERPOLATE_STATUS_POOR;
    513524            }
    514525        }
     
    547558            psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Unrecognised type for image: %x",
    548559                    variance->type.type);
    549             return false;
    550         }
    551     }
    552 
    553     return true;
    554 }
    555 
    556 
    557 
    558 bool psImageInterpolate(double *imageValue, double *varianceValue, psMaskType *maskValue,
     560            return PS_INTERPOLATE_STATUS_ERROR;
     561        }
     562    }
     563
     564    return status;
     565}
     566
     567
     568
     569psImageInterpolateStatus psImageInterpolate(double *imageValue, double *varianceValue, psMaskType *maskValue,
    559570                        float x, float y, const psImageInterpolateOptions *options)
    560571{
    561     PS_ASSERT_PTR_NON_NULL(options, false);
     572    PS_ASSERT_PTR_NON_NULL(options, PS_INTERPOLATE_STATUS_ERROR);
    562573
    563574    const psImage *image = options->image; // Image to interpolate
     
    565576    const psImage *variance = options->variance; // Variance to interpolate
    566577
    567     PS_ASSERT_IMAGE_NON_NULL(image, false);
     578    PS_ASSERT_IMAGE_NON_NULL(image, PS_INTERPOLATE_STATUS_ERROR);
    568579    if (varianceValue && variance) {
    569         PS_ASSERT_IMAGE_NON_NULL(variance, false);
    570         PS_ASSERT_IMAGE_TYPE(variance, image->type.type, false);
    571         PS_ASSERT_IMAGES_SIZE_EQUAL(variance, image, false);
     580        PS_ASSERT_IMAGE_NON_NULL(variance, PS_INTERPOLATE_STATUS_ERROR);
     581        PS_ASSERT_IMAGE_TYPE(variance, image->type.type, PS_INTERPOLATE_STATUS_ERROR);
     582        PS_ASSERT_IMAGES_SIZE_EQUAL(variance, image, PS_INTERPOLATE_STATUS_ERROR);
    572583    }
    573584    if (maskValue && mask) {
    574         PS_ASSERT_IMAGE_NON_NULL(mask, false);
    575         PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, false);
    576         PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, false);
    577     }
    578 
    579     PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(options->poorFrac, 0.0, false);
     585        PS_ASSERT_IMAGE_NON_NULL(mask, PS_INTERPOLATE_STATUS_ERROR);
     586        PS_ASSERT_IMAGE_TYPE(mask, PS_TYPE_MASK, PS_INTERPOLATE_STATUS_ERROR);
     587        PS_ASSERT_IMAGES_SIZE_EQUAL(mask, image, PS_INTERPOLATE_STATUS_ERROR);
     588    }
     589
     590    PS_ASSERT_FLOAT_LARGER_THAN_OR_EQUAL(options->poorFrac, 0.0, PS_INTERPOLATE_STATUS_ERROR);
    580591
    581592    switch (options->mode) {
     
    594605                _("Specified interpolation method (%d) is not supported."),
    595606                options->mode);
    596         return false;
     607        return PS_INTERPOLATE_STATUS_ERROR;
    597608    }
    598609
    599610    psAbort("Should never reach here.");
    600     return false;
     611    return PS_INTERPOLATE_STATUS_ERROR;
    601612}
    602613
  • trunk/psLib/src/imageops/psImageInterpolate.h

    r12741 r13483  
    77 * @author Paul Price, Institute for Astronomy
    88 *
    9  * @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    10  * @date $Date: 2007-04-04 22:42:02 $
     9 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     10 * @date $Date: 2007-05-23 02:55:01 $
    1111 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii
    1212 */
    1313
    14 #ifndef PS_IMAGE_PIXEL_INTERPOLATE_H
    15 #define PS_IMAGE_PIXEL_INTERPOLATE_H
     14#ifndef PS_IMAGE_INTERPOLATE_H
     15#define PS_IMAGE_INTERPOLATE_H
    1616
    1717
     
    2828} psImageInterpolateMode;
    2929
     30/// Status of interpolation
     31typedef enum {
     32    PS_INTERPOLATE_STATUS_ERROR = 0,    ///< There was an error
     33    PS_INTERPOLATE_STATUS_OFF,          ///< The pixel fell completely off the image or in the border
     34    PS_INTERPOLATE_STATUS_BAD,          ///< The pixel is bad
     35    PS_INTERPOLATE_STATUS_POOR,         ///< The pixel is poor
     36    PS_INTERPOLATE_STATUS_GOOD,         ///< The pixel is good
     37} psImageInterpolateStatus;
    3038
    3139/// Options for general interpolation.
     
    3543/// included.
    3644typedef struct {
    37     psImageInterpolateMode mode;        // Interpolation mode
    38     const psImage *image;               // Input image for interpolation
    39     const psImage *variance;            // Variance image for interpolation
    40     const psImage *mask;                // Mask image for interpolation
    41     psMaskType maskVal;                 // Value to mask
    42     double badImage;                    // Image value if x,y location is not good
    43     double badVariance;                 // Variance value if x,y location is not good
    44     psMaskType badMask;                 // Mask value to give bad pixels
    45     psMaskType poorMask;                // Mask value to give poor pixels
    46     float poorFrac;                     // Fraction of flux in bad pixels before output is marked bad
     45    psImageInterpolateMode mode;        ///< Interpolation mode
     46    const psImage *image;               ///< Input image for interpolation
     47    const psImage *variance;            ///< Variance image for interpolation
     48    const psImage *mask;                ///< Mask image for interpolation
     49    psMaskType maskVal;                 ///< Value to mask
     50    double badImage;                    ///< Image value if x,y location is not good
     51    double badVariance;                 ///< Variance value if x,y location is not good
     52    psMaskType badMask;                 ///< Mask value to give bad pixels
     53    psMaskType poorMask;                ///< Mask value to give poor pixels
     54    float poorFrac;                     ///< Fraction of flux in bad pixels before output is marked bad
    4755} psImageInterpolateOptions;
    4856
     
    6472
    6573/// Interpolate image pixel value given floating point coordinates.
    66 bool psImageInterpolate(double *imageValue, ///< Return value for image
    67                         double *varianceValue, ///< Return value for variance
    68                         psMaskType *maskValue, ///< Return value for mask
    69                         float x, float y, ///< Location to which to interpolate
    70                         const psImageInterpolateOptions *options ///< Options for interpolation
     74psImageInterpolateStatus psImageInterpolate(double *imageValue, ///< Return value for image
     75                                            double *varianceValue, ///< Return value for variance
     76                                            psMaskType *maskValue, ///< Return value for mask
     77                                            float x, float y, ///< Location to which to interpolate
     78                                            const psImageInterpolateOptions *options ///< Options
    7179    );
    7280
Note: See TracChangeset for help on using the changeset viewer.