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
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
00028
00029
00030 #define IE( img , x , y , c ) ( (img)->data[(x)][(y)][(c)] )
00031
00032
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
00039
00040
00041 #if(!INTERPOLATE_FAST)
00042 PIX_TYPE interpLinear(Image img, PIX_TYPE x, PIX_TYPE y, int c);
00043 #else
00044
00045 #endif
00046
00047
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
00055
00056 void brightnessImage(Image im, double scalar);
00057
00058
00059 void ZeroMeanUnitLength(Image im);
00060
00061 void ZeroMeanUnitLengthMasked(Image im, const char **mask);
00062
00063
00064 void ZeroMeanOneStdDev(Image im);
00065
00066 void ZeroMeanOneStdDevMasked(Image im, const char **mask);
00067
00068
00069 double corrilateImages(const Image i1, const Image i2);
00070
00071 double dotImages(const Image i1, const Image i2);
00072
00073
00074 Image computeMeanImage(Image* images, int count);
00075
00076
00077 Image accumulateChannels(const Image im);
00078
00079
00080 void accumulateImages(Image i1, const Image i2);
00081
00082
00083 void gaussianBlur(Image im, double sigma);
00084
00085
00086
00087
00088
00089 double gaussianNoise(Image im, double s);
00090
00091
00092 void histEqual(Image i, int num_bins);
00093 void histEqualMask(Image i, int num_bins, const char **mask);
00094
00095
00096 void smoothImageEdge(Image i, int width);
00097
00098
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
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
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