00001
00002 #ifndef vil_pixel_traits_h_
00003 #define vil_pixel_traits_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <vcl_climits.h>
00031 #include <vcl_cfloat.h>
00032
00033
00034 template <class T>
00035 class vil_pixel_traits;
00036
00037
00038 VCL_DEFINE_SPECIALIZATION
00039 class vil_pixel_traits<bool>
00040 {
00041 public:
00042
00043 typedef bool component_type;
00044
00045
00046 static bool is_signed() {return false;}
00047
00048
00049 static unsigned num_bits() {return 1;}
00050
00051
00052 static bool minval() {return false;}
00053
00054
00055 static bool maxval() {return true;}
00056
00057
00058 static bool real_number_field() {return false;}
00059 };
00060
00061 #if !VCL_CANNOT_SPECIALIZE_CV
00062 VCL_DEFINE_SPECIALIZATION
00063 class vil_pixel_traits<bool const> : public vil_pixel_traits<bool> {};
00064 #endif
00065
00066 VCL_DEFINE_SPECIALIZATION
00067 class vil_pixel_traits<char>
00068 {
00069 public:
00070
00071 typedef char component_type;
00072
00073
00074 static bool is_signed() {return (char)255<0;}
00075
00076
00077 static unsigned num_bits() {return 8;}
00078
00079
00080 static char minval() {return char(255)<0?-128:0;}
00081
00082
00083 static char maxval() {return char(255)<0?127:255;}
00084
00085
00086 static bool real_number_field() {return false;}
00087 };
00088
00089 #if !VCL_CANNOT_SPECIALIZE_CV
00090 VCL_DEFINE_SPECIALIZATION
00091 class vil_pixel_traits<char const> : public vil_pixel_traits<char> {};
00092 #endif
00093
00094 VCL_DEFINE_SPECIALIZATION
00095 class vil_pixel_traits<unsigned char>
00096 {
00097 public:
00098
00099 typedef unsigned char component_type;
00100
00101
00102 static bool is_signed() {return false;}
00103
00104
00105 static unsigned num_bits() {return 8;}
00106
00107
00108 static unsigned char minval() {return 0;}
00109
00110
00111 static unsigned char maxval() {return UCHAR_MAX;}
00112
00113
00114 static bool real_number_field() {return false;}
00115 };
00116
00117 #if !VCL_CANNOT_SPECIALIZE_CV
00118 VCL_DEFINE_SPECIALIZATION
00119 class vil_pixel_traits<unsigned char const> : public vil_pixel_traits<unsigned char> {};
00120 #endif
00121
00122 VCL_DEFINE_SPECIALIZATION
00123 class vil_pixel_traits<signed char>
00124 {
00125 public:
00126
00127 typedef signed char component_type;
00128
00129
00130 static bool is_signed() {return true;}
00131
00132
00133 static unsigned num_bits() {return 8;}
00134
00135
00136 static signed char minval() {return SCHAR_MIN;}
00137
00138
00139 static signed char maxval() {return SCHAR_MAX;}
00140
00141
00142 static bool real_number_field() {return false;}
00143 };
00144
00145 #if !VCL_CANNOT_SPECIALIZE_CV
00146 VCL_DEFINE_SPECIALIZATION
00147 class vil_pixel_traits<signed char const> : public vil_pixel_traits<signed char> {};
00148 #endif
00149
00150 VCL_DEFINE_SPECIALIZATION
00151 class vil_pixel_traits<short>
00152 {
00153 public:
00154
00155 typedef short component_type;
00156
00157
00158 static bool is_signed() {return true;}
00159
00160
00161 static unsigned num_bits() {return 8*sizeof(short);}
00162
00163
00164 static short minval() {return SHRT_MIN;}
00165
00166
00167 static short maxval() {return SHRT_MAX;}
00168
00169
00170 static bool real_number_field() {return false;}
00171 };
00172
00173 #if !VCL_CANNOT_SPECIALIZE_CV
00174 VCL_DEFINE_SPECIALIZATION
00175 class vil_pixel_traits<short const> : public vil_pixel_traits<short> {};
00176 #endif
00177
00178 VCL_DEFINE_SPECIALIZATION
00179 class vil_pixel_traits<unsigned short>
00180 {
00181 public:
00182
00183 typedef unsigned short component_type;
00184
00185
00186 static bool is_signed() {return false;}
00187
00188
00189 static unsigned num_bits() {return 16;}
00190
00191
00192 static unsigned short minval() {return 0;}
00193
00194
00195 static unsigned short maxval() {return USHRT_MAX;}
00196
00197
00198 static bool real_number_field() {return false;}
00199 };
00200
00201 #if !VCL_CANNOT_SPECIALIZE_CV
00202 VCL_DEFINE_SPECIALIZATION
00203 class vil_pixel_traits<unsigned short const> : public vil_pixel_traits<unsigned short> {};
00204 #endif
00205
00206 VCL_DEFINE_SPECIALIZATION
00207 class vil_pixel_traits<int>
00208 {
00209 public:
00210
00211 typedef int component_type;
00212
00213
00214 static bool is_signed() {return true;}
00215
00216
00217 static unsigned num_bits() {return 8*sizeof(int);}
00218
00219
00220 static int minval() {return INT_MIN;}
00221
00222
00223 static int maxval() {return INT_MAX;}
00224
00225
00226 static bool real_number_field() {return false;}
00227 };
00228
00229 #if !VCL_CANNOT_SPECIALIZE_CV
00230 VCL_DEFINE_SPECIALIZATION
00231 class vil_pixel_traits<int const> : public vil_pixel_traits<int> {};
00232 #endif
00233
00234 VCL_DEFINE_SPECIALIZATION
00235 class vil_pixel_traits<unsigned int>
00236 {
00237 public:
00238
00239 typedef unsigned int component_type;
00240
00241
00242 static bool is_signed() {return false;}
00243
00244
00245 static unsigned num_bits() {return 8*sizeof(unsigned int);}
00246
00247
00248 static unsigned int minval() {return 0;}
00249
00250
00251 static unsigned int maxval() {return UINT_MAX;}
00252
00253
00254 static bool real_number_field() {return false;}
00255 };
00256
00257 #if !VCL_CANNOT_SPECIALIZE_CV
00258 VCL_DEFINE_SPECIALIZATION
00259 class vil_pixel_traits<unsigned int const> : public vil_pixel_traits<unsigned int> {};
00260 #endif
00261
00262 VCL_DEFINE_SPECIALIZATION
00263 class vil_pixel_traits<long>
00264 {
00265 public:
00266
00267 typedef long component_type;
00268
00269
00270 static bool is_signed() {return true;}
00271
00272
00273 static unsigned num_bits() {return 8*sizeof(long);}
00274
00275
00276 static long minval() {return LONG_MIN;}
00277
00278
00279 static long maxval() {return LONG_MAX;}
00280
00281
00282 static bool real_number_field() {return false;}
00283 };
00284
00285 #if !VCL_CANNOT_SPECIALIZE_CV
00286 VCL_DEFINE_SPECIALIZATION
00287 class vil_pixel_traits<long const> : public vil_pixel_traits<long > {};
00288 #endif
00289
00290 VCL_DEFINE_SPECIALIZATION
00291 class vil_pixel_traits<unsigned long>
00292 {
00293 public:
00294
00295 typedef unsigned long component_type;
00296
00297
00298 static bool is_signed() {return false;}
00299
00300
00301 static unsigned num_bits() {return 8*sizeof(unsigned long);}
00302
00303
00304 static unsigned long minval() {return 0;}
00305
00306
00307 static unsigned long maxval() {return ULONG_MAX;}
00308
00309
00310 static bool real_number_field() {return false;}
00311 };
00312
00313 #if !VCL_CANNOT_SPECIALIZE_CV
00314 VCL_DEFINE_SPECIALIZATION
00315 class vil_pixel_traits<unsigned long const> : public vil_pixel_traits<unsigned long> {};
00316 #endif
00317
00318 VCL_DEFINE_SPECIALIZATION
00319 class vil_pixel_traits<float>
00320 {
00321 public:
00322
00323 typedef float component_type;
00324
00325
00326 static bool is_signed() {return true;}
00327
00328
00329 static unsigned num_bits() {return 8*sizeof(float);}
00330
00331
00332 static float minval() {return -FLT_MAX;}
00333
00334
00335 static float maxval() {return FLT_MAX;}
00336
00337
00338 static bool real_number_field() {return true;}
00339 };
00340
00341 #if !VCL_CANNOT_SPECIALIZE_CV
00342 VCL_DEFINE_SPECIALIZATION
00343 class vil_pixel_traits<float const> : public vil_pixel_traits<float> {};
00344 #endif
00345
00346 VCL_DEFINE_SPECIALIZATION
00347 class vil_pixel_traits<double>
00348 {
00349 public:
00350
00351 typedef double component_type;
00352
00353
00354 static bool is_signed() {return true;}
00355
00356
00357 static unsigned num_bits() {return 8*sizeof(double);}
00358
00359
00360 static double minval() {return -DBL_MAX;}
00361
00362
00363 static double maxval() {return DBL_MAX;}
00364
00365
00366 static bool real_number_field() {return true;}
00367 };
00368
00369 #if !VCL_CANNOT_SPECIALIZE_CV
00370 VCL_DEFINE_SPECIALIZATION
00371 class vil_pixel_traits<double const> : public vil_pixel_traits<double> {};
00372 #endif
00373
00374 VCL_DEFINE_SPECIALIZATION
00375 class vil_pixel_traits<long double>
00376 {
00377 public:
00378
00379 typedef long double component_type;
00380
00381
00382 static bool is_signed() {return true;}
00383
00384
00385 static unsigned num_bits() {return 8*sizeof(long double);}
00386
00387
00388 static long double minval() {return -LDBL_MAX;}
00389
00390
00391 static long double maxval() {return LDBL_MAX;}
00392
00393
00394 static bool real_number_field() {return true;}
00395 };
00396
00397 #if !VCL_CANNOT_SPECIALIZE_CV
00398 VCL_DEFINE_SPECIALIZATION
00399 class vil_pixel_traits<long double const> : public vil_pixel_traits<long double> {};
00400 #endif
00401
00402
00403
00404 template <class T>
00405 class vil_pixel_traits
00406 {
00407 public:
00408
00409 typedef typename vil_pixel_traits<VCL_DISAPPEARING_TYPENAME T::value_type>::
00410 component_type component_type;
00411 };
00412
00413 #endif // vil_pixel_traits_h_