00001 00002 /** @file psImageManip.h 00003 * 00004 * @brief Contains basic image pixel and geometry manipulation operations, as 00005 * specified in the PSLIB SDRS sections "Image Pixel Manipulations" and 00006 * "Image Geometry Manipulations". 00007 * 00008 * @ingroup Image 00009 * 00010 * @author Robert DeSonia, MHPCC 00011 * @author Ross Harman, MHPCC 00012 * 00013 * @version $Revision: 1.19 $ $Name: rel5_0 $ 00014 * @date $Date: 2005/03/22 21:52:49 $ 00015 * 00016 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 00017 */ 00018 #ifndef PS_IMAGE_MANIP_H 00019 #define PS_IMAGE_MANIP_H 00020 00021 #include "psImage.h" 00022 #include "psCoord.h" 00023 00024 /// @addtogroup Image 00025 /// @{ 00026 00027 /** Clip image values outside of range to given values 00028 * 00029 * All pixels with values less than min are set to the value vmin. all pixels 00030 * with values greater than max are set to the value vmax. This function is 00031 * defined for psU8, psU16, psS8, psS16, psF32, psF64, psC32, and psC64. 00032 * 00033 * @return psS32 The number of clipped pixels 00034 */ 00035 psS32 psImageClip( 00036 psImage* input, ///< the image to clip 00037 psF64 min, ///< the minimum image value allowed 00038 psF64 vmin, ///< the value pixels < min are set to 00039 psF64 max, ///< the maximum image value allowed 00040 psF64 vmax ///< the value pixels > max are set to 00041 ); 00042 00043 /** Clip image values outside of a specified complex region 00044 * 00045 * All pixels outside of the rectangular region in complex space formed by 00046 * the min and max input parameters are set to the value vmax (if either 00047 * the real or imaginary portion exceeds the respective max values), or vmin. 00048 * This function is defined for psC32, and psC64 imagery only. 00049 * 00050 * @return psS32 The number of clipped pixels 00051 */ 00052 psS32 psImageClipComplexRegion( 00053 psImage* input, ///< the image to clip 00054 psC64 min, ///< the minimum image value allowed 00055 psC64 vmin, ///< the value pixels < min are set to 00056 psC64 max, ///< the maximum image value allowed 00057 psC64 vmax ///< the value pixels > max are set to 00058 ); 00059 00060 /** Clip NaN image pixels to given value. 00061 * 00062 * Pixels with NaN, +Inf, or -Inf values are set to the specified value. This 00063 * function is defined for psF32, psF64, psC32, and psC64. 00064 * 00065 * @return psS32 The number of clipped pixels 00066 */ 00067 psS32 psImageClipNaN( 00068 psImage* input, ///< the image to clip 00069 psF64 value ///< the value to set all NaN/Inf values to 00070 ); 00071 00072 /** Overlay subregion of image with another image 00073 * 00074 * Replace the pixels in the image which correspond to the pixels in OVERLAY 00075 * with values derived from the IMAGE and OVERLAY based on the given operator 00076 * OP. Valid operators are "=" (set image value to OVERLAY value), "+" (add 00077 * OVERLAY value to image value), "-" (subtract OVERLAY from image), "*" 00078 * (multiply OVERLAY times image), "/" (divide image by OVERLAY). This 00079 * function is defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64. 00080 * 00081 * @return psS32 0 if success, non-zero if failed. 00082 */ 00083 psS32 psImageOverlaySection( 00084 psImage* image, ///< target image 00085 const psImage* overlay, ///< the overlay image 00086 psS32 col0, ///< the column to start overlay 00087 psS32 row0, ///< the row to start overlay 00088 const char *op ///< the operation to perform for overlay 00089 ); 00090 00091 /** Rebin image to new scale. 00092 * 00093 * A new image is constructed in which the dimensions are reduced by a factor of 00094 * 1/scale. The scale, always a positive number, is equal in each dimension and 00095 * specified the number of pixels used to define a new pixel in the output image. 00096 * The output image is generated from all input image pixels. This function is 00097 * defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64. 00098 * 00099 * @return psImage new image formed by rebinning input image. 00100 */ 00101 psImage* psImageRebin( 00102 psImage* out, ///< an psImage to recycle. If NULL, a new image is created 00103 const psImage* in, ///< input image 00104 const psImage* mask, ///< mask for input image. If NULL, no masking is done. 00105 psMaskType maskVal, ///< the bits to check in mask. 00106 psU32 scale, ///< the scale to rebin for each dimension 00107 const psStats* stats 00108 ///< the statistic to perform when rebinning. Only one method should be set. 00109 ); 00110 00111 /** Resample image to new scale. 00112 * 00113 * A new image is constructed in which the dimensions are increased by a 00114 * factor of scale. The scale, always a positive number, is equal in each 00115 * dimension. The output image is generated from all input image pixels. 00116 * Each pixel in the output image is derived by interpolating between 00117 * neighboring pixels using the specified interpolation method (mode). 00118 * 00119 * @return psImage* resampled image result 00120 */ 00121 psImage* psImageResample( 00122 psImage* out, ///< an psImage to recycle. If NULL, a new image is created 00123 const psImage* in, ///< input image 00124 psS32 scale, ///< resample scaling factor 00125 psImageInterpolateMode mode ///< the interpolation mode used in resampling 00126 ); 00127 00128 /** Rotate the input image by given angle, specified in degrees. 00129 * 00130 * The output image must contain all of the pixels from the input image in 00131 * their new frame. Pixels in the output image which do not map to input 00132 * pixels should be set to exposed. The center of rotation is always the 00133 * center pixel of the image. The rotation is specified in the sense that a 00134 * positive angle is an anti-clockwise rotation. This function must be 00135 * defined for the following types: psU8, psU16, psS8, psS16, psF32, psF64, 00136 * psC32, psC64. 00137 * 00138 * @return psImage* the rotated image result. 00139 */ 00140 psImage* psImageRotate( 00141 psImage* out, ///< an psImage to recycle. If NULL, a new image is created 00142 const psImage* in, ///< input image 00143 float angle, ///< the rotation angle in radians. 00144 psC64 unexposedValue, ///< the output image pixel values for non-imagery areas 00145 psImageInterpolateMode mode ///< the interpolation mode used 00146 ); 00147 00148 /** Shift image by an arbitrary number of pixels (dx,dy) in either direction. 00149 * 00150 * If the shift values are fractional, the output pixel values should 00151 * interpolate between the input pixel values. The output image has the same 00152 * dimensions as the input image. Pixels which fall off the edge of the 00153 * output image are lost. Newly exposed pixels are set to the value given by 00154 * exposed. This function must be defined for the following types: psU8, 00155 * psU16, psS8, psS16, psF32, psF64, psC32, psC64. 00156 * 00157 * @return psImage* the shifted image result. 00158 */ 00159 psImage* psImageShift( 00160 psImage* out, ///< an psImage to recycle. If NULL, a new image is created 00161 const psImage* in, ///< input image 00162 float dx, ///< the shift in x direction. 00163 float dy, ///< the shift in y direction. 00164 psC64 unexposedValue, ///< the output image pixel values for non-imagery areas 00165 psImageInterpolateMode mode ///< the interpolation mode to use 00166 ); 00167 00168 /** Roll image by an integer number of pixels in either direction. 00169 * 00170 * The output image is the same dimensions as the input image. Edge pixels 00171 * wrap to the other side (no values are lost). This function is 00172 * defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64. 00173 * 00174 * @return psImage* the rolled version of the input image. 00175 */ 00176 psImage* psImageRoll( 00177 psImage* out, ///< an psImage to recycle. If NULL, a new image is created 00178 const psImage* in, ///< input image 00179 psS32 dx, ///< number of pixels to roll in the x-dimension 00180 psS32 dy ///< number of pixels to roll in the y-dimension 00181 ); 00182 00183 /** Transform the input image according the supplied transformation. 00184 * 00185 * Transform the input image according the supplied transformation. In the 00186 * event that the output is NULL, the smallest possible image capable of 00187 * containing the entire transformed input image is to be returned; otherwise 00188 * only the image size specified in the output image is to be used. If the 00189 * inputMask is not NULL, those pixels in the inputMask matching inputMaskVal 00190 * are to be ignored in the transformation. The inputMask must be of type 00191 * psU8, and of the same size as the input, otherwise the function shall 00192 * generate an error and return NULL. The transformation outToIn specifies 00193 * the coordinates in the input image of a pixel in the output image - note 00194 * that this is the reverse of what might be naively expected, but it is what 00195 * is required in order to use psImagePixelInterpolate. If combineMask is not 00196 * NULL, then those pixels that match combineMaskVal are not transformed. 00197 * combineMask must be of type psU8 and of the same size as the output, 00198 * otherwise the function shall generate an error and return NULL. This 00199 * function must be capable of handling the following types for the input 00200 * (with corresponding types for the output): psF32, psF64. 00201 * 00202 * @return psImage* The transformed image. 00203 */ 00204 psImage* psImageTransform( 00205 psImage *output, ///< psImage to recycle, or NULL 00206 const psImage *input, ///< psImage to apply transform to 00207 const psImage *inputMask, ///< if not NULL, mask of input psImage 00208 int inputMaskVal, ///< masking value for inputMask 00209 const psPlaneTransform *outToIn, ///< the transform to apply 00210 const psImage *combineMask, ///< if not NULL, mask of pixels not to be transformed 00211 int combineMaskVal ///< masking value for combineMask 00212 ); 00213 00214 #endif
1.3.9.1