00001 00002 /** @file psImageExtraction.h 00003 * 00004 * @brief Contains basic image extraction operations, as specified in the 00005 * PSLIB SDRS sections "Image Pixel Extractions" and "Image Structure 00006 * Manipulation". 00007 * 00008 * @ingroup Image 00009 * 00010 * @author Robert DeSonia, MHPCC 00011 * 00012 * @version $Revision: 1.21 $ $Name: rel5_0 $ 00013 * @date $Date: 2005/02/17 19:26:24 $ 00014 * 00015 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii 00016 */ 00017 00018 #ifndef PSIMAGEEXTRACTION_H 00019 #define PSIMAGEEXTRACTION_H 00020 00021 #include "psImage.h" 00022 #include "psVector.h" 00023 #include "psStats.h" 00024 00025 /// @addtogroup Image 00026 /// @{ 00027 00028 /* Cut direction flag. Used with psImageCut function. 00029 */ 00030 typedef enum { 00031 PS_CUT_X_POS, ///< Cut in the x dimension from left to right 00032 PS_CUT_X_NEG, ///< Cut in the x dimension from rigth to left 00033 PS_CUT_Y_POS, ///< Cut in the y dimension from bottom up 00034 PS_CUT_Y_NEG, ///< Cut in the y dimension from top down. 00035 } psImageCutDirection; 00036 00037 /** Create a subimage of the specified area. 00038 * 00039 * Extracts a subimage starting at (col0,row0) to (col1-1,row1-1). Note: 00040 * the column col1 and row row1 are NOT included in the resulting subimage. 00041 * In the event that x1 or y1 are non-positive, they shall be interpreted as 00042 * being relative to the size of the parent image in that dimension. 00043 * 00044 * If the entire specified subimage is not contained within the parent 00045 * image, an error results and the return value will be NULL. 00046 * 00047 * The resulting psImage does not create a copy of the underlying image 00048 * data. Future changes in the parent may be reflecting in the child 00049 * subimage and vis versa. 00050 * 00051 * @return psImage* : Pointer to psImage. 00052 * 00053 */ 00054 psImage* psImageSubset( 00055 psImage* image, ///< Parent image. 00056 psS32 col0, ///< starting column of subimage 00057 psS32 row0, ///< starting row of subimage 00058 psS32 col1, ///< exclusive end column of subimage. 00059 psS32 row1 ///< exclusive end row of subimage 00060 ); 00061 00062 /** Create a subimage of the specified area. 00063 * 00064 * Uses psLib memory allocation functions to create an image based on a larger 00065 * one. 00066 * 00067 * @return psImage* : Pointer to psImage. 00068 * 00069 */ 00070 psImage* psImageSubsection( 00071 psImage* image, ///< Parent image. 00072 const char* section ///< Subsection in the form '[x1:x2,y1:y2]' 00073 ); 00074 00075 /** Trim an image 00076 * 00077 * Trim the specified image in-place, which involves shuffling the pixels 00078 * around in memory. The pixels in the region [col0:col1,row0:row1] shall consist 00079 * the output image. The column col1 and row row1 are NOT included in the range. 00080 * In the event that x1 or y1 are non-positive, they shall be interpreted as 00081 * being relative to the size of the parent image in that dimension. 00082 * 00083 * If the entire specified subimage is not contained within the parent 00084 * image, an error results and the return value will be NULL. 00085 * 00086 * N.B. If the input psImage is a child of another psImage, no pixel data 00087 * will be trimmed, rather it equivalent to calling psImageSubset. If the input 00088 * psImage is, however, a parent psImage, any children will be obliterated, 00089 * i.e., freed from memory. 00090 * 00091 * @return psImage* trimmed image result 00092 */ 00093 psImage* psImageTrim( 00094 psImage* image, ///< image to trim 00095 psS32 col0, ///< column of trim region's left boundary 00096 psS32 row0, ///< row of trim region's lower boundary 00097 psS32 col1, ///< column of trim region's right boundary 00098 psS32 row1 ///< row of trim region's upper boundary 00099 ); 00100 00101 /** Extract pixels from rectlinear region to a vector (array of floats). 00102 * 00103 * The output vector contains either col1-col0 or row1-row0 elements, based 00104 * on the value of the direction: e.g., if direction is PS_CUT_X_POS, there 00105 * are col1-col0 elements. The region to be sliced is defined by the 00106 * lower-left corner, (col0,row0), and the upper-right corner, (col1,row1). 00107 * Note that the row and column of the upper right-hand corner are NOT 00108 * included in the region. In the event that col1 or row1 are negative, they 00109 * shall be interpreted as being relative to the size of the parent image in 00110 * that dimension. The input region is collapsed in the direction perpendicular 00111 * to that specified by direction, and each element of the output vectors is 00112 * derived from the statistics of the pixels at that direction coordinate. The 00113 * statistic used to derive the output vector value is specified by stats. 00114 * If mask is non-NULL, pixels for which the corresponding mask pixel 00115 * matches maskVal are excluded from operations. If coords is not NULL, the 00116 * calculated coordinates along the slice are returned in this vector. Only 00117 * one of the statistics choices may be specified, otherwise the function 00118 * must return an error. 00119 * 00120 * This function is defined for the following types: psS8, psU16, psF32, psF64. 00121 * 00122 * @return psVector the resulting vector 00123 */ 00124 psVector* psImageSlice( 00125 psVector* out, ///< psVector to recycle, or NULL. 00126 psVector* slicePositions, 00127 ///< If not NULL, it is populated with the coordinate in the slice dimension 00128 ///< coorsponding to the output vector's value of the same position in the 00129 ///< vector. This vector maybe resized and retyped as appropriate. 00130 const psImage* input, ///< the input image in which to perform the slice 00131 const psImage* mask, ///< the mask for the input image. 00132 psU32 maskVal, ///< the mask value to apply to the mask 00133 psS32 col0, ///< the leftmost column of the slice region 00134 psS32 row0, ///< the bottommost row of the slice region 00135 psS32 col1, ///< exclusive end column of the slice region 00136 psS32 row1, ///< exclusive end row of the slice region 00137 psImageCutDirection direction, ///< the slice dimension and direction 00138 const psStats* stats ///< the statistic to perform in slice operation 00139 ); 00140 00141 /** Extract pixels from an image along a line to a vector (array of floats). 00142 * 00143 * The vector (xs,ys) - (xe,ye) forms the basis of the output vector. Pixels 00144 * are considered in a rectangular region of width dw about this vector. The 00145 * input region is collapsed in the perpendicular direction, and each element 00146 * of the output vector represents pixel-sized boxes, where the value is 00147 * derived from the statistics of the pixels interpolated along the 00148 * perpendicular direction. The specific algorithm which must be used is 00149 * described in the PSLib ADD (PSDC-430-006). The statistic used to derive 00150 * the output vector value is specified by stats. Only one of the statistics 00151 * choices may be specified, otherwise the function must return an error. 00152 * This function must be defined for the following types: psS8, psU16, psF32, 00153 * psF64. 00154 * 00155 * @return psVector resulting vector 00156 */ 00157 psVector* psImageCut( 00158 psVector* out, ///< psVector to recycle, or NULL. 00159 psVector* cutCols, ///< if not NULL, the calculated column values along the slice (output) 00160 psVector* cutRows, ///< if not NULL, the calculated row values along the slice (output) 00161 const psImage* input, ///< the input image in which to perform the cut 00162 const psImage* mask, ///< the mask for the input image. 00163 psU32 maskVal, ///< the mask value to apply to the mask 00164 float startCol, ///< the column of the start of the cut line 00165 float startRow, ///< the row of the start of the cut line 00166 float endCol, ///< the column of the end of the cut line 00167 float endRow, ///< the row of the end of the cut line 00168 psU32 nSamples, ///< the number of samples along the cut 00169 psImageInterpolateMode mode ///< the interpolation method to use 00170 ); 00171 00172 /** Extract radial region data to a vector. A vector is constructed where each 00173 * vector elements is derived from the statistics of the pixels which land 00174 * within one of a sequence of radii. The radii are centered on the image 00175 * pixel coordinate x,y, and are defined by the sequence of values in the 00176 * vector radii. The specific algorithm which must be used is described in 00177 * the PSLib ADD (PSDC-430-006). The statistic used to derive the output 00178 * vector value is specified by stats. Only one of the statistics choices 00179 * may be specified, otherwise the function must return an error. This 00180 * function must be defined for the following types: psS8, psU16, psF32, 00181 * psF64. 00182 * 00183 * @return psVector resulting vector 00184 */ 00185 psVector* psImageRadialCut( 00186 psVector* out, ///< psVector to recycle, or NULL. 00187 const psImage* input, ///< the input image in which to perform the cut 00188 const psImage* mask, ///< the mask for the input image. 00189 psU32 maskVal, ///< the mask value to apply to the mask 00190 float centerCol, ///< the column of the center of the cut circle 00191 float centerRow, ///< the row of the center of the cut circle 00192 const psVector* radii, ///< the radii of the cut circle 00193 const psStats* stats ///< the statistic to perform in operation 00194 ); 00195 00196 /// @} 00197 00198 #endif
1.3.9.1