Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

csuCommonImage.h

Go to the documentation of this file.
00001 #ifndef CSU_IMAGE_INCLUDED
00002 #define CSU_IMAGE_INCLUDED
00003 
00004 namespace csu{
00005 #define PIX_TYPE double
00006 #define RASTER_ID "CSU_RASTER"
00007 
00008 //#define INTERPOLATE_FAST 1
00009 
00010 typedef struct{
00011     int width;
00012     int height;
00013     int channels;
00014     PIX_TYPE*** data;
00015 } image;
00016 
00017 typedef image* Image;
00018 
00019 Image makeImage(int width,int height,int channels);
00020 Image makeZeroImage(int width,int height,int channels);
00021 void freeImage(Image i);
00022 
00023 Image duplicateImage(Image im);
00024 
00025 
00026 
00027 /********************* Image Access Functions *******************/
00028 
00029 /* Access a single image element using dope vector expantion. symantics: img[x,y,c] */
00030 #define IE( img , x , y , c )   ( (img)->data[(x)][(y)][(c)] )
00031 
00032 /* Safe read-only/range-checked implementation of IE - returns 0.0 if off image. */
00033 #if(!INTERPOLATE_FAST)
00034 PIX_TYPE ie(Image img, int x, int y, int c);
00035 #else
00036 #define ie( img , x , y , c ) ((x < img->width && y < img->height && c < img->channels && x >= 0 && y >=  0 && c >= 0) ? IE(img, x, y, c) : 0.0 )
00037 #endif
00038 /* interpolate a pixel value at a point */
00039 
00040 
00041 #if(!INTERPOLATE_FAST)
00042 PIX_TYPE interpLinear(Image img, PIX_TYPE x, PIX_TYPE y, int c);
00043 #else
00044 /* Error in Code #define interpLinear(img, x, y, c) ; */
00045 #endif
00046 
00047 /********************* Image Manipulation Functions *******************/
00048 
00049 Image convolveImage(const Image im, const Image mask);
00050 
00051 double convolvePoint(PIX_TYPE x, PIX_TYPE y, int c, const Image im, const Image mask);
00052 
00053 void contrastImage(Image im, double scalar);
00054     /* Multiplies everyvalue in im by scalar */
00055 
00056 void brightnessImage(Image im, double scalar);
00057     /* Adds scalar to every value in im */
00058 
00059 void ZeroMeanUnitLength(Image im);
00060 /* scales the pixel so that they have zero mean and the image is unit length*/
00061 void ZeroMeanUnitLengthMasked(Image im, const char **mask);
00062 /* scales the pixel so that they have zero mean and the image is unit length*/
00063 
00064 void ZeroMeanOneStdDev(Image im);
00065 /* scales the pixel so that they have zero mean and the image is unit length*/
00066 void ZeroMeanOneStdDevMasked(Image im, const char **mask);
00067 /* scales the pixel so that they have zero mean and the image is unit length*/
00068 
00069 double corrilateImages(const Image i1, const Image i2);
00070 /* findes the corrilation between two images */
00071 double dotImages(const Image i1, const Image i2);
00072 /* find the corrilation for images that have zero mean and unit length */
00073 
00074 Image computeMeanImage(Image* images, int count);
00075 /* takes an array of images and returns the mean of those images.*/
00076 
00077 Image accumulateChannels(const Image im);
00078 /* generates a new image that is the sum of all channels. */
00079 
00080 void accumulateImages(Image i1, const Image i2);
00081 /* inplace adds image i2 to image i1 */
00082 
00083 void gaussianBlur(Image im, double sigma);
00084 
00085 /* Add gausian noise to the image. s is the standard
00086  * deviation relative to the total image range returns the actual standard deviation
00087  * of the applied noise
00088  */
00089 double gaussianNoise(Image im, double s);
00090 
00091 /* Performs a histogram equalization function.  Output values are in the range 0 to 1 */
00092 void histEqual(Image i, int num_bins);
00093 void histEqualMask(Image i, int num_bins, const char **mask);
00094 
00095 /* Smooth image borders */
00096 void smoothImageEdge(Image i, int width);
00097 
00098 /* Zero all pixels not in a mask */
00099 void applyMask(Image im, const char **mask);
00100 
00101 PIX_TYPE imageMax(Image im);
00102 
00103 void markPoint(Image im, PIX_TYPE x, PIX_TYPE y);
00104 
00105 Image makeThurmalColorImage(Image im);
00106 
00107 Image makeThurmalComboImage(Image thrm, Image bw);
00108 
00109 
00110 /********************* Image File I/O Functions *******************/
00111 
00112 Image readPGMImage(const char*);
00113 Image readRawImage(const char*);
00114 Image readFeretImage(const char *fname, int width, int height,int channels);
00115 
00116 void  writePGMImage(const Image, const char*,int channel);
00117 void  writePPMImage(const Image, const char*);
00118 void  writeRawImage(const Image, const char*);
00119 void  writeFeretImage(const Image im, const char *fname);
00120 
00121 /********************* Image Statistics ************************************/
00122 
00123 typedef struct{
00124     PIX_TYPE max, min, mean, variance, stddev;
00125     int max_x, max_y, max_c, min_x, min_y, min_c;
00126 } image_statistics;
00127 
00128 typedef image_statistics* ImageStatistics;
00129 
00130 ImageStatistics computeImageStatistics(Image im);
00131 ImageStatistics computeImageStatisticsLocal(Image im, int x, int y, int dist);
00132 }
00133 #endif
00134 
00135 

Generated on Wed Apr 23 10:42:33 2003 for BioFilter by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002