IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 151


Ignore:
Timestamp:
Mar 9, 2004, 12:05:49 PM (22 years ago)
Author:
eugene
Message:

updated for doxygen support

Location:
trunk/archive/pslib/include
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/pslib/include/psImages.h

    r150 r151  
    22# define PS_IMAGES_H
    33
    4 /* General image manipulation functions
     4/** General image manipulation functions.
    55 */
    66
    7 // image data type names
     7/// image data type names.
    88typedef enum {
    99    PS_U8  = 1,
     
    1414} PS_IMAGE_DEPTH;
    1515
    16 // overlay operations
    17 typedef enum {
     16PS_DECLARE_ARRAY_TYPE(psFloatArray);    ///< Declare an array of real vectors (psFloatArrayArray).
     17PS_CREATE_ARRAY_TYPE(psFloatArray);     ///< Create the data type (psFloatArrayArray).
     18
     19typedef unsigned char  psU8;            ///< BITPIX 8   (unsigned short)
     20typedef unsigned short psU16;           ///< BITPIX 16  (unsigned int)
     21typedef unsigned long  psU32;           ///< BITPIX 32  (unsigned long)
     22typedef float          psF32;           ///< BITPIX -32 (float)
     23typedef double         psF64;           ///< BITPIX -64 (double)
     24
     25/// basic image data structure.
     26typedef 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.
     45psImage *
     46psAllocImage (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.
     52psImage *
     53psSubsetImage (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).
     61void
     62psFreeImage (psImage *image             ///< free this image
     63);
     64
     65/// Destroy the children of the specified image.
     66int
     67psFreeImageChildren (psImage *image     ///< free children of this image
     68);
     69
     70/// Create a copy of the specified image.
     71psImage *
     72psCopyImage (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.
     78psFloatArray *
     79psSliceImage (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.
     89psFloatArray *
     90psCutImage (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.
     100psFloatArray *
     101psRadialCutImage (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.
     110psFloatArrayArray *
     111psContourImage (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.
     117psSpanArray *
     118psContourImage (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.
     124psImage *
     125psRebinImage (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.
     131psImage *
     132psRotateImage (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'.
     138psImage *
     139psShiftImage (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).
     147psImage *
     148psRollImage (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?
     156void
     157psStatImage (psImage *input, enum statmode);
     158
     159/// Construct a histogram from an image (or subimage).
     160psHistogram *
     161psHistogramImage (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.
     166psFloatArrayArray *
     167psFitPolynomialImage (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.
     174psImage *
     175psReadImageSection (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.
     186psImage *
     187psFReadImageSection (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).
     198psImage *
     199psWriteImageSection (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).
     208psImage *
     209psFWriteImageSection (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.
     218psMetadata *
     219psReadImageHeader (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.
     225psMetadata *
     226psReadImageHeader (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.
     233psImage *
     234psFFTImage (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.
     240int
     241psClipImage (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.
     249int
     250psClipNaNImage (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.
     256psImage *
     257psImageBinaryOp (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.
     264psImage *
     265psImageUnaryOp (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.
     271int
     272psOverlayImage (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
    18282    PS_OVERLAY_EQUALS   = '=',
    19283    PS_OVERLAY_ADD      = '+',
     
    21285    PS_OVERLAY_MULTIPLY = '*',
    22286    PS_OVERLAY_DIVIDE   = '/',
    23 } PS_OVERLAY_OP;
    24 
    25 // binary operations (image / vector?)
    26 typedef enum {
     287
    27288    PS_BINARY_ADD        = '+',
    28289    PS_BINARY_SUBTRACT   = '-',
     
    44305    PS_BINARY_XOR        = '~',
    45306    PS_BINARY_ATAN2      = 'atan2',
    46 } PS_BINARY_OP;
    47 
    48 // unary image operations
    49 typedef enum {
     307
    50308    PS_UNARY_IS     = '=',
    51309    PS_UNARY_ABS,
     
    75333    PS_UNARY_ISINF,
    76334    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.