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
00027
00028
00029
00030
00031
00032 #ifdef _USE_ITK_
00033
00034 #ifndef __BBITKIMAGE_H_INCLUDED__
00035 #define __BBITKIMAGE_H_INCLUDED__
00036
00037 #include "itkImage.h"
00038 #include "bbtkAny.h"
00039 #include "bbtkSystem.h"
00040
00041 namespace bbitk
00042 {
00043
00044
00045 #define BBTK_TYPEDEF_ITK_IMAGE(TYPE,DIM) \
00046 typedef itk::Image<TYPE,DIM> Image_##TYPE##_##DIM; \
00047 typedef const Image_##TYPE##_##DIM Image_##TYPE##_##DIM##_c; \
00048 typedef Image_##TYPE##_##DIM * Image_##TYPE##_##DIM##_ptr; \
00049 typedef Image_##TYPE##_##DIM##_c * Image_##TYPE##_##DIM##_cptr;
00050
00051
00052 #define BBTK_TYPEDEF_ITK_IMAGES_DIM(DIM) \
00053 BBTK_TYPEDEF_ITK_IMAGE(int8_t,DIM); \
00054 BBTK_TYPEDEF_ITK_IMAGE(uint8_t,DIM); \
00055 BBTK_TYPEDEF_ITK_IMAGE(int16_t,DIM); \
00056 BBTK_TYPEDEF_ITK_IMAGE(uint16_t,DIM); \
00057 BBTK_TYPEDEF_ITK_IMAGE(int32_t,DIM); \
00058 BBTK_TYPEDEF_ITK_IMAGE(uint32_t,DIM); \
00059 BBTK_TYPEDEF_ITK_IMAGE(float,DIM); \
00060 BBTK_TYPEDEF_ITK_IMAGE(double,DIM)
00061
00062 BBTK_TYPEDEF_ITK_IMAGES_DIM(2);
00063 BBTK_TYPEDEF_ITK_IMAGES_DIM(3);
00064 BBTK_TYPEDEF_ITK_IMAGES_DIM(4);
00065
00066
00067
00068
00069 #define BBTK_BEGIN_TEMPLATE_SWITCH(TYPE_INFO) if (false) {}
00070
00071 #define BBTK_END_TEMPLATE_SWITCH(TYPE_INFO) else { bbtkError("bbtk was not built for itk images of type <"<< bbtk::demangle_type_name(TYPE_INFO.name())<<">"); }
00072
00073 #define BBTK_END_TEMPLATE_SWITCH_MESSAGE(TYPE_INFO,MESSAGE) else { bbtkError(MESSAGE); }
00074
00078 #define TEMPLATE_SWITCH(TYPE_INFO,TEST_TYPE,TEMPLATE_FUNCTION,TEMPLATE_TYPE) \
00079 else if (TYPE_INFO == typeid(bbitk::TEST_TYPE)) \
00080 { TEMPLATE_FUNCTION<bbitk::TEMPLATE_TYPE>(); }
00081
00082
00083
00084 #ifdef BBTK_ITK_IMAGE_DIM_2
00085 # ifdef BBTK_ITK_IMAGE_TYPE_int8_t
00086 # define BBTK_SWITCH_ITK_IMAGE_int8_t_2(TYPE_INFO,FUN,CONST) \
00087 TEMPLATE_SWITCH(TYPE_INFO,Image_int8_t_2_##CONST##ptr,FUN,Image_int8_t_2)
00088 # else
00089 # define BBTK_SWITCH_ITK_IMAGE_int8_t_2(TYPE_INFO,FUN,CONST)
00090 # endif
00091 # ifdef BBTK_ITK_IMAGE_TYPE_int16_t
00092 # define BBTK_SWITCH_ITK_IMAGE_int16_t_2(TYPE_INFO,FUN,CONST) \
00093 TEMPLATE_SWITCH(TYPE_INFO,Image_int16_t_2_##CONST##ptr,FUN,Image_int16_t_2)
00094 # else
00095 # define BBTK_SWITCH_ITK_IMAGE_int16_t_2(TYPE_INFO,FUN,CONST)
00096 # endif
00097 # ifdef BBTK_ITK_IMAGE_TYPE_int32_t
00098 # define BBTK_SWITCH_ITK_IMAGE_int32_t_2(TYPE_INFO,FUN,CONST) \
00099 TEMPLATE_SWITCH(TYPE_INFO,Image_int32_t_2_##CONST##ptr,FUN,Image_int32_t_2)
00100 # else
00101 # define BBTK_SWITCH_ITK_IMAGE_int32_t_2(TYPE_INFO,FUN,CONST)
00102 # endif
00103 # ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
00104 # define BBTK_SWITCH_ITK_IMAGE_uint8_t_2(TYPE_INFO,FUN,CONST) \
00105 TEMPLATE_SWITCH(TYPE_INFO,Image_uint8_t_2_##CONST##ptr,FUN,Image_uint8_t_2)
00106 # else
00107 # define BBTK_SWITCH_ITK_IMAGE_uint8_t_2(TYPE_INFO,FUN,CONST)
00108 # endif
00109 # ifdef BBTK_ITK_IMAGE_TYPE_int16_t
00110 # define BBTK_SWITCH_ITK_IMAGE_uint16_t_2(TYPE_INFO,FUN,CONST) \
00111 TEMPLATE_SWITCH(TYPE_INFO,Image_uint16_t_2_##CONST##ptr,FUN,Image_uint16_t_2)
00112 # else
00113 # define BBTK_SWITCH_ITK_IMAGE_uint16_t_2(TYPE_INFO,FUN,CONST)
00114 # endif
00115 # ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
00116 # define BBTK_SWITCH_ITK_IMAGE_uint32_t_2(TYPE_INFO,FUN,CONST) \
00117 TEMPLATE_SWITCH(TYPE_INFO,Image_uint32_t_2_##CONST##ptr,FUN,Image_uint32_t_2)
00118 # else
00119 # define BBTK_SWITCH_ITK_IMAGE_uint32_t_2(TYPE_INFO,FUN,CONST)
00120 # endif
00121 # ifdef BBTK_ITK_IMAGE_TYPE_float
00122 # define BBTK_SWITCH_ITK_IMAGE_float_2(TYPE_INFO,FUN,CONST) \
00123 TEMPLATE_SWITCH(TYPE_INFO,Image_float_2_##CONST##ptr,FUN,Image_float_2)
00124 # else
00125 # define BBTK_SWITCH_ITK_IMAGE_float_2(TYPE_INFO,FUN,CONST)
00126 # endif
00127 # ifdef BBTK_ITK_IMAGE_TYPE_double
00128 # define BBTK_SWITCH_ITK_IMAGE_double_2(TYPE_INFO,FUN,CONST) \
00129 TEMPLATE_SWITCH(TYPE_INFO,Image_double_2_##CONST##ptr,FUN,Image_double_2)
00130 # else
00131 # define BBTK_SWITCH_ITK_IMAGE_double_2(TYPE_INFO,FUN,CONST)
00132 # endif
00133 #else
00134 # define BBTK_SWITCH_ITK_IMAGE_int8_t_2(TYPE_INFO,FUN,CONST)
00135 # define BBTK_SWITCH_ITK_IMAGE_int16_t_2(TYPE_INFO,FUN,CONST)
00136 # define BBTK_SWITCH_ITK_IMAGE_int32_t_2(TYPE_INFO,FUN,CONST)
00137 # define BBTK_SWITCH_ITK_IMAGE_uint8_t_2(TYPE_INFO,FUN,CONST)
00138 # define BBTK_SWITCH_ITK_IMAGE_uint16_t_2(TYPE_INFO,FUN,CONST)
00139 # define BBTK_SWITCH_ITK_IMAGE_uint32_t_2(TYPE_INFO,FUN,CONST)
00140 # define BBTK_SWITCH_ITK_IMAGE_float_2(TYPE_INFO,FUN,CONST)
00141 # define BBTK_SWITCH_ITK_IMAGE_double_2(TYPE_INFO,FUN,CONST)
00142 #endif
00143
00144
00145
00146 #ifdef BBTK_ITK_IMAGE_DIM_3
00147 # ifdef BBTK_ITK_IMAGE_TYPE_int8_t
00148 # define BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,CONST) \
00149 TEMPLATE_SWITCH(TYPE_INFO,Image_int8_t_3_##CONST##ptr,FUN,Image_int8_t_3)
00150 # else
00151 # define BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,CONST)
00152 # endif
00153 # ifdef BBTK_ITK_IMAGE_TYPE_int16_t
00154 # define BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,CONST) \
00155 TEMPLATE_SWITCH(TYPE_INFO,Image_int16_t_3_##CONST##ptr,FUN,Image_int16_t_3)
00156 # else
00157 # define BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,CONST)
00158 # endif
00159 # ifdef BBTK_ITK_IMAGE_TYPE_int32_t
00160 # define BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,CONST) \
00161 TEMPLATE_SWITCH(TYPE_INFO,Image_int32_t_3_##CONST##ptr,FUN,Image_int32_t_3)
00162 # else
00163 # define BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,CONST)
00164 # endif
00165 # ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
00166 # define BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,CONST) \
00167 TEMPLATE_SWITCH(TYPE_INFO,Image_uint8_t_3_##CONST##ptr,FUN,Image_uint8_t_3)
00168 # else
00169 # define BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,CONST)
00170 # endif
00171 # ifdef BBTK_ITK_IMAGE_TYPE_int16_t
00172 # define BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,CONST) \
00173 TEMPLATE_SWITCH(TYPE_INFO,Image_uint16_t_3_##CONST##ptr,FUN,Image_uint16_t_3)
00174 # else
00175 # define BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,CONST)
00176 # endif
00177 # ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
00178 # define BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,CONST) \
00179 TEMPLATE_SWITCH(TYPE_INFO,Image_uint32_t_3_##CONST##ptr,FUN,Image_uint32_t_3)
00180 # else
00181 # define BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,CONST)
00182 # endif
00183 # ifdef BBTK_ITK_IMAGE_TYPE_float
00184 # define BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,CONST) \
00185 TEMPLATE_SWITCH(TYPE_INFO,Image_float_3_##CONST##ptr,FUN,Image_float_3)
00186 # else
00187 # define BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,CONST)
00188 # endif
00189 # ifdef BBTK_ITK_IMAGE_TYPE_double
00190 # define BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,CONST) \
00191 TEMPLATE_SWITCH(TYPE_INFO,Image_double_3_##CONST##ptr,FUN,Image_double_3)
00192 # else
00193 # define BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,CONST)
00194 # endif
00195 #else
00196 # define BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,CONST)
00197 # define BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,CONST)
00198 # define BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,CONST)
00199 # define BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,CONST)
00200 # define BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,CONST)
00201 # define BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,CONST)
00202 # define BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,CONST)
00203 # define BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,CONST)
00204 #endif
00205
00206
00207
00208 #ifdef BBTK_ITK_IMAGE_DIM_4
00209 # ifdef BBTK_ITK_IMAGE_TYPE_int8_t
00210 # define BBTK_SWITCH_ITK_IMAGE_int8_t_4(TYPE_INFO,FUN,CONST) \
00211 TEMPLATE_SWITCH(TYPE_INFO,Image_int8_t_4_##CONST##ptr,FUN,Image_int8_t_4)
00212 # else
00213 # define BBTK_SWITCH_ITK_IMAGE_int8_t_4(TYPE_INFO,FUN,CONST)
00214 # endif
00215 # ifdef BBTK_ITK_IMAGE_TYPE_int16_t
00216 # define BBTK_SWITCH_ITK_IMAGE_int16_t_4(TYPE_INFO,FUN,CONST) \
00217 TEMPLATE_SWITCH(TYPE_INFO,Image_int16_t_4_##CONST##ptr,FUN,Image_int16_t_4)
00218 # else
00219 # define BBTK_SWITCH_ITK_IMAGE_int16_t_4(TYPE_INFO,FUN,CONST)
00220 # endif
00221 # ifdef BBTK_ITK_IMAGE_TYPE_int32_t
00222 # define BBTK_SWITCH_ITK_IMAGE_int32_t_4(TYPE_INFO,FUN,CONST) \
00223 TEMPLATE_SWITCH(TYPE_INFO,Image_int32_t_4_##CONST##ptr,FUN,Image_int32_t_4)
00224 # else
00225 # define BBTK_SWITCH_ITK_IMAGE_int32_t_4(TYPE_INFO,FUN,CONST)
00226 # endif
00227 # ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
00228 # define BBTK_SWITCH_ITK_IMAGE_uint8_t_4(TYPE_INFO,FUN,CONST) \
00229 TEMPLATE_SWITCH(TYPE_INFO,Image_uint8_t_4_##CONST##ptr,FUN,Image_uint8_t_4)
00230 # else
00231 # define BBTK_SWITCH_ITK_IMAGE_uint8_t_4(TYPE_INFO,FUN,CONST)
00232 # endif
00233 # ifdef BBTK_ITK_IMAGE_TYPE_int16_t
00234 # define BBTK_SWITCH_ITK_IMAGE_uint16_t_4(TYPE_INFO,FUN,CONST) \
00235 TEMPLATE_SWITCH(TYPE_INFO,Image_uint16_t_4_##CONST##ptr,FUN,Image_uint16_t_4)
00236 # else
00237 # define BBTK_SWITCH_ITK_IMAGE_uint16_t_4(TYPE_INFO,FUN,CONST)
00238 # endif
00239 # ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
00240 # define BBTK_SWITCH_ITK_IMAGE_uint32_t_4(TYPE_INFO,FUN,CONST) \
00241 TEMPLATE_SWITCH(TYPE_INFO,Image_uint32_t_4_##CONST##ptr,FUN,Image_uint32_t_4)
00242 # else
00243 # define BBTK_SWITCH_ITK_IMAGE_uint32_t_4(TYPE_INFO,FUN,CONST)
00244 # endif
00245 # ifdef BBTK_ITK_IMAGE_TYPE_float
00246 # define BBTK_SWITCH_ITK_IMAGE_float_4(TYPE_INFO,FUN,CONST) \
00247 TEMPLATE_SWITCH(TYPE_INFO,Image_float_4_##CONST##ptr,FUN,Image_float_4)
00248 # else
00249 # define BBTK_SWITCH_ITK_IMAGE_float_4(TYPE_INFO,FUN,CONST)
00250 # endif
00251 # ifdef BBTK_ITK_IMAGE_TYPE_double
00252 # define BBTK_SWITCH_ITK_IMAGE_double_4(TYPE_INFO,FUN,CONST) \
00253 TEMPLATE_SWITCH(TYPE_INFO,Image_double_4_##CONST##ptr,FUN,Image_double_4)
00254 # else
00255 # define BBTK_SWITCH_ITK_IMAGE_double_4(TYPE_INFO,FUN,CONST)
00256 # endif
00257 #else
00258 # define BBTK_SWITCH_ITK_IMAGE_int8_t_4(TYPE_INFO,FUN,CONST)
00259 # define BBTK_SWITCH_ITK_IMAGE_int16_t_4(TYPE_INFO,FUN,CONST)
00260 # define BBTK_SWITCH_ITK_IMAGE_int32_t_4(TYPE_INFO,FUN,CONST)
00261 # define BBTK_SWITCH_ITK_IMAGE_uint8_t_4(TYPE_INFO,FUN,CONST)
00262 # define BBTK_SWITCH_ITK_IMAGE_uint16_t_4(TYPE_INFO,FUN,CONST)
00263 # define BBTK_SWITCH_ITK_IMAGE_uint32_t_4(TYPE_INFO,FUN,CONST)
00264 # define BBTK_SWITCH_ITK_IMAGE_float_4(TYPE_INFO,FUN,CONST)
00265 # define BBTK_SWITCH_ITK_IMAGE_double_4(TYPE_INFO,FUN,CONST)
00266 #endif
00267
00268
00271 #define BBTK_TEMPLATE_ITK_IMAGE_SWITCH(TYPE_INFO,FUN) \
00272 BBTK_BEGIN_TEMPLATE_SWITCH(TYPE_INFO) \
00273 BBTK_SWITCH_ITK_IMAGE_int8_t_2(TYPE_INFO,FUN,) \
00274 BBTK_SWITCH_ITK_IMAGE_int16_t_2(TYPE_INFO,FUN,) \
00275 BBTK_SWITCH_ITK_IMAGE_int32_t_2(TYPE_INFO,FUN,) \
00276 BBTK_SWITCH_ITK_IMAGE_uint8_t_2(TYPE_INFO,FUN,) \
00277 BBTK_SWITCH_ITK_IMAGE_uint16_t_2(TYPE_INFO,FUN,) \
00278 BBTK_SWITCH_ITK_IMAGE_uint32_t_2(TYPE_INFO,FUN,) \
00279 BBTK_SWITCH_ITK_IMAGE_float_2(TYPE_INFO,FUN,) \
00280 BBTK_SWITCH_ITK_IMAGE_double_2(TYPE_INFO,FUN,) \
00281 BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,) \
00282 BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,) \
00283 BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,) \
00284 BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,) \
00285 BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,) \
00286 BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,) \
00287 BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,) \
00288 BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,) \
00289 BBTK_SWITCH_ITK_IMAGE_int8_t_4(TYPE_INFO,FUN,) \
00290 BBTK_SWITCH_ITK_IMAGE_int16_t_4(TYPE_INFO,FUN,) \
00291 BBTK_SWITCH_ITK_IMAGE_int32_t_4(TYPE_INFO,FUN,) \
00292 BBTK_SWITCH_ITK_IMAGE_uint8_t_4(TYPE_INFO,FUN,) \
00293 BBTK_SWITCH_ITK_IMAGE_uint16_t_4(TYPE_INFO,FUN,) \
00294 BBTK_SWITCH_ITK_IMAGE_uint32_t_4(TYPE_INFO,FUN,) \
00295 BBTK_SWITCH_ITK_IMAGE_float_4(TYPE_INFO,FUN,) \
00296 BBTK_SWITCH_ITK_IMAGE_double_4(TYPE_INFO,FUN,) \
00297 BBTK_END_TEMPLATE_SWITCH(TYPE_INFO)
00298
00301 #define BBTK_TEMPLATE_ITK_IMAGE_DIM_3_SWITCH(TYPE_INFO,FUN,ERROR_MESSAGE) \
00302 BBTK_BEGIN_TEMPLATE_SWITCH(TYPE_INFO) \
00303 BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,) \
00304 BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,) \
00305 BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,) \
00306 BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,) \
00307 BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,) \
00308 BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,) \
00309 BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,) \
00310 BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,) \
00311 BBTK_END_TEMPLATE_SWITCH_MESSAGE(TYPE_INFO,ERROR_MESSAGE)
00312
00313
00316
00317 #define BBTK_TEMPLATE_CONST_ITK_IMAGE_SWITCH(TYPE_INFO,FUN) \
00318 BBTK_BEGIN_TEMPLATE_SWITCH(TYPE_INFO) \
00319 BBTK_SWITCH_ITK_IMAGE_int8_t_2(TYPE_INFO,FUN,c) \
00320 BBTK_SWITCH_ITK_IMAGE_int16_t_2(TYPE_INFO,FUN,c) \
00321 BBTK_SWITCH_ITK_IMAGE_int32_t_2(TYPE_INFO,FUN,c) \
00322 BBTK_SWITCH_ITK_IMAGE_uint8_t_2(TYPE_INFO,FUN,c) \
00323 BBTK_SWITCH_ITK_IMAGE_uint16_t_2(TYPE_INFO,FUN,c) \
00324 BBTK_SWITCH_ITK_IMAGE_uint32_t_2(TYPE_INFO,FUN,c) \
00325 BBTK_SWITCH_ITK_IMAGE_float_2(TYPE_INFO,FUN,c) \
00326 BBTK_SWITCH_ITK_IMAGE_double_2(TYPE_INFO,FUN,c) \
00327 BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,c) \
00328 BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,c) \
00329 BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,c) \
00330 BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,c) \
00331 BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,c) \
00332 BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,c) \
00333 BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,c) \
00334 BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,c) \
00335 BBTK_SWITCH_ITK_IMAGE_int8_t_4(TYPE_INFO,FUN,c) \
00336 BBTK_SWITCH_ITK_IMAGE_int16_t_4(TYPE_INFO,FUN,c) \
00337 BBTK_SWITCH_ITK_IMAGE_int32_t_4(TYPE_INFO,FUN,c) \
00338 BBTK_SWITCH_ITK_IMAGE_uint8_t_4(TYPE_INFO,FUN,c) \
00339 BBTK_SWITCH_ITK_IMAGE_uint16_t_4(TYPE_INFO,FUN,c) \
00340 BBTK_SWITCH_ITK_IMAGE_uint32_t_4(TYPE_INFO,FUN,c) \
00341 BBTK_SWITCH_ITK_IMAGE_float_4(TYPE_INFO,FUN,c) \
00342 BBTK_SWITCH_ITK_IMAGE_double_4(TYPE_INFO,FUN,c) \
00343 BBTK_END_TEMPLATE_SWITCH(TYPE_INFO)
00344
00345 #define BBTK_GITIFPTI_DIM(DIM) \
00346 if (pti == typeid(unsigned char)) \
00347 return typeid(itk::Image<unsigned char,DIM>*); \
00348 if (pti == typeid(unsigned short)) \
00349 return typeid(itk::Image<unsigned short,DIM>*); \
00350 if (pti == typeid(unsigned int)) \
00351 return typeid(itk::Image<unsigned int,DIM>*); \
00352 if (pti == typeid(unsigned long)) \
00353 return typeid(itk::Image<unsigned long,DIM>*); \
00354 if (pti == typeid(signed char)) \
00355 return typeid(itk::Image<signed char,DIM>*); \
00356 if (pti == typeid(signed short)) \
00357 return typeid(itk::Image<signed short,DIM>*); \
00358 if (pti == typeid(signed int)) \
00359 return typeid(itk::Image<signed int,DIM>*); \
00360 if (pti == typeid(signed long)) \
00361 return typeid(itk::Image<signed long,DIM>*); \
00362 if (pti == typeid(float)) \
00363 return typeid(itk::Image<float,DIM>*); \
00364 if (pti == typeid(double)) \
00365 return typeid(itk::Image<double,DIM>*);
00366
00367
00368 inline bbtk::TypeInfo GetITKImagePtrTypeInfoFromPixelTypeInfoAndDimension(
00369 bbtk::TypeInfo pti,
00370 unsigned int dim )
00371 {
00372 if (dim==2) { BBTK_GITIFPTI_DIM(2); }
00373 else if (dim==3) { BBTK_GITIFPTI_DIM(3); }
00374 else if (dim==4) { BBTK_GITIFPTI_DIM(4); }
00375 else
00376 {
00377
00378 return typeid(void);
00379 }
00380 return typeid(void);
00381 }
00382
00383
00384 #undef BBTK_GITIFPTI_DIM
00385
00386
00388 template <typename ValueType>
00389 class TypeMapping
00390 {
00391 public:
00392 TypeMapping() {}
00393
00394 template <typename T>
00395 ValueType& value()
00396 {
00397 return m_map[ (void*)typeid(T).name() ];
00398 }
00399 template <typename T>
00400 ValueType& operator[]( const T& )
00401 {
00402 return m_map[ (void*)typeid(T).name() ];
00403 }
00404
00405 ValueType& operator[]( const std::type_info& t)
00406 {
00407 return m_map[ (void*)t.name() ];
00408 }
00409
00410 unsigned int size() const { return m_map.size(); }
00411
00412 typedef typename std::map<void*, ValueType>::const_iterator const_iterator;
00413
00414 const_iterator begin() const { return m_map.begin(); }
00415 const_iterator end() const { return m_map.end(); }
00416
00417 protected:
00418 std::map<void*, ValueType> m_map;
00419 };
00420
00421 #define BBTK_BUILD_ITK_IMAGE_FUNCTION_MAPPING(MAP,FUN) \
00422 MAP.value<bbtk::Image_int8_t_2_ptr>() = FUN<bbtk::Image_int8_t_2_ptr>; \
00423 MAP.value<bbtk::Image_int16_t_2_ptr>() = FUN<bbtk::Image_int16_t_2_ptr>; \
00424 MAP.value<bbtk::Image_int32_t_2_ptr>() = FUN<bbtk::Image_int32_t_2_ptr>; \
00425 MAP.value<bbtk::Image_uint8_t_2_ptr>() = FUN<bbtk::Image_uint8_t_2_ptr>; \
00426 MAP.value<bbtk::Image_uint16_t_2_ptr>() = FUN<bbtk::Image_uint16_t_2_ptr>; \
00427 MAP.value<bbtk::Image_uint32_t_2_ptr>() = FUN<bbtk::Image_uint32_t_2_ptr>; \
00428 MAP.value<bbtk::Image_float_2_ptr>() = FUN<bbtk::Image_float_2_ptr>; \
00429 MAP.value<bbtk::Image_double_2_ptr>() = FUN<bbtk::Image_double_2_ptr>; \
00430 MAP.value<bbtk::Image_int8_t_3_ptr>() = FUN<bbtk::Image_int8_t_3_ptr>; \
00431 MAP.value<bbtk::Image_int16_t_3_ptr>() = FUN<bbtk::Image_int16_t_3_ptr>; \
00432 MAP.value<bbtk::Image_int32_t_3_ptr>() = FUN<bbtk::Image_int32_t_3_ptr>; \
00433 MAP.value<bbtk::Image_uint8_t_3_ptr>() = FUN<bbtk::Image_uint8_t_3_ptr>; \
00434 MAP.value<bbtk::Image_uint16_t_3_ptr>() = FUN<bbtk::Image_uint16_t_3_ptr>; \
00435 MAP.value<bbtk::Image_uint32_t_3_ptr>() = FUN<bbtk::Image_uint32_t_3_ptr>; \
00436 MAP.value<bbtk::Image_float_3_ptr>() = FUN<bbtk::Image_float_3_ptr>; \
00437 MAP.value<bbtk::Image_double_3_ptr>() = FUN<bbtk::Image_double_3_ptr>; \
00438 MAP.value<bbtk::Image_int8_t_4_ptr>() = FUN<bbtk::Image_int8_t_4_ptr>; \
00439 MAP.value<bbtk::Image_int16_t_4_ptr>() = FUN<bbtk::Image_int16_t_4_ptr>; \
00440 MAP.value<bbtk::Image_int32_t_4_ptr>() = FUN<bbtk::Image_int32_t_4_ptr>; \
00441 MAP.value<bbtk::Image_uint8_t_4_ptr>() = FUN<bbtk::Image_uint8_t_4_ptr>; \
00442 MAP.value<bbtk::Image_uint16_t_4_ptr>() = FUN<bbtk::Image_uint16_t_4_ptr>; \
00443 MAP.value<bbtk::Image_uint32_t_4_ptr>() = FUN<bbtk::Image_uint32_t_4_ptr>; \
00444 MAP.value<bbtk::Image_float_4_ptr>() = FUN<bbtk::Image_float_4_ptr>; \
00445 MAP.value<bbtk::Image_double_4_ptr>() = FUN<bbtk::Image_double_4_ptr>;
00446
00447
00448
00449
00450
00451
00453 template <typename T> struct ImagePointer { static const bool value = false; };
00454
00455 typedef bbtk::any<ImagePointer> anyImagePointer;
00456
00457
00458
00459 #ifdef BBTK_ITK_IMAGE_DIM_2
00460 # ifdef BBTK_ITK_IMAGE_TYPE_int8_t
00461 template <> struct ImagePointer<Image_int8_t_2_ptr> { static const bool value = true; };
00462 # endif
00463 # ifdef BBTK_ITK_IMAGE_TYPE_int16_t
00464 template <> struct ImagePointer<Image_int16_t_2_ptr> { static const bool value = true; };
00465 # endif
00466 # ifdef BBTK_ITK_IMAGE_TYPE_int32_t
00467 template <> struct ImagePointer<Image_int32_t_2_ptr> { static const bool value = true; };
00468 # endif
00469 # ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
00470 template <> struct ImagePointer<Image_uint8_t_2_ptr> { static const bool value = true; };
00471 # endif
00472 # ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
00473 template <> struct ImagePointer<Image_uint16_t_2_ptr> { static const bool value = true; };
00474 # endif
00475 # ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
00476 template <> struct ImagePointer<Image_uint32_t_2_ptr> { static const bool value = true; };
00477 # endif
00478 # ifdef BBTK_ITK_IMAGE_TYPE_float
00479 template <> struct ImagePointer<Image_float_2_ptr> { static const bool value = true; };
00480 # endif
00481 # ifdef BBTK_ITK_IMAGE_TYPE_double
00482 template <> struct ImagePointer<Image_double_2_ptr> { static const bool value = true; };
00483 # endif
00484 #endif
00485
00486
00487
00488 #ifdef BBTK_ITK_IMAGE_DIM_3
00489 # ifdef BBTK_ITK_IMAGE_TYPE_int8_t
00490 template <> struct ImagePointer<Image_int8_t_3_ptr> { static const bool value = true; };
00491 # endif
00492 # ifdef BBTK_ITK_IMAGE_TYPE_int16_t
00493 template <> struct ImagePointer<Image_int16_t_3_ptr> { static const bool value = true; };
00494 # endif
00495 # ifdef BBTK_ITK_IMAGE_TYPE_int32_t
00496 template <> struct ImagePointer<Image_int32_t_3_ptr> { static const bool value = true; };
00497 # endif
00498 # ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
00499 template <> struct ImagePointer<Image_uint8_t_3_ptr> { static const bool value = true; };
00500 # endif
00501 # ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
00502 template <> struct ImagePointer<Image_uint16_t_3_ptr> { static const bool value = true; };
00503 # endif
00504 # ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
00505 template <> struct ImagePointer<Image_uint32_t_3_ptr> { static const bool value = true; };
00506 # endif
00507 # ifdef BBTK_ITK_IMAGE_TYPE_float
00508 template <> struct ImagePointer<Image_float_3_ptr> { static const bool value = true; };
00509 # endif
00510 # ifdef BBTK_ITK_IMAGE_TYPE_double
00511 template <> struct ImagePointer<Image_double_3_ptr> { static const bool value = true; };
00512 # endif
00513 #endif
00514
00515
00516
00517 #ifdef BBTK_ITK_IMAGE_DIM_4
00518 # ifdef BBTK_ITK_IMAGE_TYPE_int8_t
00519 template <> struct ImagePointer<Image_int8_t_4_ptr> { static const bool value = true; };
00520 # endif
00521 # ifdef BBTK_ITK_IMAGE_TYPE_int16_t
00522 template <> struct ImagePointer<Image_int16_t_4_ptr> { static const bool value = true; };
00523 # endif
00524 # ifdef BBTK_ITK_IMAGE_TYPE_int32_t
00525 template <> struct ImagePointer<Image_int32_t_4_ptr> { static const bool value = true; };
00526 # endif
00527 # ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
00528 template <> struct ImagePointer<Image_uint8_t_4_ptr> { static const bool value = true; };
00529 # endif
00530 # ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
00531 template <> struct ImagePointer<Image_uint16_t_4_ptr> { static const bool value = true; };
00532 # endif
00533 # ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
00534 template <> struct ImagePointer<Image_uint32_t_4_ptr> { static const bool value = true; };
00535 # endif
00536 # ifdef BBTK_ITK_IMAGE_TYPE_float
00537 template <> struct ImagePointer<Image_float_4_ptr> { static const bool value = true; };
00538 # endif
00539 # ifdef BBTK_ITK_IMAGE_TYPE_double
00540 template <> struct ImagePointer<Image_double_4_ptr> { static const bool value = true; };
00541 # endif
00542 #endif
00543
00544
00545 }
00546
00547 namespace bbtk
00548 {
00549 BBTK_DEFINE_HUMAN_READABLE_TYPE_NAME(bbitk::anyImagePointer,"anyItkImagePointer");
00550
00551
00552
00553
00554
00555
00556 #define BBTK_HUMAN_READABLE_ITK_IMAGE(TYPE,DIM) \
00557 template <> inline std::string HumanTypeName< bbitk::Image_##TYPE##_##DIM##_ptr >() \
00558 { std::string n("itkImage"); \
00559 n+= HumanTypeName<TYPE>();\
00560 n += std::string(#DIM);\
00561 n += std::string("ptr"); \
00562 return n; } \
00563 template <> inline std::string HumanTypeName< bbitk::Image_##TYPE##_##DIM##_ptr >(const bbitk::Image_##TYPE##_##DIM##_ptr &) \
00564 { std::string n("itkImage");\
00565 n+= HumanTypeName<TYPE>(); \
00566 n += std::string(#DIM); \
00567 n+= std::string("ptr"); \
00568 return n; } \
00569 template <> inline std::string HumanTypeName< bbitk::Image_##TYPE##_##DIM##_cptr >() \
00570 { std::string n("itkImage"); \
00571 n+= HumanTypeName<TYPE>();\
00572 n += std::string(#DIM);\
00573 n += std::string("cptr"); \
00574 return n; } \
00575 template <> inline std::string HumanTypeName< bbitk::Image_##TYPE##_##DIM##_cptr >(const bbitk::Image_##TYPE##_##DIM##_cptr &) \
00576 { std::string n("itkImage");\
00577 n+= HumanTypeName<TYPE>(); \
00578 n += std::string(#DIM); \
00579 n+= std::string("cptr"); \
00580 return n; }
00581
00582
00583
00584
00585
00586
00587 #define BBTK_HUMAN_READABLE_ITK_IMAGES_DIM(DIM) \
00588 BBTK_HUMAN_READABLE_ITK_IMAGE(int8_t,DIM); \
00589 BBTK_HUMAN_READABLE_ITK_IMAGE(uint8_t,DIM); \
00590 BBTK_HUMAN_READABLE_ITK_IMAGE(int16_t,DIM); \
00591 BBTK_HUMAN_READABLE_ITK_IMAGE(uint16_t,DIM); \
00592 BBTK_HUMAN_READABLE_ITK_IMAGE(int32_t,DIM); \
00593 BBTK_HUMAN_READABLE_ITK_IMAGE(uint32_t,DIM); \
00594 BBTK_HUMAN_READABLE_ITK_IMAGE(float,DIM); \
00595 BBTK_HUMAN_READABLE_ITK_IMAGE(double,DIM)
00596
00597 BBTK_HUMAN_READABLE_ITK_IMAGES_DIM(2);
00598 BBTK_HUMAN_READABLE_ITK_IMAGES_DIM(3);
00599 BBTK_HUMAN_READABLE_ITK_IMAGES_DIM(4);
00600
00601
00602
00603 }
00604
00605 #endif
00606 #endif