Changeset 633
- Timestamp:
- May 10, 2004, 10:20:42 AM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 5 edited
-
dataManip/Makefile (modified) (2 diffs)
-
image/psImage.c (modified) (3 diffs)
-
image/psImage.h (modified) (6 diffs)
-
mathtypes/psImage.c (modified) (3 diffs)
-
mathtypes/psImage.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/Makefile
r563 r633 3 3 endif 4 4 5 TARGET = ps Stats.o libpsDataManip.a5 TARGET = psImage.o psStats.o libpsDataManip.a 6 6 7 7 all: $(TARGET) … … 9 9 include ../Makefile.Globals 10 10 11 SRC_OBJS = 11 SRC_OBJS = 12 12 13 13 %.o: %.c -
trunk/psLib/src/image/psImage.c
r599 r633 7 7 * @author Ross Harman, MHPCC 8 8 * 9 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-05- 07 02:56:52 $9 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-05-10 20:20:42 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 17 17 /******************************************************************************/ 18 18 #include "psMemory.h" 19 #include "psError.h" 19 20 #include "psArray.h" 21 #include "psImage.h" 20 22 21 23 /******************************************************************************/ … … 53 55 /*****************************************************************************/ 54 56 55 psImage *psImageAlloc(int n x, int ny, psType type)57 psImage *psImageAlloc(int nCols, int nRows, psType type) 56 58 { 57 59 psImage *image = NULL; 58 60 59 psImage = psAlloc(psImage);60 psImage->type = type;61 psImage->nx = nx;62 psImage->ny = ny;63 psImage->x0 = 0;64 psImage->y0 = 0;65 psImage->parent = NULL;66 psImage->nChildren = 0;67 psImage->children = NULL;61 image = psAlloc(sizeof(psImage)); 62 image->type = type; 63 image->nCols = nCols; 64 image->nRows = nRows; 65 image->col0 = 0; 66 image->row0 = 0; 67 image->parent = NULL; 68 image->nChildren = 0; 69 image->children = NULL; 68 70 69 71 switch(type.type) { 70 72 case PS_TYPE_SHORT: 71 image->rows.rows_s i = psAlloc(nx*ny*sizeof(short));73 image->rows.rows_s = psAlloc(nCols*nRows*sizeof(short)); 72 74 break; 73 75 case PS_TYPE_INT: 74 image->rows.rows_i = psAlloc(n x*ny*sizeof(int));76 image->rows.rows_i = psAlloc(nCols*nRows*sizeof(int)); 75 77 break; 76 78 case PS_TYPE_LONG: 77 image->rows.rows_l i = psAlloc(nx*ny*sizeof(long));79 image->rows.rows_l = psAlloc(nCols*nRows*sizeof(long)); 78 80 break; 79 81 case PS_TYPE_USHORT: 80 image->rows.rows_us = psAlloc(n x*ny*sizeof(unsigned short));82 image->rows.rows_us = psAlloc(nCols*nRows*sizeof(unsigned short)); 81 83 break; 82 84 case PS_TYPE_UINT: 83 image->rows.rows_ui = psAlloc(n x*ny*sizeof(unsigned int));85 image->rows.rows_ui = psAlloc(nCols*nRows*sizeof(unsigned int)); 84 86 break; 85 87 case PS_TYPE_ULONG: 86 image->rows.rows_ul = psAlloc(n x*ny*sizeof(unsigned long));88 image->rows.rows_ul = psAlloc(nCols*nRows*sizeof(unsigned long)); 87 89 break; 88 90 case PS_TYPE_FLOAT: 89 image->rows.rows_f = psAlloc(n x*ny*sizeof(float));91 image->rows.rows_f = psAlloc(nCols*nRows*sizeof(float)); 90 92 break; 91 93 case PS_TYPE_DOUBLE: 92 image->rows.rows_d = psAlloc(n x*ny*sizeof(double));94 image->rows.rows_d = psAlloc(nCols*nRows*sizeof(double)); 93 95 break; 94 96 case PS_TYPE_COMPLEX: 95 image->rows.rows_cf = psAlloc(nx*ny*sizeof(complex float)); 96 break; 97 case PS_TYPE_OTHER: 98 psError(__func__, " : Line %d - Invalid psBitMask binary operation: %s\n", __LINE__); 97 image->rows.rows_cf = psAlloc(nCols*nRows*sizeof(complex float)); 99 98 break; 100 99 default: 101 psError(__func__, " : Line %d - Invalid ps BitMask binary operation: %s\n", __LINE__);100 psError(__func__, " : Line %d - Invalid psImage type: %d\n", __LINE__, type.type); 102 101 } 103 102 103 return image; 104 } 104 105 106 void psImageFree(psImage *image) 107 { 108 int i = 0; 109 int nChildren = 0; 110 psElemType imageType = 0; 111 psImage *children = NULL; 112 113 if(image != NULL) { 114 imageType = image->type.type; 115 nChildren = image->nChildren; 116 children = image->children; 117 118 switch(imageType) { 119 case PS_TYPE_SHORT: 120 psFree(image->rows.rows_s); 121 break; 122 case PS_TYPE_INT: 123 psFree(image->rows.rows_i); 124 break; 125 case PS_TYPE_LONG: 126 psFree(image->rows.rows_l); 127 break; 128 case PS_TYPE_USHORT: 129 psFree(image->rows.rows_us); 130 break; 131 case PS_TYPE_UINT: 132 psFree(image->rows.rows_ui); 133 break; 134 case PS_TYPE_ULONG: 135 psFree(image->rows.rows_ul); 136 break; 137 case PS_TYPE_FLOAT: 138 psFree(image->rows.rows_f); 139 break; 140 case PS_TYPE_DOUBLE: 141 psFree(image->rows.rows_d); 142 break; 143 case PS_TYPE_COMPLEX: 144 psFree(image->rows.rows_cf); 145 break; 146 case PS_TYPE_OTHER: 147 psError(__func__, " : Line %d - Can't delete images of type PS_TYPE_OTHER\n", __LINE__); 148 break; 149 default: 150 psError(__func__, " : Line %d - Invalid psImage type: %d\n", __LINE__, imageType); 151 } 152 153 for(i=0; i<nChildren; i++) { 154 psImageFree(children); 155 } 156 } 105 157 } -
trunk/psLib/src/image/psImage.h
r599 r633 7 7 * @author Ross Harman, MHPCC 8 8 * 9 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-05- 07 02:56:52 $9 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-05-10 20:20:42 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 36 36 { 37 37 psType type; ///< Image data type and dimension. 38 int nx, ny; ///< Size of image. 39 int x0, y0; ///< Data region relative to parent. 38 int nCols; ///< Number of rows in image 39 int nRows; ///< Number of columns in image. 40 int col0; ///< Row position relative to parent. 41 int row0; ///< Column position relative to parent. 40 42 union { 41 float **rows ///< Pointers to floating point data (default).42 43 short **rows_s; ///< Pointers to short integer data. 43 44 int **rows_i; ///< Pointers to integer data. … … 46 47 unsigned int **rows_ui; ///< Pointers to unsigned integer data. 47 48 unsigned long **rows_ul; ///< Pointers to unsigned long integer data. 48 float **rows_f ///< Pointers to floating point data.49 double **rows_d ///< Pointers to double precision data.50 complex float **rows_cf ///< Pointers to complex floating point data.49 float **rows_f; ///< Pointers to floating point data. 50 double **rows_d; ///< Pointers to double precision data. 51 complex float **rows_cf; ///< Pointers to complex floating point data. 51 52 } rows; ///< Union for data types. 52 53 struct psImage *parent; ///< Parent, if a subimage. … … 69 70 */ 70 71 psImage *psImageAlloc( 71 int n x, ///< Image width.72 int n y, ///< Image height.73 psType type ///< Image data type.72 int nCols, ///< Number of rows in image. 73 int nRows, ///< Number of columns in image. 74 psType type ///< Type of data for image. 74 75 ); 75 76 … … 84 85 psImage *out, ///< Subimage to return, or NULL. 85 86 const psImage *image, ///< Parent image. 86 int n x, ///< Subimage width (<= image.nx - x0).87 int n y, ///< Subimage width (<= image.ny - y0).88 int x0, ///< Subimage x-offset (0 <= x0 < nx).89 int y0 ///< Subimage y-offset (0 <= y0 < ny).87 int nCols, ///< Subimage width (<= image.nCols - col0). 88 int nRows, ///< Subimage height (<= image.nRows - row0). 89 int col0, ///< Subimage col-offset (0 <= col0 < nCol). 90 int row0 ///< Subimage row-offset (0 <= row0 < nCol). 90 91 ); 91 92 … … 98 99 */ 99 100 void psImageFree( 100 psImage *restrict image ///< free this image101 psImage *restrict image ///< Free psImage 101 102 ); 102 103 103 104 105 // DOXYGEN COMMENTING FORMAT NOT YET FULLY IMPLEMENTED BEYOND THIS POINT106 107 108 109 /** Destroy the pixels of the specified image */110 psImage *111 psImageFreePixels(psImage *restrict image ///< Image whose pixels are to be freed112 );113 114 /// Destroy the children of the specified image. Returns number of children freed.115 int116 psImageFreeChildren(const psImage *image ///< free children of this image117 );118 119 /// Create a copy of the specified image.120 psImage *121 psImageCopy(psImage *output, ///< target structure for output image data122 const psImage *input ///< copy this image123 );124 125 /*** various image pixel extractions ***/126 127 /// Extract pixels from rectlinear region to a vector.128 psFloatArray *129 psImageSlice(psFloatArray *out, ///< Vector to output, or NULL130 const psImage *input, ///< extract slice from this image131 int x, ///< starting x coord of region to slice132 int y, ///< starting y coord of region to slice133 int nx, ///< width of region in x134 int ny, ///< width of region in y135 int direction, ///< direction of vector along slice136 const psStats *stats ///< defines statistics used to find output values137 );138 139 /// Extract pixels along a line to a vector.140 psFloatArray *141 psImageCut(psFloatArray *out, ///< Vector to output, or NULL142 const psImage *input, ///< extract cut from this image143 float xs, ///< starting x coord of cut144 float ys, ///< starting y coord of cut145 float xe, ///< ending x coord of cut146 float ye, ///< ending y coord of cut147 float dw, ///< width of cut148 const psStats *stats ///< defines statistics used to find output values149 );150 151 /// Extract radial annulii data to a vector.152 psFloatArray *153 psImageRadialCut(psFloatArray *out, ///< Vector to output, or NULL154 const psImage *input, ///< extract profile from this image155 float x, ///< center x coord of annulii156 float y, ///< center y coord of annulii157 float radius, ///< outer radius of annulii158 float dr, ///< radial step size of annulii159 const psStats *stats ///< defines statistics used to find output values160 );161 162 /* Contour is a high-level function */163 #if 0164 /// Extract a 2-d contour from an image at the given threshold.165 psFloatArray *166 psImageContour(psFloatArray *out, ///< Vector to output, or NULL167 const psImage *input, ///< create contour for this image168 float threshold, ///< contour image at this threshold169 int binning ///< bin image by this value for contour calculation170 );171 104 #endif 172 173 /*** various image geometry manipulation ***/174 /// Rebin image to new scale.175 psImage *176 psImageRebin(psImage *out, ///< Image to output, or NULL177 const psImage *input, ///< rebin this image178 float scale, ///< rebinning scale: doutput = scale*dinput179 const psStats *stats ///< defines statistics used to find output values180 );181 182 /// Rotate image by given angle.183 psImage *184 psImageRotate(psImage *out, ///< Image to output, or NULL185 const psImage *input, ///< rotate this image186 float angle ///< rotate by this amount anti-clockwise (degrees)187 );188 189 /// Shift image by an arbitrary number of pixels in either direction.190 /// Drop edge pixels, and set newly exposed pixels to 'exposed'.191 psImage *192 psImageShift(psImage *out, ///< Image to output, or NULL193 const psImage *input, ///< shift this image194 float dx, ///< shift by this amount in x195 float dy, ///< shift by this amount in y196 float exposed ///< set exposed pixels to this value197 );198 199 /// Roll image by an integer number of pixels in either direction.200 /// Edge pixels wrap to the other side (no values are lost).201 psImage *202 psImageRoll(psImage *out, ///< Image to output, or NULL203 const psImage *input, ///< roll this image204 int dx, ///< roll this amount in x205 int dy ///< roll this amount in y206 );207 208 /// Determine statistics for image (or subimage).209 psStats *210 psImageGetStats(const psImage *input, ///< image (or subimage) to calculate stats211 psStats *stats ///< defines statistics to be calculated & target212 );213 214 /// Construct a histogram from an image (or subimage).215 psHistogram *216 psImageHistogram(psHistogram *hist, ///< input histogram description & target217 const psImage *input ///< determine histogram of this image218 );219 220 /// Fit a 2-D polynomial surface to an image.221 psPolynomial2D *222 psImageFitPolynomial(const psImage *input, ///< image to fit223 psPolynomial2D *coeffs ///< coefficient structure carries in desired terms & target224 );225 226 /// Evaluate a 2-D polynomial surface to image pixels.227 int228 psImageEvalPolynomial(const psImage *input, ///< image to fit229 const psPolynomial2D *coeffs ///< coefficient structure carries in desired terms230 );231 232 /*** image input/output routines ***/233 /// Read an image or subimage from a named file.234 psImage *235 psImageReadSection(psImage *output, ///< place data in this structure for output236 int x, ///< starting x coord of region237 int y, ///< starting y coord of region238 int nx, ///< x size of region (-1 for full range)239 int ny, ///< y size of region (-1 for full range)240 int z, ///< plane of interest241 const char *extname, ///< MEF extension name ("PHU" for primary header)242 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)243 const char *filename ///< file to read data from244 );245 246 /// Read an image or subimage from file descriptor.247 psImage *248 psImageFReadSection(psImage *output, ///< place data in this structure for output249 int x, ///< starting x coord of region250 int y, ///< starting y coord of region251 int nx, ///< x size of region (-1 for full range)252 int ny, ///< y size of region (-1 for full range)253 int z, ///< plane of interest254 const char *extname, ///< MEF extension name ("PHU" for primary header)255 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)256 FILE *f ///< file descriptor to read data from257 );258 259 /// Write an image section to named file (which may exist).260 psImage *261 psImageWriteSection(psImage *input, ///< image to write out262 int x, ///< starting x coord of region263 int y, ///< starting y coord of region264 int z, ///< plane of interest265 const char *extname, ///< MEF extension name ("PHU" for primary header)266 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)267 const char *filename ///< file to write data to268 );269 270 /// Write an image section to named file (which may exist).271 psImage *272 psImageFWriteSection(psImage *input, ///< image to write out273 int x, ///< starting x coord of region274 int y, ///< starting y coord of region275 int z, ///< plane of interest276 const char *extname, ///< MEF extension name277 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)278 FILE *f ///< file descriptor to write data to279 );280 281 /// Read only header from image file.282 psMetadata *283 psImageReadHeader(psMetadata *output, ///< read data to this structure284 const char *extname, ///< MEF extension name ("PHU" for primary header)285 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)286 const char *filename ///< file to read from287 );288 289 /// Read only header from image file descriptor.290 psMetadata *291 psImageFReadHeader(psMetadata *output, ///< read data to this structure292 const char *extname, ///< MEF extension name ("PHU" for primary header)293 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)294 FILE *f ///< file descriptor to read from295 );296 297 /*** basic pixel manipulations ***/298 /// Clip image values outside of range to given values. Return number of clipped pixels.299 int300 psImageClip(psImage *input, ///< clip this image301 float min, ///< clip pixels with values < min302 float vmin, ///< set min-clipped pixels to vmin303 float max, ///< clip pixels with values > max304 float vmax ///< set max-clipped pixels to vmax305 );306 307 /// Clip NaN image pixels to given value. Return number of clipped pixels.308 int309 psImageClipNaN(psImage *input, ///< clip this image & target310 float value ///< set nan pixels to this value311 );312 313 /// Overlay subregion of image with another image. Return number of pixels replaced.314 int315 psImageOverlaySection(psImage *image, ///< input image & target316 const psImage *overlay, ///< image to overlay317 int x0, ///< x offset of overlay subimage318 int y0, ///< y offset of overlay subimage319 const char *op ///< overlay operation320 );321 322 /* \} */ // End of AstroGroup Functions323 324 # endif325 /* image overlay operations326 PS_OVERLAY_EQUALS = '=',327 PS_OVERLAY_ADD = '+',328 PS_OVERLAY_SUBTRACT = '-',329 PS_OVERLAY_MULTIPLY = '*',330 PS_OVERLAY_DIVIDE = '/',331 */ -
trunk/psLib/src/mathtypes/psImage.c
r599 r633 7 7 * @author Ross Harman, MHPCC 8 8 * 9 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-05- 07 02:56:52 $9 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-05-10 20:20:42 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 17 17 /******************************************************************************/ 18 18 #include "psMemory.h" 19 #include "psError.h" 19 20 #include "psArray.h" 21 #include "psImage.h" 20 22 21 23 /******************************************************************************/ … … 53 55 /*****************************************************************************/ 54 56 55 psImage *psImageAlloc(int n x, int ny, psType type)57 psImage *psImageAlloc(int nCols, int nRows, psType type) 56 58 { 57 59 psImage *image = NULL; 58 60 59 psImage = psAlloc(psImage);60 psImage->type = type;61 psImage->nx = nx;62 psImage->ny = ny;63 psImage->x0 = 0;64 psImage->y0 = 0;65 psImage->parent = NULL;66 psImage->nChildren = 0;67 psImage->children = NULL;61 image = psAlloc(sizeof(psImage)); 62 image->type = type; 63 image->nCols = nCols; 64 image->nRows = nRows; 65 image->col0 = 0; 66 image->row0 = 0; 67 image->parent = NULL; 68 image->nChildren = 0; 69 image->children = NULL; 68 70 69 71 switch(type.type) { 70 72 case PS_TYPE_SHORT: 71 image->rows.rows_s i = psAlloc(nx*ny*sizeof(short));73 image->rows.rows_s = psAlloc(nCols*nRows*sizeof(short)); 72 74 break; 73 75 case PS_TYPE_INT: 74 image->rows.rows_i = psAlloc(n x*ny*sizeof(int));76 image->rows.rows_i = psAlloc(nCols*nRows*sizeof(int)); 75 77 break; 76 78 case PS_TYPE_LONG: 77 image->rows.rows_l i = psAlloc(nx*ny*sizeof(long));79 image->rows.rows_l = psAlloc(nCols*nRows*sizeof(long)); 78 80 break; 79 81 case PS_TYPE_USHORT: 80 image->rows.rows_us = psAlloc(n x*ny*sizeof(unsigned short));82 image->rows.rows_us = psAlloc(nCols*nRows*sizeof(unsigned short)); 81 83 break; 82 84 case PS_TYPE_UINT: 83 image->rows.rows_ui = psAlloc(n x*ny*sizeof(unsigned int));85 image->rows.rows_ui = psAlloc(nCols*nRows*sizeof(unsigned int)); 84 86 break; 85 87 case PS_TYPE_ULONG: 86 image->rows.rows_ul = psAlloc(n x*ny*sizeof(unsigned long));88 image->rows.rows_ul = psAlloc(nCols*nRows*sizeof(unsigned long)); 87 89 break; 88 90 case PS_TYPE_FLOAT: 89 image->rows.rows_f = psAlloc(n x*ny*sizeof(float));91 image->rows.rows_f = psAlloc(nCols*nRows*sizeof(float)); 90 92 break; 91 93 case PS_TYPE_DOUBLE: 92 image->rows.rows_d = psAlloc(n x*ny*sizeof(double));94 image->rows.rows_d = psAlloc(nCols*nRows*sizeof(double)); 93 95 break; 94 96 case PS_TYPE_COMPLEX: 95 image->rows.rows_cf = psAlloc(nx*ny*sizeof(complex float)); 96 break; 97 case PS_TYPE_OTHER: 98 psError(__func__, " : Line %d - Invalid psBitMask binary operation: %s\n", __LINE__); 97 image->rows.rows_cf = psAlloc(nCols*nRows*sizeof(complex float)); 99 98 break; 100 99 default: 101 psError(__func__, " : Line %d - Invalid ps BitMask binary operation: %s\n", __LINE__);100 psError(__func__, " : Line %d - Invalid psImage type: %d\n", __LINE__, type.type); 102 101 } 103 102 103 return image; 104 } 104 105 106 void psImageFree(psImage *image) 107 { 108 int i = 0; 109 int nChildren = 0; 110 psElemType imageType = 0; 111 psImage *children = NULL; 112 113 if(image != NULL) { 114 imageType = image->type.type; 115 nChildren = image->nChildren; 116 children = image->children; 117 118 switch(imageType) { 119 case PS_TYPE_SHORT: 120 psFree(image->rows.rows_s); 121 break; 122 case PS_TYPE_INT: 123 psFree(image->rows.rows_i); 124 break; 125 case PS_TYPE_LONG: 126 psFree(image->rows.rows_l); 127 break; 128 case PS_TYPE_USHORT: 129 psFree(image->rows.rows_us); 130 break; 131 case PS_TYPE_UINT: 132 psFree(image->rows.rows_ui); 133 break; 134 case PS_TYPE_ULONG: 135 psFree(image->rows.rows_ul); 136 break; 137 case PS_TYPE_FLOAT: 138 psFree(image->rows.rows_f); 139 break; 140 case PS_TYPE_DOUBLE: 141 psFree(image->rows.rows_d); 142 break; 143 case PS_TYPE_COMPLEX: 144 psFree(image->rows.rows_cf); 145 break; 146 case PS_TYPE_OTHER: 147 psError(__func__, " : Line %d - Can't delete images of type PS_TYPE_OTHER\n", __LINE__); 148 break; 149 default: 150 psError(__func__, " : Line %d - Invalid psImage type: %d\n", __LINE__, imageType); 151 } 152 153 for(i=0; i<nChildren; i++) { 154 psImageFree(children); 155 } 156 } 105 157 } -
trunk/psLib/src/mathtypes/psImage.h
r599 r633 7 7 * @author Ross Harman, MHPCC 8 8 * 9 * @version $Revision: 1. 2$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-05- 07 02:56:52 $9 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-05-10 20:20:42 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 36 36 { 37 37 psType type; ///< Image data type and dimension. 38 int nx, ny; ///< Size of image. 39 int x0, y0; ///< Data region relative to parent. 38 int nCols; ///< Number of rows in image 39 int nRows; ///< Number of columns in image. 40 int col0; ///< Row position relative to parent. 41 int row0; ///< Column position relative to parent. 40 42 union { 41 float **rows ///< Pointers to floating point data (default).42 43 short **rows_s; ///< Pointers to short integer data. 43 44 int **rows_i; ///< Pointers to integer data. … … 46 47 unsigned int **rows_ui; ///< Pointers to unsigned integer data. 47 48 unsigned long **rows_ul; ///< Pointers to unsigned long integer data. 48 float **rows_f ///< Pointers to floating point data.49 double **rows_d ///< Pointers to double precision data.50 complex float **rows_cf ///< Pointers to complex floating point data.49 float **rows_f; ///< Pointers to floating point data. 50 double **rows_d; ///< Pointers to double precision data. 51 complex float **rows_cf; ///< Pointers to complex floating point data. 51 52 } rows; ///< Union for data types. 52 53 struct psImage *parent; ///< Parent, if a subimage. … … 69 70 */ 70 71 psImage *psImageAlloc( 71 int n x, ///< Image width.72 int n y, ///< Image height.73 psType type ///< Image data type.72 int nCols, ///< Number of rows in image. 73 int nRows, ///< Number of columns in image. 74 psType type ///< Type of data for image. 74 75 ); 75 76 … … 84 85 psImage *out, ///< Subimage to return, or NULL. 85 86 const psImage *image, ///< Parent image. 86 int n x, ///< Subimage width (<= image.nx - x0).87 int n y, ///< Subimage width (<= image.ny - y0).88 int x0, ///< Subimage x-offset (0 <= x0 < nx).89 int y0 ///< Subimage y-offset (0 <= y0 < ny).87 int nCols, ///< Subimage width (<= image.nCols - col0). 88 int nRows, ///< Subimage height (<= image.nRows - row0). 89 int col0, ///< Subimage col-offset (0 <= col0 < nCol). 90 int row0 ///< Subimage row-offset (0 <= row0 < nCol). 90 91 ); 91 92 … … 98 99 */ 99 100 void psImageFree( 100 psImage *restrict image ///< free this image101 psImage *restrict image ///< Free psImage 101 102 ); 102 103 103 104 105 // DOXYGEN COMMENTING FORMAT NOT YET FULLY IMPLEMENTED BEYOND THIS POINT106 107 108 109 /** Destroy the pixels of the specified image */110 psImage *111 psImageFreePixels(psImage *restrict image ///< Image whose pixels are to be freed112 );113 114 /// Destroy the children of the specified image. Returns number of children freed.115 int116 psImageFreeChildren(const psImage *image ///< free children of this image117 );118 119 /// Create a copy of the specified image.120 psImage *121 psImageCopy(psImage *output, ///< target structure for output image data122 const psImage *input ///< copy this image123 );124 125 /*** various image pixel extractions ***/126 127 /// Extract pixels from rectlinear region to a vector.128 psFloatArray *129 psImageSlice(psFloatArray *out, ///< Vector to output, or NULL130 const psImage *input, ///< extract slice from this image131 int x, ///< starting x coord of region to slice132 int y, ///< starting y coord of region to slice133 int nx, ///< width of region in x134 int ny, ///< width of region in y135 int direction, ///< direction of vector along slice136 const psStats *stats ///< defines statistics used to find output values137 );138 139 /// Extract pixels along a line to a vector.140 psFloatArray *141 psImageCut(psFloatArray *out, ///< Vector to output, or NULL142 const psImage *input, ///< extract cut from this image143 float xs, ///< starting x coord of cut144 float ys, ///< starting y coord of cut145 float xe, ///< ending x coord of cut146 float ye, ///< ending y coord of cut147 float dw, ///< width of cut148 const psStats *stats ///< defines statistics used to find output values149 );150 151 /// Extract radial annulii data to a vector.152 psFloatArray *153 psImageRadialCut(psFloatArray *out, ///< Vector to output, or NULL154 const psImage *input, ///< extract profile from this image155 float x, ///< center x coord of annulii156 float y, ///< center y coord of annulii157 float radius, ///< outer radius of annulii158 float dr, ///< radial step size of annulii159 const psStats *stats ///< defines statistics used to find output values160 );161 162 /* Contour is a high-level function */163 #if 0164 /// Extract a 2-d contour from an image at the given threshold.165 psFloatArray *166 psImageContour(psFloatArray *out, ///< Vector to output, or NULL167 const psImage *input, ///< create contour for this image168 float threshold, ///< contour image at this threshold169 int binning ///< bin image by this value for contour calculation170 );171 104 #endif 172 173 /*** various image geometry manipulation ***/174 /// Rebin image to new scale.175 psImage *176 psImageRebin(psImage *out, ///< Image to output, or NULL177 const psImage *input, ///< rebin this image178 float scale, ///< rebinning scale: doutput = scale*dinput179 const psStats *stats ///< defines statistics used to find output values180 );181 182 /// Rotate image by given angle.183 psImage *184 psImageRotate(psImage *out, ///< Image to output, or NULL185 const psImage *input, ///< rotate this image186 float angle ///< rotate by this amount anti-clockwise (degrees)187 );188 189 /// Shift image by an arbitrary number of pixels in either direction.190 /// Drop edge pixels, and set newly exposed pixels to 'exposed'.191 psImage *192 psImageShift(psImage *out, ///< Image to output, or NULL193 const psImage *input, ///< shift this image194 float dx, ///< shift by this amount in x195 float dy, ///< shift by this amount in y196 float exposed ///< set exposed pixels to this value197 );198 199 /// Roll image by an integer number of pixels in either direction.200 /// Edge pixels wrap to the other side (no values are lost).201 psImage *202 psImageRoll(psImage *out, ///< Image to output, or NULL203 const psImage *input, ///< roll this image204 int dx, ///< roll this amount in x205 int dy ///< roll this amount in y206 );207 208 /// Determine statistics for image (or subimage).209 psStats *210 psImageGetStats(const psImage *input, ///< image (or subimage) to calculate stats211 psStats *stats ///< defines statistics to be calculated & target212 );213 214 /// Construct a histogram from an image (or subimage).215 psHistogram *216 psImageHistogram(psHistogram *hist, ///< input histogram description & target217 const psImage *input ///< determine histogram of this image218 );219 220 /// Fit a 2-D polynomial surface to an image.221 psPolynomial2D *222 psImageFitPolynomial(const psImage *input, ///< image to fit223 psPolynomial2D *coeffs ///< coefficient structure carries in desired terms & target224 );225 226 /// Evaluate a 2-D polynomial surface to image pixels.227 int228 psImageEvalPolynomial(const psImage *input, ///< image to fit229 const psPolynomial2D *coeffs ///< coefficient structure carries in desired terms230 );231 232 /*** image input/output routines ***/233 /// Read an image or subimage from a named file.234 psImage *235 psImageReadSection(psImage *output, ///< place data in this structure for output236 int x, ///< starting x coord of region237 int y, ///< starting y coord of region238 int nx, ///< x size of region (-1 for full range)239 int ny, ///< y size of region (-1 for full range)240 int z, ///< plane of interest241 const char *extname, ///< MEF extension name ("PHU" for primary header)242 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)243 const char *filename ///< file to read data from244 );245 246 /// Read an image or subimage from file descriptor.247 psImage *248 psImageFReadSection(psImage *output, ///< place data in this structure for output249 int x, ///< starting x coord of region250 int y, ///< starting y coord of region251 int nx, ///< x size of region (-1 for full range)252 int ny, ///< y size of region (-1 for full range)253 int z, ///< plane of interest254 const char *extname, ///< MEF extension name ("PHU" for primary header)255 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)256 FILE *f ///< file descriptor to read data from257 );258 259 /// Write an image section to named file (which may exist).260 psImage *261 psImageWriteSection(psImage *input, ///< image to write out262 int x, ///< starting x coord of region263 int y, ///< starting y coord of region264 int z, ///< plane of interest265 const char *extname, ///< MEF extension name ("PHU" for primary header)266 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)267 const char *filename ///< file to write data to268 );269 270 /// Write an image section to named file (which may exist).271 psImage *272 psImageFWriteSection(psImage *input, ///< image to write out273 int x, ///< starting x coord of region274 int y, ///< starting y coord of region275 int z, ///< plane of interest276 const char *extname, ///< MEF extension name277 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)278 FILE *f ///< file descriptor to write data to279 );280 281 /// Read only header from image file.282 psMetadata *283 psImageReadHeader(psMetadata *output, ///< read data to this structure284 const char *extname, ///< MEF extension name ("PHU" for primary header)285 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)286 const char *filename ///< file to read from287 );288 289 /// Read only header from image file descriptor.290 psMetadata *291 psImageFReadHeader(psMetadata *output, ///< read data to this structure292 const char *extname, ///< MEF extension name ("PHU" for primary header)293 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)294 FILE *f ///< file descriptor to read from295 );296 297 /*** basic pixel manipulations ***/298 /// Clip image values outside of range to given values. Return number of clipped pixels.299 int300 psImageClip(psImage *input, ///< clip this image301 float min, ///< clip pixels with values < min302 float vmin, ///< set min-clipped pixels to vmin303 float max, ///< clip pixels with values > max304 float vmax ///< set max-clipped pixels to vmax305 );306 307 /// Clip NaN image pixels to given value. Return number of clipped pixels.308 int309 psImageClipNaN(psImage *input, ///< clip this image & target310 float value ///< set nan pixels to this value311 );312 313 /// Overlay subregion of image with another image. Return number of pixels replaced.314 int315 psImageOverlaySection(psImage *image, ///< input image & target316 const psImage *overlay, ///< image to overlay317 int x0, ///< x offset of overlay subimage318 int y0, ///< y offset of overlay subimage319 const char *op ///< overlay operation320 );321 322 /* \} */ // End of AstroGroup Functions323 324 # endif325 /* image overlay operations326 PS_OVERLAY_EQUALS = '=',327 PS_OVERLAY_ADD = '+',328 PS_OVERLAY_SUBTRACT = '-',329 PS_OVERLAY_MULTIPLY = '*',330 PS_OVERLAY_DIVIDE = '/',331 */
Note:
See TracChangeset
for help on using the changeset viewer.
