IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 10, 2004, 10:20:42 AM (22 years ago)
Author:
harman
Message:

Added psAlloc alloc and free functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/image/psImage.h

    r599 r633  
    77 *  @author Ross Harman, MHPCC
    88 *   
    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 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3636{
    3737    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.
    4042    union {
    41         float **rows                ///< Pointers to floating point data (default).
    4243        short **rows_s;             ///< Pointers to short integer data.
    4344        int **rows_i;               ///< Pointers to integer data.
     
    4647        unsigned int **rows_ui;     ///< Pointers to unsigned integer data.
    4748        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.
    5152    } rows;                         ///< Union for data types.
    5253    struct psImage *parent;         ///< Parent, if a subimage.
     
    6970 */
    7071psImage *psImageAlloc(
    71     int nx,     ///< Image width.
    72     int ny,     ///< 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.
    7475);
    7576
     
    8485    psImage *out,           ///< Subimage to return, or NULL.
    8586    const psImage *image,   ///< Parent image.
    86     int nx,                 ///< Subimage width (<= image.nx - x0).
    87     int ny,                 ///< 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).
    9091);
    9192
     
    9899 */
    99100void psImageFree(
    100     psImage *restrict image ///< free this image
     101    psImage *restrict image ///< Free psImage
    101102);
    102103
    103 
    104 
    105 // DOXYGEN COMMENTING FORMAT NOT YET FULLY IMPLEMENTED BEYOND THIS POINT
    106 
    107 
    108 
    109 /** Destroy the pixels of the specified image */
    110 psImage *
    111 psImageFreePixels(psImage *restrict image ///< Image whose pixels are to be freed
    112                  );
    113 
    114 /// Destroy the children of the specified image.  Returns number of children freed.
    115 int
    116 psImageFreeChildren(const psImage *image ///< free children of this image
    117                    );
    118 
    119 /// Create a copy of the specified image.
    120 psImage *
    121 psImageCopy(psImage *output,   ///< target structure for output image data
    122             const psImage *input ///< copy this image
    123            );
    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 NULL
    130              const psImage *input, ///< extract slice from this image
    131              int x,    ///< starting x coord of region to slice
    132              int y,    ///< starting y coord of region to slice
    133              int nx,    ///< width of region in x
    134              int ny,    ///< width of region in y
    135              int direction,  ///< direction of vector along slice
    136              const psStats *stats ///< defines statistics used to find output values
    137             );
    138 
    139 /// Extract pixels along a line to a vector.
    140 psFloatArray *
    141 psImageCut(psFloatArray *out,  ///< Vector to output, or NULL
    142            const psImage *input, ///< extract cut from this image
    143            float xs,    ///< starting x coord of cut
    144            float ys,    ///< starting y coord of cut
    145            float xe,    ///< ending x coord of cut
    146            float ye,    ///< ending y coord of cut
    147            float dw,    ///< width of cut
    148            const psStats *stats  ///< defines statistics used to find output values
    149           );
    150 
    151 /// Extract radial annulii data to a vector.
    152 psFloatArray *
    153 psImageRadialCut(psFloatArray *out, ///< Vector to output, or NULL
    154                  const psImage *input, ///< extract profile from this image
    155                  float x,   ///< center x coord of annulii
    156                  float y,   ///< center y coord of annulii
    157                  float radius,  ///< outer radius of annulii
    158                  float dr,  ///< radial step size of annulii
    159                  const psStats *stats ///< defines statistics used to find output values
    160                 );
    161 
    162 /* Contour is a high-level function */
    163 #if 0
    164 /// Extract a 2-d contour from an image at the given threshold.
    165 psFloatArray *
    166 psImageContour(psFloatArray *out, ///< Vector to output, or NULL
    167                const psImage *input,  ///< create contour for this image
    168                float threshold, ///< contour image at this threshold
    169                int binning  ///< bin image by this value for contour calculation
    170               );
    171104#endif
    172 
    173 /*** various image geometry manipulation ***/
    174 /// Rebin image to new scale.
    175 psImage *
    176 psImageRebin(psImage *out,  ///< Image to output, or NULL
    177              const psImage *input, ///< rebin this image
    178              float scale,   ///< rebinning scale: doutput = scale*dinput
    179              const psStats *stats ///< defines statistics used to find output values
    180             );
    181 
    182 /// Rotate image by given angle.
    183 psImage *
    184 psImageRotate(psImage *out,  ///< Image to output, or NULL
    185               const psImage *input, ///< rotate this image
    186               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 NULL
    193              const psImage *input, ///< shift this image
    194              float dx,   ///< shift by this amount in x
    195              float dy,   ///< shift by this amount in y
    196              float exposed  ///< set exposed pixels to this value
    197             );
    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 NULL
    203             const psImage *input, ///< roll this image
    204             int dx,    ///< roll this amount in x
    205             int dy   ///< roll this amount in y
    206            );
    207 
    208 /// Determine statistics for image (or subimage).
    209 psStats *
    210 psImageGetStats(const psImage *input,  ///< image (or subimage) to calculate stats
    211                 psStats *stats  ///< defines statistics to be calculated & target
    212                );
    213 
    214 /// Construct a histogram from an image (or subimage).
    215 psHistogram *
    216 psImageHistogram(psHistogram *hist, ///< input histogram description & target
    217                  const psImage *input ///< determine histogram of this image
    218                 );
    219 
    220 /// Fit a 2-D polynomial surface to an image.
    221 psPolynomial2D *
    222 psImageFitPolynomial(const psImage *input, ///< image to fit
    223                      psPolynomial2D *coeffs ///< coefficient structure carries in desired terms & target
    224                     );
    225 
    226 /// Evaluate a 2-D polynomial surface to image pixels.
    227 int
    228 psImageEvalPolynomial(const psImage *input, ///< image to fit
    229                       const psPolynomial2D *coeffs ///< coefficient structure carries in desired terms
    230                      );
    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 output
    236                    int x,   ///< starting x coord of region
    237                    int y,   ///< starting y coord of region
    238                    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 interest
    241                    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 from
    244                   );
    245 
    246 /// Read an image or subimage from file descriptor.
    247 psImage *
    248 psImageFReadSection(psImage *output, ///< place data in this structure for output
    249                     int x,  ///< starting x coord of region
    250                     int y,  ///< starting y coord of region
    251                     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 interest
    254                     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 from
    257                    );
    258 
    259 /// Write an image section to named file (which may exist).
    260 psImage *
    261 psImageWriteSection(psImage *input,    ///< image to write out
    262                     int x,   ///< starting x coord of region
    263                     int y,   ///< starting y coord of region
    264                     int z,   ///< plane of interest
    265                     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 to
    268                    );
    269 
    270 /// Write an image section to named file (which may exist).
    271 psImage *
    272 psImageFWriteSection(psImage *input, ///< image to write out
    273                      int x,   ///< starting x coord of region
    274                      int y,   ///< starting y coord of region
    275                      int z,   ///< plane of interest
    276                      const char *extname, ///< MEF extension name
    277                      int extnum,  ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)
    278                      FILE *f  ///< file descriptor to write data to
    279                     );
    280 
    281 /// Read only header from image file.
    282 psMetadata *
    283 psImageReadHeader(psMetadata *output, ///< read data to this structure
    284                   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 from
    287                  );
    288 
    289 /// Read only header from image file descriptor.
    290 psMetadata *
    291 psImageFReadHeader(psMetadata *output, ///< read data to this structure
    292                    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 from
    295                   );
    296 
    297 /*** basic pixel manipulations ***/
    298 /// Clip image values outside of range to given values.  Return number of clipped pixels.
    299 int
    300 psImageClip(psImage *input,   ///< clip this image
    301             float min,   ///< clip pixels with values < min
    302             float vmin,   ///< set min-clipped pixels to vmin
    303             float max,   ///< clip pixels with values > max
    304             float vmax   ///< set max-clipped pixels to vmax
    305            );
    306 
    307 /// Clip NaN image pixels to given value.  Return number of clipped pixels.
    308 int
    309 psImageClipNaN(psImage *input,  ///< clip this image & target
    310                float value  ///< set nan pixels to this value
    311               );
    312 
    313 /// Overlay subregion of image with another image.  Return number of pixels replaced.
    314 int
    315 psImageOverlaySection(psImage *image, ///< input image & target
    316                       const psImage *overlay, ///< image to overlay
    317                       int x0,  ///< x offset of overlay subimage
    318                       int y0,  ///< y offset of overlay subimage
    319                       const char *op ///< overlay operation
    320                      );
    321 
    322 /* \} */ // End of AstroGroup Functions
    323 
    324 # endif
    325 /* image overlay operations
    326     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.