Changeset 151
- Timestamp:
- Mar 9, 2004, 12:05:49 PM (22 years ago)
- Location:
- trunk/archive/pslib/include
- Files:
-
- 1 added
- 1 edited
-
Doxyfile (added)
-
psImages.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/pslib/include/psImages.h
r150 r151 2 2 # define PS_IMAGES_H 3 3 4 /* General image manipulation functions4 /** General image manipulation functions. 5 5 */ 6 6 7 // image data type names7 /// image data type names. 8 8 typedef enum { 9 9 PS_U8 = 1, … … 14 14 } PS_IMAGE_DEPTH; 15 15 16 // overlay operations 17 typedef enum { 16 PS_DECLARE_ARRAY_TYPE(psFloatArray); ///< Declare an array of real vectors (psFloatArrayArray). 17 PS_CREATE_ARRAY_TYPE(psFloatArray); ///< Create the data type (psFloatArrayArray). 18 19 typedef unsigned char psU8; ///< BITPIX 8 (unsigned short) 20 typedef unsigned short psU16; ///< BITPIX 16 (unsigned int) 21 typedef unsigned long psU32; ///< BITPIX 32 (unsigned long) 22 typedef float psF32; ///< BITPIX -32 (float) 23 typedef double psF64; ///< BITPIX -64 (double) 24 25 /// basic image data structure. 26 typedef struct psImage { 27 int nx, ny; ///< size of image 28 int x0, y0; ///< data region relative to parent 29 PS_IMAGE_DEPTH depth; ///< type of image 30 psF32 **rows; ///< == rows_f32 31 psU8 **rows_u8; ///< pointers to psU8 data 32 psU16 **rows_u16; ///< pointers to psU16 data 33 psU32 **rows_u32; ///< pointers to psU32 data 34 psF32 **rows_f32; ///< pointers to psF32 data 35 psF64 **rows_f64; ///< pointers to psF64 data 36 psImage *parent; ///< parent, if a subimage 37 psImage *children; ///< children of this region 38 int Nchildren; ///< number of subimages 39 psDlist md; ///< metadata associated with image 40 psObjectTable objtable; ///< objects associated with image 41 } psImage; 42 43 /*** Image structure manipulation ***/ 44 /// Create an image of the specified size and type. 45 psImage * 46 psAllocImage (int nx, ///< image width 47 int ny, ///< image height 48 PS_IMAGE_DEPTH depth ///< image depth 49 ); 50 51 /// Create a subimage of the specified area. 52 psImage * 53 psSubsetImage (psImage *image, ///< parent image 54 int nx, ///< subimage width (<= image.nx - x0) 55 int ny, ///< subimage width (<= image.ny - y0) 56 int x0, ///< subimage x-offset (0 <= x0 < nx) 57 int y0 ///< subimage y-offset (0 <= y0 < ny) 58 ); 59 60 /// Destroy the specified image (destroy children if they exist). 61 void 62 psFreeImage (psImage *image ///< free this image 63 ); 64 65 /// Destroy the children of the specified image. 66 int 67 psFreeImageChildren (psImage *image ///< free children of this image 68 ); 69 70 /// Create a copy of the specified image. 71 psImage * 72 psCopyImage (psImage *output, ///< target structure for output image data 73 psImage *input ///< copy this image 74 ); 75 76 /*** various image pixel extractions ***/ 77 /// Extract pixels from rectlinear region to a vector. 78 psFloatArray * 79 psSliceImage (psImage *input, ///< extract slice from this image 80 int x, ///< starting x coord of region to slice 81 int y, ///< starting y coord of region to slice 82 int nx, ///< width of region in x 83 int ny, ///< width of region in y 84 enum direction, ///< direction of vector along slice 85 enum statmode ///< statistic applied to pixel group to find output value 86 ); 87 88 /// Extract pixels along a line to a vector. 89 psFloatArray * 90 psCutImage (psImage *input, ///< extract cut from this image 91 float xs, ///< starting x coord of cut 92 float ys, ///< starting y coord of cut 93 float xe, ///< ending x coord of cut 94 float ye, ///< ending y coord of cut 95 float dw, ///< width of cut 96 enum statmode ///< statistic applied to pixel group to find output value 97 ); 98 99 /// Extract radial annulii data to a vector. 100 psFloatArray * 101 psRadialCutImage (psImage *input, ///< extract profile from this image 102 float x, ///< center x coord of annulii 103 float y, ///< center y coord of annulii 104 float radius, ///< outer radius of annulii 105 float dr, ///< radial step size of annulii 106 enum statmode ///< statistic applied to pixel group to find output value 107 ); 108 109 /// Extract a 2-d contour from an image at the given threshold. 110 psFloatArrayArray * 111 psContourImage (psImage *input, ///< create contour for this image 112 float threshold, ///< contour image at this threshold 113 int binning ///< bin image by this value for contour calculation 114 ); 115 116 /// Extract a 2-d contour from an image at the given threshold. 117 psSpanArray * 118 psContourImage (psImage *input, ///< create contour for this image 119 float threshold ///< image at this threshold 120 ); 121 122 /*** various image geometry manipulation ***/ 123 /// Rebin image to new scale. 124 psImage * 125 psRebinImage (psImage *input, ///< rebin this image 126 float scale, ///< rebinning scale: doutput = scale*dinput 127 enum statmode ///< statistic used in performing interpolation / summing 128 ); 129 130 /// Rotate image by given angle. 131 psImage * 132 psRotateImage (psImage *input, ///< rotate this image 133 float angle ///< rotate by this amount (degrees) 134 ); 135 136 /// Shift image by an arbitrary number of pixels in either direction. 137 /// Drop edge pixels, and set newly exposed pixels to 'exposed'. 138 psImage * 139 psShiftImage (psImage *input, ///< shift this image 140 float dx, ///< shift by this amount in x 141 float dy, ///< shift by this amount in y 142 float exposed ///< set exposed pixels to this value 143 ); 144 145 /// Roll image by an integer number of pixels in either direction. 146 /// Edge pixels wrap to the other side (no values are lost). 147 psImage * 148 psRollImage (psImage *input, ///< roll this image 149 int dx, ///< roll this amount in x 150 int dy ///< roll this amount in y 151 ); 152 153 /// Determine statistics for image (or subimage). 154 /// Should we have one function for all stats, or multiple functions? 155 /// How to represent the output values? 156 void 157 psStatImage (psImage *input, enum statmode); 158 159 /// Construct a histogram from an image (or subimage). 160 psHistogram * 161 psHistogramImage (psHistogram, ///< input histogram description & target 162 psImage *input, ///< determine histogram of this image 163 ); 164 165 /// Fit a 2-D polynomial surface to an image. 166 psFloatArrayArray * 167 psFitPolynomialImage (psImage *input, ///< image to fit 168 int xorder ///< order of polynomial in x-dir 169 int yorder ///< order of polynomial in y-dir 170 ); 171 172 /*** image input/output routines ***/ 173 /// Read an image or subimage from a named file. 174 psImage * 175 psReadImageSection (psImage *output, ///< place data in this structure for output 176 int x, ///< starting x coord of region 177 int y, ///< starting y coord of region 178 int dx, ///< x size of region (-1 for full range) 179 int dy, ///< y size of region (-1 for full range) 180 int z, ///< plane of interest 181 char *extname, ///< MEF extension name ("PHU" for primary header) 182 char *filename ///< file to read data from 183 ); 184 185 /// Read an image or subimage from file descriptor. 186 psImage * 187 psFReadImageSection (psImage *output, ///< place data in this structure for output 188 int x, ///< starting x coord of region 189 int y, ///< starting y coord of region 190 int dx, ///< x size of region (-1 for full range) 191 int dy, ///< y size of region (-1 for full range) 192 int z, ///< plane of interest 193 char *extname, ///< MEF extension name ("PHU" for primary header) 194 FILE *f ///< file descriptor to read data from 195 ); 196 197 /// Write an image section to named file (which may exist). 198 psImage * 199 psWriteImageSection (psImage *input, ///< image to write out 200 int x, ///< starting x coord of region 201 int y, ///< starting y coord of region 202 int z, ///< plane of interest 203 char *extname, ///< MEF extension name ("PHU" for primary header) 204 char *filename ///< file to write data to 205 ); 206 207 /// Write an image section to named file (which may exist). 208 psImage * 209 psFWriteImageSection (psImage *input, ///< image to write out 210 int x, ///< starting x coord of region 211 int y, ///< starting y coord of region 212 int z, ///< plane of interest 213 char *extname, ///< MEF extension name 214 FILE *f ///< file descriptor to write data to 215 ); 216 217 /// Read only header from image file. 218 psMetadata * 219 psReadImageHeader (psMetadata *output, ///< read data to this structure 220 char *extname, ///< MEF extension name ("PHU" for primary header) 221 char *filename ///< file to read from 222 ); 223 224 /// Read only header from image file descriptor. 225 psMetadata * 226 psReadImageHeader (psMetadata *output, ///< read data to this structure 227 char *extname, ///< MEF extension name ("PHU" for primary header) 228 FILE *f ///< file descriptor to read from 229 ); 230 231 /*** image FFT operations ***/ 232 /// Perform an FFT on the image. 233 psImage * 234 psFFTImage (psImage *input, ///< image to FFT 235 enum direction ///< FFT direction 236 ); 237 238 /*** basic pixel manipulations ***/ 239 /// Clip image values outside of range to given values. 240 int 241 psClipImage (psImage *input, ///< clip this image 242 float min, ///< clip pixels with values < min 243 float vmin, ///< set min-clipped pixels to vmin 244 float max, ///< clip pixels with values > max 245 float vmax ///< set max-clipped pixels to vmax 246 ); 247 248 /// Clip NaN image pixels to given value. 249 int 250 psClipNaNImage (psImage *input, ///< clip this image 251 float value ///< set nan pixels to this value 252 ); 253 254 /*** image arithmetic ***/ 255 /// Perform a binary operation on two images. 256 psImage * 257 psImageBinaryOp (psImage *out, ///< destination image (may be NULL) 258 psImage *in1, ///< first input image 259 char *operator, ///< operator 260 psImage *in2 ///< second input image 261 ); 262 263 /// Perform a unary operation on an image. 264 psImage * 265 psImageUnaryOp (psImage *out, ///< destination image (may be NULL) 266 psImage *in1, ///< input image 267 char *operator ///< operator 268 ); 269 270 /// Overlay subregion of image with another image. 271 int 272 psOverlayImage (psImage *image, ///< input image 273 psImage *overlay, ///< image to overlay 274 int x0, ///< x offset of overlay subimage 275 int y0, ///< y offset of overlay subimage 276 char *operator ///< overlay operation 277 ); 278 279 # endif 280 281 /** allowed operators for the different image functions 18 282 PS_OVERLAY_EQUALS = '=', 19 283 PS_OVERLAY_ADD = '+', … … 21 285 PS_OVERLAY_MULTIPLY = '*', 22 286 PS_OVERLAY_DIVIDE = '/', 23 } PS_OVERLAY_OP; 24 25 // binary operations (image / vector?) 26 typedef enum { 287 27 288 PS_BINARY_ADD = '+', 28 289 PS_BINARY_SUBTRACT = '-', … … 44 305 PS_BINARY_XOR = '~', 45 306 PS_BINARY_ATAN2 = 'atan2', 46 } PS_BINARY_OP; 47 48 // unary image operations 49 typedef enum { 307 50 308 PS_UNARY_IS = '=', 51 309 PS_UNARY_ABS, … … 75 333 PS_UNARY_ISINF, 76 334 PS_UNARY_ISNAN 77 } PS_UNARY_OP; 78 79 // An array of real vectors 80 PS_DECLARE_ARRAY_TYPE(psFloatArray); 81 PS_CREATE_ARRAY_TYPE(psFloatArray); 82 83 // image depth types 84 typedef unsigned char psU8; 85 typedef unsigned short psU16; 86 typedef unsigned long psU32; 87 typedef float psF32; 88 typedef double psF64; 89 90 // basic image data structure 91 typedef struct psImage { 92 int nx, ny; // size of image 93 int x0, y0; // data region relative to parent 94 PS_IMAGE_DEPTH depth; // type of image 95 psF32 **rows; // == rows_f32 96 psU8 **rows_u8; // pointers to psU8 data 97 psU16 **rows_u16; // pointers to psU16 data 98 psU32 **rows_u32; // pointers to psU32 data 99 psF32 **rows_f32; // pointers to psF32 data 100 psF64 **rows_f64; // pointers to psF64 data 101 psImage *parent; // parent, if a subimage 102 psImage *children; // children of this region 103 int Nchildren; // number of subimages 104 psDlist md; // metadata associated with image 105 psObjectTable objtable; // objects associated with image 106 } psImage; 107 108 /*** Image structure manipulation ***/ 109 // create an image of the specified size and type 110 psImage * 111 psAllocImage (int nx, // image width 112 int ny, // image height 113 PS_IMAGE_DEPTH depth // image depth 114 ); 115 116 // create a subimage of the specified area 117 psImage * 118 psSubsetImage (psImage *image, // parent image 119 int nx, // subimage width (<= image.nx - x0) 120 int ny, // subimage width (<= image.ny - y0) 121 int x0, // subimage x-offset (0 <= x0 < nx) 122 int y0 // subimage y-offset (0 <= y0 < ny) 123 ); 124 125 // destroy the specified image (destroy children if they exist) 126 void 127 psFreeImage (psImage *image // free this image 128 ); 129 130 // destroy the children of the specified image 131 int 132 psFreeImageChildren (psImage *image // free children of this image 133 ); 134 135 // create a copy of the specified image 136 psImage * 137 psCopyImage (psImage *output, // target structure for output image data 138 psImage *input // copy this image 139 ); 140 141 /*** various image pixel extractions ***/ 142 // extract pixels from rectlinear region to a vector 143 psFloatArray * 144 psSliceImage (psImage *input, // extract slice from this image 145 int x, // starting x coord of region to slice 146 int y, // starting y coord of region to slice 147 int nx, // width of region in x 148 int ny, // width of region in y 149 enum direction, // direction of vector along slice 150 enum statmode // statistic applied to pixel group to find output value 151 ); 152 153 // extract pixels along a line to a vector 154 psFloatArray * 155 psCutImage (psImage *input, // extract cut from this image 156 float xs, // starting x coord of cut 157 float ys, // starting y coord of cut 158 float xe, // ending x coord of cut 159 float ye, // ending y coord of cut 160 float dw, // width of cut 161 enum statmode // statistic applied to pixel group to find output value 162 ); 163 164 // extract radial annulii data to a vector 165 psFloatArray * 166 psRadialCutImage (psImage *input, // extract profile from this image 167 float x, // center x coord of annulii 168 float y, // center y coord of annulii 169 float radius, // outer radius of annulii 170 float dr, // radial step size of annulii 171 enum statmode // statistic applied to pixel group to find output value 172 ); 173 174 // extract a 2-d contour from an image at the given threshold 175 psFloatArrayArray * 176 psContourImage (psImage *input, // create contour for this image 177 float threshold, // contour image at this threshold 178 int binning // bin image by this value for contour calculation 179 ); 180 181 // extract a 2-d contour from an image at the given threshold 182 psSpanArray * 183 psContourImage (psImage *input, // create contour for this image 184 float threshold // image at this threshold 185 ); 186 187 /*** various image geometry manipulation ***/ 188 // rebin image to new scale 189 psImage * 190 psRebinImage (psImage *input, // rebin this image 191 float scale, // rebinning scale: doutput = scale*dinput 192 enum statmode // statistic used in performing interpolation / summing 193 ); 194 195 // rotate image by given angle 196 psImage * 197 psRotateImage (psImage *input, // rotate this image 198 float angle // rotate by this amount (degrees) 199 ); 200 201 // shift image by an arbitrary number of pixels in either direction 202 // edge pixels value and newly exposed pixels are set to 'exposed' 203 psImage * 204 psShiftImage (psImage *input, // shift this image 205 float dx, // shift by this amount in x 206 float dy, // shift by this amount in y 207 float exposed // set exposed pixels to this value 208 ); 209 210 // roll image by an integer number of pixels in either direction 211 // edge pixels wrap to the other side (no values are lost) 212 psImage * 213 psRollImage (psImage *input, // roll this image 214 int dx, // roll this amount in x 215 int dy // roll this amount in y 216 ); 217 218 // determine statistics for image (or subimage) 219 // should we have one function for all stats, or multiple functions? 220 // how to represent the output values? 221 void 222 psStatImage (psImage *input, enum statmode); 223 224 // construct a histogram from an image (or subimage) 225 psHistogram * 226 psHistogramImage (psHistogram, // input histogram description & target 227 psImage *input, // determine histogram of this image 228 ); 229 230 // fit a 2-D polynomial surface to an image 231 psFloatArrayArray * 232 psFitPolynomialImage (psImage *input, // image to fit 233 int xorder // order of polynomial in x-dir 234 int yorder // order of polynomial in y-dir 235 ); 236 237 /*** image input/output routines ***/ 238 // read an image or subimage from a named file 239 psImage * 240 psReadImageSection (psImage *output, // place data in this structure for output 241 int x, // starting x coord of region 242 int y, // starting y coord of region 243 int dx, // x size of region (-1 for full range) 244 int dy, // y size of region (-1 for full range) 245 int z, // plane of interest 246 char *extname, // MEF extension name ("PHU" for primary header) 247 char *filename // file to read data from 248 ); 249 250 // read an image or subimage from file descriptor 251 psImage * 252 psFReadImageSection (psImage *output, // place data in this structure for output 253 int x, // starting x coord of region 254 int y, // starting y coord of region 255 int dx, // x size of region (-1 for full range) 256 int dy, // y size of region (-1 for full range) 257 int z, // plane of interest 258 char *extname, // MEF extension name ("PHU" for primary header) 259 FILE *f // file descriptor to read data from 260 ); 261 262 // write an image section to named file (which may exist) 263 psImage * 264 psWriteImageSection (psImage *input, // image to write out 265 int x, // starting x coord of region 266 int y, // starting y coord of region 267 int z, // plane of interest 268 char *extname, // MEF extension name ("PHU" for primary header) 269 char *filename // file to write data to 270 ); 271 272 // write an image section to named file (which may exist) 273 psImage * 274 psFWriteImageSection (psImage *input, // image to write out 275 int x, // starting x coord of region 276 int y, // starting y coord of region 277 int z, // plane of interest 278 char *extname, // MEF extension name 279 FILE *f // file descriptor to write data to 280 ); 281 282 // read only header from image file 283 psMetadata * 284 psReadImageHeader (psMetadata *output, // read data to this structure 285 char *extname, // MEF extension name ("PHU" for primary header) 286 char *filename // file to read from 287 ); 288 289 // read only header from image file descriptor 290 psMetadata * 291 psReadImageHeader (psMetadata *output, // read data to this structure 292 char *extname, // MEF extension name ("PHU" for primary header) 293 FILE *f // file descriptor to read from 294 ); 295 296 /*** image FFT operations ***/ 297 psImage * 298 psFFTImage (psImage *input, // image to FFT 299 enum direction // FFT direction 300 ); 301 302 /*** basic pixel manipulations ***/ 303 // clip image values outside of range to given values 304 int 305 psClipImage (psImage *input, // clip this image 306 float min, // clip pixels with values < min 307 float vmin, // set min-clipped pixels to vmin 308 float max, // clip pixels with values > max 309 float vmax // set max-clipped pixels to vmax 310 ); 311 312 // clip NaN image pixels to given value 313 int 314 psClipNaNImage (psImage *input, // clip this image 315 float value // set nan pixels to this value 316 ); 317 318 /*** image arithmetic ***/ 319 // perform a binary operation on two images 320 psImage * 321 psImageBinaryOp (psImage *out, // destination image (may be NULL) 322 psImage *in1, // first input image 323 PS_BINARY_OP OP, // operator 324 psImage *in2 // second input image 325 ); 326 327 // perform a unary operation on an image 328 psImage * 329 psImageUnaryOp (psImage *out, // destination image (may be NULL) 330 psImage *in1, // input image 331 PS_UNARY_OP OP // operator 332 ); 333 334 // overlay subregion of image with another image 335 int 336 psOverlayImage (psImage *image, // input image 337 psImage *overlay, // image to overlay 338 int x0, // x offset of overlay subimage 339 int y0, // y offset of overlay subimage 340 PS_OVERLAY_OP op // overlay operation 341 ); 342 343 # endif 335 **/
Note:
See TracChangeset
for help on using the changeset viewer.
