00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __IMAGE_DATA__
00027 #define __IMAGE_DATA__
00028
00029
00051
00052
00053
00054
00055
00056
00059 typedef unsigned char Image_operator;
00060
00062 const Image_operator COPY = 0;
00064 const Image_operator LEFT_DX = 1;
00066 const Image_operator RIGHT_DX = 2;
00068 const Image_operator DX = LEFT_DX;
00070 const Image_operator UP_DY = 3;
00072 const Image_operator DOWN_DY = 4;
00074 const Image_operator DY = UP_DY;
00076 const Image_operator DDX = 5;
00078 const Image_operator DDY = 6;
00080 const Image_operator SQUARE = 7;
00082 const Image_operator SQUARE_ROOT = 8;
00083
00084
00086 typedef unsigned char Output_format;
00087
00089
00090 const Output_format GREY_LEVELS = 0;
00091 const Output_format BLUE_AND_RED = 1;
00093
00094
00095
00096
00097
00098
00099
00101 class Image_data {
00102 private:
00104 float* data;
00105
00107
00108 int x_size;
00109 int y_size;
00111
00113 inline int offset(const int x,
00114 const int y) const{
00115 return x + x_size*y;
00116 }
00117
00118 public:
00120 Image_data(const int x_dim=0,
00121 const int y_dim=0);
00122
00125 Image_data(const int x_dim,
00126 const int y_dim,
00127 const float value);
00128
00130 Image_data(const char* file);
00131
00133 Image_data(const Image_data& source,
00134 const Image_operator op = COPY);
00135
00137 void get_size(int* width,
00138 int* height) const;
00139
00141 void get_dx(Image_data* result) const;
00142
00144 void get_dy(Image_data* result) const;
00145
00147 void get_ddx(Image_data* result) const;
00148
00150 void get_ddy(Image_data* result) const;
00151
00153 void get_laplacian(Image_data* result) const;
00154
00156 void get_square(Image_data* result) const;
00157
00159 void get_square_root(Image_data* result) const;
00160
00162 void get_grad_norm(Image_data* result) const;
00163
00165 template<class Float_function>
00166 void get_mapped_data(const Float_function& f,
00167 Image_data* result) const;
00168
00170 void output_to_GREY_LEVELS(const char* file) const;
00171
00173 void output_to_BLUE_AND_RED(const char* file) const;
00174
00176 void output_to_image(const char* file,
00177 const Output_format& format = GREY_LEVELS) const;
00178
00180 Image_data& operator=(const Image_data& img);
00181
00183 Image_data& operator+=(const Image_data& img);
00185 Image_data& operator+=(const float lambda);
00186
00188 Image_data& operator-=(const Image_data& img);
00190 Image_data& operator-=(const float lambda);
00191
00193 Image_data& operator*=(const Image_data& img);
00195 Image_data& operator*=(const float lambda);
00196
00198 Image_data& operator/=(const Image_data& img);
00200 Image_data& operator/=(const float lambda);
00201
00203 ~Image_data();
00204
00205
00206 friend Image_data operator+(const float lambda,
00207 const Image_data& img);
00208 friend Image_data operator+(const Image_data& img,
00209 const float lambda);
00210 friend Image_data operator+(const Image_data& img_1,
00211 const Image_data& img_2);
00212
00213 friend Image_data operator-(const float lambda,
00214 const Image_data& img);
00215 friend Image_data operator-(const Image_data& img,
00216 const float lambda);
00217 friend Image_data operator-(const Image_data& img_1,
00218 const Image_data& img_2);
00219
00220 friend Image_data operator*(const float lambda,
00221 const Image_data& img);
00222 friend Image_data operator*(const Image_data& img,
00223 const float lambda);
00224 friend Image_data operator*(const Image_data& img_1,
00225 const Image_data& img_2);
00226
00227 friend Image_data operator/(const Image_data& img_1,
00228 const Image_data& img_2);
00229 friend Image_data operator/(const Image_data& img,
00230 const float lambda);
00231
00232 friend inline void add(const float lambda,
00233 const Image_data& img,
00234 Image_data* result);
00235
00236 friend inline void add(const Image_data& img,
00237 const float lambda,
00238 Image_data* result);
00239
00240 friend inline void add(const Image_data& img_1,
00241 const Image_data& img_2,
00242 Image_data* result);
00243
00244 friend inline void sub(const float lambda,
00245 const Image_data& img,
00246 Image_data* result);
00247
00248 friend inline void sub(const Image_data& img,
00249 const float lambda,
00250 Image_data* result);
00251
00252 friend inline void sub(const Image_data& img_1,
00253 const Image_data& img_2,
00254 Image_data* result);
00255
00256 friend inline void mul(const Image_data& img,
00257 const float lambda,
00258 Image_data* result);
00259
00260 friend inline void mul(const float lambda,
00261 const Image_data& img,
00262 Image_data* result);
00263
00264 friend inline void mul(const Image_data& img_1,
00265 const Image_data& img_2,
00266 Image_data* result);
00267
00268 friend inline void div(const Image_data& img,
00269 const float lambda,
00270 Image_data* result);
00271
00272 friend inline void div(const Image_data& img_1,
00273 const Image_data& img_2,
00274 Image_data* result);
00275 };
00276
00277
00278 #include "image_data.cc"
00279
00280 #endif
00281
00282
00283
00284
00285
00286
00287
00288