Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

psPixels.h

Go to the documentation of this file.
00001 /** @file  psPixels.h
00002  *
00003  *  @brief Contains psPixel related functions
00004  *
00005  *  @ingroup Image
00006  *
00007  *  @author Robert DeSonia, MHPCC
00008  *
00009  *  @version $Revision: 1.17 $ $Name: rel9_0 $
00010  *  @date $Date: 2005/11/16 23:06:35 $
00011  *
00012  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00013  */
00014 #ifndef PS_PIXELS_H
00015 #define PS_PIXELS_H
00016 
00017 #include "psImage.h"
00018 #include "psVector.h"
00019 
00020 /// @addtogroup Image
00021 /// @{
00022 
00023 /** Data structure for storing psPixel coordinates  */
00024 typedef struct
00025 {
00026     float x;                             ///< x coordinate
00027     float y;                             ///< y coordinate
00028 }
00029 psPixelCoord;
00030 
00031 /** list of pixel coordinates
00032  *
00033  *  Usually an image mask is the best way to carry information about what
00034  *  pixels mean what. However, in the case where the number of pixels in which
00035  *  we are interested is limited, it is more efficient to simply carry a list
00036  *  of pixels. An example of this is in the image combination code, where we
00037  *  want to perform an operation on a relatively small fraction of pixels, and
00038  *  it is inefficient to go through an entire mask image checking each pixel.
00039  *
00040  */
00041 typedef struct
00042 {
00043     long n;                            ///< Number in usa
00044     const long nalloc;                 ///< Number allocated
00045     psPixelCoord* data;                ///< The pixel coordinates
00046     void *lock;                        ///< Option lock for thread safety
00047 }
00048 psPixels;
00049 
00050 #define P_PSPIXELS_SET_NALLOC(pix,n) *(long*)&pix->nalloc = n
00051 
00052         /** Allocates a new psPixels structure
00053          *
00054          *  @return psPixels*   new psPixels
00055          */
00056         psPixels* psPixelsAlloc(
00057             long nalloc                       ///< the size of the coordinate vectors
00058         )
00059         ;
00060 
00061 /** Checks the type of a particular pointer.
00062  *
00063  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00064  *
00065  *  @return bool:       True if the pointer matches a psPixels structure, false otherwise.
00066  */
00067 bool psMemCheckPixels(
00068     psPtr ptr                          ///< the pointer whose type to check
00069 );
00070 
00071 
00072 /** resizes a psPixels structure
00073  *
00074  *  @return psPixels*   resized psPixels
00075  */
00076 psPixels* psPixelsRealloc(
00077     psPixels* pixels,                  ///< psPixels to resize, or NULL to create new psPixels
00078     long nalloc                       ///< the size of the coordinate vectors
00079 );
00080 
00081 /** Add a pixel location to a psPixels
00082  *
00083  *  @return psPixels*       psPixels with the value appended.
00084  */
00085 psPixels* p_psPixelsAppend(
00086     psPixels* pixels,                  ///< psPixels to append new coordinate to.  NULL creates a new one.
00087     long growth,
00088     ///< number of elements to grow the psPixels list, if necessary.  if growth < 1, 10 is used.
00089     float x,                             ///< x coordinate to append
00090     float y                              ///< y coordinate to append
00091 );
00092 
00093 /** Copies a psPixels object
00094  *
00095  *  Makes a deep copy of the data in a psPixels object.  Any data in the OUT
00096  *  parameter will be destroyed and OUT will be resized, if necessary.
00097  *
00098  *  @return psPixels*   a new psPixels that is a duplicate to IN
00099  */
00100 psPixels* psPixelsCopy(
00101     psPixels* out,                     ///< psPixels struct to recycle, or NULL
00102     const psPixels* pixels             ///< psPixels struct to copy
00103 );
00104 
00105 /** Generate a psImage from a psPixels
00106  *
00107  *  psPixelsToMask shall return an image of type U8 with the pixels lying
00108  *  within the specified region set to the maskVal. The out image shall be
00109  *  modified if supplied, or allocated and returned if NULL. The size of the
00110  *  output image shall be region->x1 - region->x0 by region->y1 - region->y0,
00111  *  with out->x0 = region->x0 and out->y0 = region->y0. In the event that
00112  *  either of pixels or region are NULL, the function shall generate an
00113  *  error and return NULL.
00114  *
00115  *  @return psImage*    generated mask image
00116  */
00117 psImage* psPixelsToMask(
00118     psImage* out,                      ///< psImage to recycle, or NULL
00119     const psPixels* pixels,            ///< list of pixels to use
00120     psRegion region,                   ///< region to define the output mask image
00121     psMaskType maskVal                 ///< the mask bit-values to act upon
00122 );
00123 
00124 /** Generate a psPixels from a mask psImage
00125  *
00126  *  psMaskToPixels shall return a psPixels consisting of the coordinates in
00127  *  the mask that match the maskVal. The out pixel list shall be modified if
00128  *  supplied, or allocated and returned if NULL. In hte event that mask is
00129  *  NULL, the function shall generate an error and return NULL.
00130  *
00131  *  @return psPixels*   generated psPixels pixel list
00132  */
00133 psPixels* psPixelsFromMask(
00134     psPixels *out,                     ///< psPixels to recycle, or NULL
00135     const psImage *mask,               ///< the input mask psImage
00136     psMaskType maskVal                 ///< the mask bit-values to act upon
00137 );
00138 
00139 /** Concatenates two psPixels
00140  *
00141  *  psPixelsConcatenate shall concatenate pixels onto out. In the event that
00142  *  out is NULL, a new psPixels shall be allocated, and the contents of
00143  *  pixels simply copied in. If pixels is NULL, the function shall generate
00144  *  an error and return NULL. The function shall take care to ensure that
00145  *  there are no duplicate pixels in out.
00146  *
00147  *  @return psPixels         Concatenated psPixel list
00148  */
00149 psPixels* psPixelsConcatenate(
00150     psPixels *out,                     ///< psPixels to recycle, or NULL
00151     const psPixels *pixels             ///< psPixels to append to OUT
00152 );
00153 
00154 /** Prints a psPixels to specified destination.
00155  *
00156  *  @return bool:    True if successful.
00157 */
00158 bool p_psPixelsPrint(
00159     FILE *fd,                          ///< destination file descriptor
00160     psPixels* pixels,                  ///< psPixels to print
00161     const char *name                   ///< printf-style format of header line
00162 );
00163 
00164 /** Sets the value of the the pixels array at the specified position to value.
00165  *
00166  *  A negative position means index from the end.
00167  *
00168  *  @return bool:       True if Successful, otherwise false.
00169 */
00170 bool psPixelsSet(
00171     psPixels *pixels,                  ///< pixels to set
00172     long position,                     ///< position to set
00173     psPixelCoord value                 ///< pixels value to be set
00174 );
00175 
00176 /** Returns the value of the pixels array at the specified position.
00177  *
00178  *  A negative position means index from the end.
00179  *
00180  *  @return psPixelCoord:       The value of the pixels at the specified position.
00181 */
00182 psPixelCoord psPixelsGet(
00183     const psPixels *pixels,            ///< input pixels from which to get
00184     long position                      ///< position to get
00185 );
00186 
00187 #endif // #ifndef PS_PIXELS_H

Generated on Tue Dec 6 17:18:42 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.2