psImageGeomManip.h

Go to the documentation of this file.
00001 /* @file  psImageGeomManip.h
00002  *
00003  * @brief Contains basic image geometry manipulation operations, as
00004  *        specified in the PSLIB SDRS sections "Image Geometry Manipulations".
00005  *
00006  * @author Robert DeSonia, MHPCC
00007  *
00008  * @version $Revision: 1.18 $ $Name:  $
00009  * @date $Date: 2007/01/23 22:47:23 $
00010  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00011  */
00012 #ifndef PS_IMAGE_GEOM_MANIP_H
00013 #define PS_IMAGE_GEOM_MANIP_H
00014 
00015 /// @addtogroup ImageOps Image Operations
00016 /// @{
00017 
00018 #include "psImage.h"
00019 #include "psCoord.h"
00020 #include "psStats.h"
00021 #include "psPixels.h"
00022 
00023 /** Rebin image to new scale.
00024  *
00025  *  A new image is constructed in which the dimensions are reduced by a factor of
00026  *  1/scale.  The scale, always a positive number, is equal in each dimension and
00027  *  specified the number of pixels used to define a new pixel in the output image.
00028  *  The output image is generated from all input image pixels. This function is
00029  *  defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64.
00030  *
00031  *  @return psImage    new image formed by rebinning input image.
00032  */
00033 psImage* psImageRebin(
00034     psImage* out,                      ///< an psImage to recycle.  If NULL, a new image is created
00035     const psImage* in,                 ///< input image
00036     const psImage* mask,               ///< mask for input image.  If NULL, no masking is done.
00037     psMaskType maskVal,                ///< the bits to check in mask.
00038     int scale,                         ///< the scale to rebin for each dimension
00039     const psStats* stats
00040     ///< the statistic to perform when rebinning.  Only one method should be set.
00041 );
00042 
00043 /** Resample image to new scale.
00044  *
00045  *  A new image is constructed in which the dimensions are increased by a
00046  *  factor of scale. The scale, always a positive number, is equal in each
00047  *  dimension. The output image is generated from all input image pixels.
00048  *  Each pixel in the output image is derived by interpolating between
00049  *  neighboring pixels using the specified interpolation method (mode).
00050  *
00051  *  @return psImage*    resampled image result
00052  */
00053 psImage* psImageResample(
00054     psImage* out,                      ///< an psImage to recycle.  If NULL, a new image is created
00055     const psImage* in,                 ///< input image
00056     int scale,                       ///< resample scaling factor
00057     psImageInterpolateMode mode        ///< the interpolation mode used in resampling
00058 );
00059 
00060 /** Rotate the input image by given angle, specified in degrees.
00061  *
00062  *  The output image must contain all of the pixels from the input image in
00063  *  their new frame. Pixels in the output image which do not map to input
00064  *  pixels should be set to exposed. The center of rotation is always the
00065  *  center pixel of the image. The rotation is specified in the sense that a
00066  *  positive angle is an anti-clockwise rotation. This function must be
00067  *  defined for the following types: psU8, psU16, psS8, psS16, psF32, psF64,
00068  *  psC32, psC64.
00069  *
00070  *  @return psImage*     the rotated image result.
00071  */
00072 psImage* psImageRotate(
00073     psImage* out,                      ///< an psImage to recycle.  If NULL, a new image is created
00074     const psImage* input,              ///< input image
00075     float angle,                       ///< the rotation angle in radians.
00076     double complex exposed,            ///< the output image pixel values for non-imagery areas
00077     psImageInterpolateMode mode        ///< the interpolation mode used
00078 );
00079 
00080 /** Shift image by an arbitrary number of pixels (dx,dy) in either direction.
00081  *
00082  *  If the shift values are fractional, the output pixel values should
00083  *  interpolate between the input pixel values. The output image has the same
00084  *  dimensions as the input image. Pixels which fall off the edge of the
00085  *  output image are lost. Newly exposed pixels are set to the value given by
00086  *  exposed. This function must be defined for the following types: psU8,
00087  *  psU16, psS8, psS16, psF32, psF64, psC32, psC64.
00088  *
00089  *  @return psImage*     the shifted image result.
00090  */
00091 psImage* psImageShift(
00092     psImage* out,                      ///< an psImage to recycle.  If NULL, a new image is created
00093     const psImage* input,              ///< input image
00094     float dx,                          ///< the shift in x direction.
00095     float dy,                          ///< the shift in y direction.
00096     double complex exposed,            ///< the output image pixel values for non-imagery areas
00097     psImageInterpolateMode mode        ///< the interpolation mode to use
00098 );
00099 
00100 /** Shift image by an arbitrary number of pixels (dx,dy) in either direction.
00101  *
00102  *  If the shift values are fractional, the output pixel values should
00103  *  interpolate between the input pixel values. The output image has the same
00104  *  dimensions as the input image. Pixels which fall off the edge of the
00105  *  output image are lost. Newly exposed pixels are set to the value given by
00106  *  exposed. This function must be defined for the following types: psU8,
00107  *  psU16, psS8, psS16, psF32, psF64, psC32, psC64.
00108  *
00109  *  This implementation uses a NxN kernel generated based on the interpolation method
00110  *  the image is first shifted by a fractional amount with the kernel, then
00111  *  shifted in place by an integer amount. 
00112  *
00113  *  XXX the integer shift portion is not implemented
00114  *  XXX the exposed pixels are not properly replaced
00115  *  XXX the algorithm can properly handle a mask, but the API does not include
00116  *  it (and it is not implemented)
00117  *
00118  *  @return psImage*     the shifted image result.
00119  */
00120 psImage* psImageShiftKernel(
00121     psImage* out,                      ///< an psImage to recycle.  If NULL, a new image is created
00122     const psImage* input,              ///< input image
00123     float dx,                          ///< the shift in x direction.
00124     float dy,                          ///< the shift in y direction.
00125     psImageInterpolateMode mode        ///< the interpolation mode to use
00126 );
00127 
00128 // XXX should this be global private or local static?
00129 psImage *p_psImageShiftKernel_F32(
00130     psImage *out,
00131     const psImage *input,
00132     const psImage *kernel);
00133 
00134 /** Roll image by an integer number of pixels in either direction.
00135  *
00136  *  The output image is the same dimensions as the input image.  Edge pixels
00137  *  wrap to the other side (no values are lost).  This function is
00138  *  defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64.
00139  *
00140  *  @return psImage* the rolled version of the input image.
00141  */
00142 psImage* psImageRoll(
00143     psImage* out,                      ///< an psImage to recycle.  If NULL, a new image is created
00144     const psImage* input,              ///< input image
00145     int dx,                            ///< number of pixels to roll in the x-dimension
00146     int dy                             ///< number of pixels to roll in the y-dimension
00147 );
00148 
00149 /** Transform the input image according the supplied transformation.
00150  *
00151  *  Transform the input image according the supplied transformation. The size
00152  *  of the transformed image is defined by the supplied output image, if
00153  *  non-NULL, or the region otherwise (size region.x1 - region.x0 by region.y1
00154  *  region.y0, with out->x0 = region.x0 and out->y0 = region.y0). If the
00155  *  inputMask is non-NULL, those pixels in the inputMask matching inputMaskVal
00156  *  are to be ignored in the transformation. The inputMask must be of type
00157  *  psU8, and of the same size as the input, otherwise the function shall
00158  *  generate an error and return NULL. The transformation outToIn specifies the
00159  *  coordinates in the input image of a pixel in the output image — note that
00160  *  this is the reverse of what might be naively expected, but it is what is
00161  *  required in order to use psImagePixelInterpolate. If the pixels array is
00162  *  non-NULL, it shall consist of psPixelCoords, and only those pixels in the
00163  *  output image shall be transformed; otherwise, the entire image is
00164  *  generated. The interpolation is performed using the specified interpolation
00165  *  mode. Where a pixel in the output image does not correspond to a pixel in
00166  *  the input image (or all appropriate pixels in the input image are
00167  *  masked), the value shall be set to exposed, and the pixel added to the
00168  *  appropriate list of pixels (psPixels) in the array of blankPixels for
00169  *  return to the user. This function must be capable of handling the following
00170  *  types for the input (with corresponding types for the output): psF32, psF64.
00171  
00172  *
00173  *  @return psImage*    The transformed image.
00174  */
00175 psImage* psImageTransform(
00176     psImage *output,                   ///< psImage to recycle, or NULL
00177     psPixels** blankPixels,            ///< list of pixels in output image not set, or NULL if no list is desired.
00178     const psImage *input,              ///< psImage to apply transform to
00179     const psImage *inputMask,          ///< if not NULL, mask of input psImage
00180     psMaskType inputMaskVal,           ///< masking value for inputMask
00181     const psPlaneTransform *outToIn,   ///< the transform to apply
00182     psRegion region,                   ///< the size of the transformed image
00183     const psPixels* pixels,            /**< if not NULL, consists of psPixelCoords and specifies
00184                                                         * which pixels in output image shall be transformed;
00185                                                         * otherwise, entire image generated*/
00186     psImageInterpolateMode mode,       ///< the interpolation scheme to be used
00187     double exposedValue                ///< Exposed value to which non-corresponding pixels are set
00188 );
00189 
00190 // Flip the input image
00191 psImage *psImageFlip(psImage *output,   // Output image, or NULL
00192                      const psImage *input, // Input image
00193                      bool xFlip,        // Flip x axis?
00194                      bool yFlip         // Flip y axis?
00195                     );
00196 
00197 /// @}
00198 #endif // #ifndef PS_IMAGE_GEOM_MANIP_H

Generated on Fri Feb 2 22:24:35 2007 for pslib by  doxygen 1.5.1