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.1.1.1 $ $Name: $ 00010 * @date $Date: 2005/09/14 20:42:48 $ 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 int x; ///< x coordinate 00027 int 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 00051 /** Allocates a new psPixels structure 00052 * 00053 * @return psPixels* new psPixels 00054 */ 00055 psPixels* psPixelsAlloc( 00056 long nalloc ///< the size of the coordinate vectors 00057 ) 00058 ; 00059 00060 /** Checks the type of a particular pointer. 00061 * 00062 * Uses the appropriate deallocation function in psMemBlock to check the ptr datatype. 00063 * 00064 * @return bool: True if the pointer matches a psPixels structure, false otherwise. 00065 */ 00066 bool psMemCheckPixels( 00067 psPtr ptr ///< the pointer whose type to check 00068 ); 00069 00070 00071 /** resizes a psPixels structure 00072 * 00073 * @return psPixels* resized psPixels 00074 */ 00075 psPixels* psPixelsRealloc( 00076 psPixels* pixels, ///< psPixels to resize, or NULL to create new psPixels 00077 long nalloc ///< the size of the coordinate vectors 00078 ); 00079 00080 /** Add a pixel location to a psPixels 00081 * 00082 * @return psPixels* psPixels with the value appended. 00083 */ 00084 psPixels* p_psPixelsAppend( 00085 psPixels* pixels, ///< psPixels to append new coordinate to. NULL creates a new one. 00086 long growth, 00087 ///< number of elements to grow the psPixels list, if necessary. if growth < 1, 10 is used. 00088 int x, ///< x coordinate to append 00089 int y ///< y coordinate to append 00090 ); 00091 00092 /** Copies a psPixels object 00093 * 00094 * Makes a deep copy of the data in a psPixels object. Any data in the OUT 00095 * parameter will be destroyed and OUT will be resized, if necessary. 00096 * 00097 * @return psPixels* a new psPixels that is a duplicate to IN 00098 */ 00099 psPixels* psPixelsCopy( 00100 psPixels* out, ///< psPixels struct to recycle, or NULL 00101 const psPixels* pixels ///< psPixels struct to copy 00102 ); 00103 00104 /** Generate a psImage from a psPixels 00105 * 00106 * psPixelsToMask shall return an image of type U8 with the pixels lying 00107 * within the specified region set to the maskVal. The out image shall be 00108 * modified if supplied, or allocated and returned if NULL. The size of the 00109 * output image shall be region->x1 - region->x0 by region->y1 - region->y0, 00110 * with out->x0 = region->x0 and out->y0 = region->y0. In the event that 00111 * either of pixels or region are NULL, the function shall generate an 00112 * error and return NULL. 00113 * 00114 * @return psImage* generated mask image 00115 */ 00116 psImage* psPixelsToMask( 00117 psImage* out, ///< psImage to recycle, or NULL 00118 const psPixels* pixels, ///< list of pixels to use 00119 psRegion region, ///< region to define the output mask image 00120 psMaskType maskVal ///< the mask bit-values to act upon 00121 ); 00122 00123 /** Generate a psPixels from a mask psImage 00124 * 00125 * psMaskToPixels shall return a psPixels consisting of the coordinates in 00126 * the mask that match the maskVal. The out pixel list shall be modiļ¬ed if 00127 * supplied, or allocated and returned if NULL. In hte event that mask is 00128 * NULL, the function shall generate an error and return NULL. 00129 * 00130 * @return psPixels* generated psPixels pixel list 00131 */ 00132 psPixels* psPixelsFromMask( 00133 psPixels *out, ///< psPixels to recycle, or NULL 00134 const psImage *mask, ///< the input mask psImage 00135 psMaskType maskVal ///< the mask bit-values to act upon 00136 ); 00137 00138 /** Concatenates two psPixels 00139 * 00140 * psPixelsConcatenate shall concatenate pixels onto out. In the event that 00141 * out is NULL, a new psPixels shall be allocated, and the contents of 00142 * pixels simply copied in. If pixels is NULL, the function shall generate 00143 * an error and return NULL. The function shall take care to ensure that 00144 * there are no duplicate pixels in out. 00145 * 00146 * @return psPixels Concatenated psPixel list 00147 */ 00148 psPixels* psPixelsConcatenate( 00149 psPixels *out, ///< psPixels to recycle, or NULL 00150 const psPixels *pixels ///< psPixels to append to OUT 00151 ); 00152 00153 /** Prints a psPixels to specified destination. 00154 * 00155 * @return bool: True if successful. 00156 */ 00157 bool p_psPixelsPrint( 00158 FILE *fd, ///< destination file descriptor 00159 psPixels* pixels, ///< psPixels to print 00160 const char *name ///< printf-style format of header line 00161 ); 00162 00163 #endif // #ifndef PS_PIXELS_H
1.4.2