#-----------------------------------------------------------------------------
#SUBDIRS(void)
-SUBDIRS(wx)
SUBDIRS(std)
+SUBDIRS(wx)
+SUBDIRS(itk)
#-----------------------------------------------------------------------------
#===========================================================================
# UNCOMMENT EACH LIBRARY NEEDED
-# SET(BBTK_PACKAGE_USE_VTK ON)
-# SET(BBTK_PACKAGE_USE_ITK ON)
-# SET(BBTK_PACKAGE_USE_GDCM ON)
-# SET(BBTK_PACKAGE_USE_GSMIS ON)
+# SET(${BBTK_PACKAGE_NAME}_USE_VTK ON)
+SET(${BBTK_PACKAGE_NAME}_USE_ITK ON)
+# SET(${BBTK_PACKAGE_NAME}_USE_GDCM ON)
+# SET(${BBTK_PACKAGE_NAME}_USE_GSMIS ON)
# SET(${BBTK_PACKAGE_NAME}_USE_WXWIDGETS ON)
#===========================================================================
# LIST HERE YOUR INCLUDE DIRECTORIES
# EXCEPT BBTK'S AND THE INCLUDE DIRS THAT WERE SET
# BY INCLUDING A LIBRARY USE FILE
+ ../std/src
)
#===========================================================================
--- /dev/null
+#ifdef _USE_ITK_
+#include "bbitkAnyImageToTypedImage.h"
+#include "bbitkPackage.h"
+
+namespace bbitk
+{
+ //====================================================================
+ BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(AnyImageToTypedImage,
+ bbtk::UserBlackBox);
+ BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(AnyImageToConstTypedImage,
+ bbtk::UserBlackBox);
+ //====================================================================
+
+
+#ifdef BBTK_ITK_IMAGE_DIM_2
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_int8_t_2_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_int16_t_2_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_int32_t_2_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_uint8_t_2_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_uint16_t_2_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_uint32_t_2_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_float_2_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_double_2_ptr);
+# endif
+#endif
+
+
+
+#ifdef BBTK_ITK_IMAGE_DIM_3
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_int8_t_3_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_int16_t_3_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_int32_t_3_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_uint8_t_3_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_uint16_t_3_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_uint32_t_3_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_float_3_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_double_3_ptr);
+# endif
+#endif
+
+
+
+
+#ifdef BBTK_ITK_IMAGE_DIM_4
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_int8_t_4_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_int16_t_4_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_int32_t_4_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_uint8_t_4_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_uint16_t_4_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_uint32_t_4_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_float_4_ptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,AnyImageToTypedImage,Image_double_4_ptr);
+# endif
+#endif
+
+
+#ifdef BBTK_ITK_IMAGE_DIM_2
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_int8_t_2_ptr,Image_int8_t_2_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_int16_t_2_ptr,Image_int16_t_2_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_int32_t_2_ptr,Image_int32_t_2_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_uint8_t_2_ptr,Image_uint8_t_2_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_uint16_t_2_ptr,Image_uint16_t_2_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_uint32_t_2_ptr,Image_uint32_t_2_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_float_2_ptr,Image_float_2_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_double_2_ptr,Image_double_2_cptr);
+# endif
+#endif
+
+#ifdef BBTK_ITK_IMAGE_DIM_3
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_int8_t_3_ptr,Image_int8_t_3_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_int16_t_3_ptr,Image_int16_t_3_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_int32_t_3_ptr,Image_int32_t_3_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_uint8_t_3_ptr,Image_uint8_t_3_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_uint16_t_3_ptr,Image_uint16_t_3_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_uint32_t_3_ptr,Image_uint32_t_3_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_float_3_ptr,Image_float_3_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_double_3_ptr,Image_double_3_cptr);
+# endif
+#endif
+
+#ifdef BBTK_ITK_IMAGE_DIM_4
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_int8_t_4_ptr,Image_int8_t_4_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_int16_t_4_ptr,Image_int16_t_4_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_int32_t_4_ptr,Image_int32_t_4_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_uint8_t_4_ptr,Image_uint8_t_4_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_uint16_t_4_ptr,Image_uint16_t_4_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_uint32_t_4_ptr,Image_uint32_t_4_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_float_4_ptr,Image_float_4_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+ BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(itk,AnyImageToConstTypedImage,Image_double_4_ptr,Image_double_4_cptr);
+# endif
+#endif
+
+
+}
+#endif
--- /dev/null
+#ifdef _USE_ITK_
+
+#ifndef __bbitkAnyImageToTypedImage_h_INCLUDED__
+#define __bbitkAnyImageToTypedImage_h_INCLUDED__
+
+#include "bbtkUserBlackBox.h"
+#include "bbitkImage.h"
+
+namespace bbitk
+{
+
+ //=================================================================
+ // UserBlackBox declaration
+ template <class itkImageTypePointer>
+ class AnyImageToTypedImage : public bbtk::UserBlackBox
+ {
+ BBTK_USER_BLACK_BOX_INTERFACE(AnyImageToTypedImage,
+ bbtk::UserBlackBox);
+ BBTK_DECLARE_INPUT(In,anyImagePointer);
+ BBTK_DECLARE_OUTPUT(Out,itkImageTypePointer);
+ BBTK_PROCESS(DoIt);
+ void DoIt();
+ };
+ //=================================================================
+
+ //=================================================================
+ // UserBlackBox description
+ BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(AnyImageToTypedImage);
+ BBTK_NAME(bbtk::HumanTypeName<anyImagePointer>() + "To"+bbtk::HumanTypeName<T>());
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Transforms a generic itk image ("+
+ bbtk::HumanTypeName<anyImagePointer>()+
+ ") into a typed itk image ("+
+ bbtk::HumanTypeName<T>()+"*)");
+ BBTK_DEFAULT_ADAPTOR();
+ BBTK_TEMPLATE_INPUT(AnyImageToTypedImage,In,
+ "Input generic image",anyImagePointer);
+ BBTK_TEMPLATE_OUTPUT(AnyImageToTypedImage,Out,
+ "Output typed image",T);
+ BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(AnyImageToTypedImage);
+ //=================================================================
+
+ //=================================================================
+ template <class itkImageTypePointer>
+ void AnyImageToTypedImage<itkImageTypePointer>::DoIt()
+ {
+ if ( bbGetInputIn().type() == typeid(itkImageTypePointer) )
+ {
+ bbSetOutputOut ( bbGetInputIn().template unsafe_get < itkImageTypePointer >() );
+ }
+ else
+ {
+ bbtkError(this->bbGetFullName()<<+" : transform of <"
+ <<bbtk::TypeName(bbGetInputIn().type())<<"> into <"
+ <<bbtk::TypeName<itkImageTypePointer>()<<"> not implemented");
+ }
+ }
+ //=================================================================
+
+ //=================================================================
+ // UserBlackBox declaration
+ template <class itkImageTypePointer, class itkImageTypeConstPointer>
+ class AnyImageToConstTypedImage : public bbtk::UserBlackBox
+ {
+ BBTK_USER_BLACK_BOX_INTERFACE(AnyImageToConstTypedImage,
+ bbtk::UserBlackBox);
+ BBTK_DECLARE_INPUT(In,anyImagePointer);
+ BBTK_DECLARE_OUTPUT(Out,itkImageTypeConstPointer);
+ BBTK_PROCESS(DoIt);
+ void DoIt();
+ };
+ //=================================================================
+
+ //=================================================================
+ // UserBlackBox description
+ BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(AnyImageToConstTypedImage);
+ BBTK_NAME("Convert<"+bbtk::TypeName<anyImagePointer>() + "," +
+ bbtk::TypeName<T2>()+">");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Transforms a generic itk image ("+
+ bbtk::TypeName<anyImagePointer>()+
+ ") into a typed itk image ("+
+ bbtk::TypeName<T2>()+"*)");
+ BBTK_DEFAULT_ADAPTOR();
+ BBTK_TEMPLATE2_INPUT(AnyImageToConstTypedImage,In,
+ "Input generic image",anyImagePointer);
+ BBTK_TEMPLATE2_OUTPUT(AnyImageToConstTypedImage,Out,
+ "Output typed image",T2);
+ BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(AnyImageToConstTypedImage);
+ //=================================================================
+
+ //=================================================================
+ template <class itkImageTypePointer, class itkImageTypeConstPointer>
+ void AnyImageToConstTypedImage<itkImageTypePointer,
+ itkImageTypeConstPointer>::DoIt()
+ {
+ if ( bbGetInputIn().type() == typeid(itkImageTypeConstPointer) )
+ {
+ bbSetOutputOut ( bbGetInputIn().template unsafe_get < itkImageTypeConstPointer >() );
+ }
+ else if ( bbGetInputIn().type() == typeid(itkImageTypePointer) )
+ {
+ bbSetOutputOut ( bbGetInputIn().template unsafe_get < itkImageTypePointer >() );
+ }
+ else
+ {
+ bbtkError(this->bbGetFullName()<<+" : transform of <"
+ <<bbtk::TypeName(bbGetInputIn().type())<<"> into <"
+ <<bbtk::TypeName<itkImageTypeConstPointer>()<<"> not implemented");
+ }
+ }
+ //=================================================================
+
+
+}
+#endif
+#endif
--- /dev/null
+#ifdef _USE_ITK_
+
+#include "bbitkBinaryThresholdImageFilter.h"
+#include "bbitkPackage.h"
+namespace bbitk
+{
+
+ BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(BinaryThresholdImageFilter,
+ bbtk::UserBlackBox);
+ BBTK_USER_BLACK_BOX_IMPLEMENTATION(BinaryThresholdImageFilterGeneric,
+ bbtk::UserBlackBox);
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,
+ BinaryThresholdImageFilterGeneric);
+}
+
+// EO namespace bbtk
+
+#endif //_USE_ITK_
+
--- /dev/null
+#ifdef _USE_ITK_
+
+#include "bbtkUserBlackBox.h"
+#include "itkBinaryThresholdImageFilter.h"
+#include "bbitkImage.h"
+
+namespace bbitk
+{
+
+ template <class T>
+ class /*BBTK_EXPORT*/ BinaryThresholdImageFilter
+ :
+ public bbtk::UserBlackBox,
+ public itk::BinaryThresholdImageFilter<T,T>
+ {
+ BBTK_USER_BLACK_BOX_INTERFACE(BinaryThresholdImageFilter,
+ bbtk::UserBlackBox);
+ typedef itk::BinaryThresholdImageFilter<T,T> itkParent;
+ BBTK_DECLARE_ITK_INPUT(itkParent,In,const T*);
+ BBTK_DECLARE_ITK_PARAM(itkParent,LowerThreshold,typename T::PixelType);
+ BBTK_DECLARE_ITK_PARAM(itkParent,UpperThreshold,typename T::PixelType);
+ BBTK_DECLARE_ITK_PARAM(itkParent,InsideValue,typename T::PixelType);
+ BBTK_DECLARE_ITK_PARAM(itkParent,OutsideValue,typename T::PixelType);
+ BBTK_DECLARE_ITK_OUTPUT(itkParent,Out,T*);
+ BBTK_PROCESS(itkParent::Update);
+ void bbDelete() { itkParent::UnRegister(); }
+
+ void bbUserConstructor() { Init(); }
+ void bbUserCopyConstructor() { Init(); }
+ void Init();
+
+ };
+
+ BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter);
+ BBTK_NAME("BinaryThresholdImageFilter<"+bbtk::TypeName<T>()+">");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Binarizes an image by thresholding (bbification of itk::BinaryThresholdImageFilter)");
+ BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,In,"Input image",const T*);
+ BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,LowerThreshold,
+ "Lower threshold",typename T::PixelType);
+ BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,UpperThreshold,
+ "Upper threshold",typename T::PixelType);
+ BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,InsideValue,
+ "Output value for pixels inside thresholds",
+ typename T::PixelType);
+ BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,OutsideValue,
+ "Output value for pixels outside thresholds",
+ typename T::PixelType);
+ BBTK_TEMPLATE_OUTPUT(BinaryThresholdImageFilter,Out,"Output image",T*);
+ BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter);
+
+ //===================================================
+ // Generic "untemplatized" filter
+ //===================================================
+ class /*BBTK_EXPORT*/ BinaryThresholdImageFilterGeneric
+ :
+ public bbtk::UserBlackBox
+ {
+ BBTK_USER_BLACK_BOX_INTERFACE(BinaryThresholdImageFilterGeneric,
+ bbtk::UserBlackBox);
+ BBTK_DECLARE_INPUT(In,anyImagePointer);
+ BBTK_DECLARE_INPUT(LowerThreshold,double);
+ BBTK_DECLARE_INPUT(UpperThreshold,double);
+ BBTK_DECLARE_INPUT(InsideValue,double);
+ BBTK_DECLARE_INPUT(OutsideValue,double);
+ BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
+ BBTK_PROCESS(ProcessSwitch);
+ private :
+ inline void ProcessSwitch();
+ template <class T> void Process();
+ void bbUserConstructor() { Init(); }
+ void bbUserCopyConstructor() { Init(); }
+ void Init();
+ };
+
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric,
+ bbtk::UserBlackBox);
+ BBTK_NAME("BinaryThresholdImageFilter");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Binarizes an image by thresholding (generic bbification of itk::BinaryThresholdImageFilter)");
+ BBTK_INPUT(BinaryThresholdImageFilterGeneric,In,
+ "Input image. Can be any itk::Image<T,D>*",anyImagePointer);
+ BBTK_INPUT(BinaryThresholdImageFilterGeneric,LowerThreshold,
+ "Lower threshold",double);
+ BBTK_INPUT(BinaryThresholdImageFilterGeneric,UpperThreshold,
+ "Upper threshold",double);
+ BBTK_INPUT(BinaryThresholdImageFilterGeneric,InsideValue,
+ "Output value for pixels inside thresholds",double);
+ BBTK_INPUT(BinaryThresholdImageFilterGeneric,OutsideValue,
+ "Output value for pixels outside thresholds",double);
+ BBTK_OUTPUT(BinaryThresholdImageFilterGeneric,Out,
+ "Output image. Of the same type and dimension than the input image",
+ anyImagePointer);
+ BBTK_END_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric);
+
+
+
+ void BinaryThresholdImageFilterGeneric::ProcessSwitch()
+ {
+ BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process);
+ }
+
+ template <class T>
+ void BinaryThresholdImageFilterGeneric::Process()
+ {
+ bbtkDebugMessageInc("Core",9,
+ "bbitk::BinaryThresholdImageFilterGeneric::Process<"
+ <<bbtk::TypeName<T>()<<">()"<<std::endl);
+
+ typedef BinaryThresholdImageFilter<T> FilterType;
+ FilterType* f = FilterType::bbNew("Temp");
+ f->bbSetInputIn( this->bbGetInputIn().get<T*>());
+ f->bbSetInputLowerThreshold ( (typename T::PixelType)
+ this->bbGetInputLowerThreshold() );
+ f->bbSetInputUpperThreshold ( (typename T::PixelType)
+ this->bbGetInputUpperThreshold() );
+ f->bbSetInputInsideValue ( (typename T::PixelType)
+ this->bbGetInputInsideValue() );
+ f->bbSetInputOutsideValue ( (typename T::PixelType)
+ this->bbGetInputOutsideValue() );
+ f->bbExecute();
+ f->bbGetOutputOut()->Register();
+ this->bbSetOutputOut( f->bbGetOutputOut() );
+ f->bbDelete();
+ bbtkDebugDecTab("Core",9);
+ }
+
+ template <class T>
+ void BinaryThresholdImageFilter<T>::Init()
+ {
+ bbSetInputLowerThreshold(0);
+ bbSetInputUpperThreshold(100);
+ bbSetInputInsideValue(255);
+ bbSetInputOutsideValue(0);
+ }
+
+ void BinaryThresholdImageFilterGeneric::Init()
+ {
+ bbSetInputLowerThreshold(0);
+ bbSetInputUpperThreshold(100);
+ bbSetInputInsideValue(255);
+ bbSetInputOutsideValue(0);
+ }
+
+}
+// EO namespace bbtk
+
+#endif
--- /dev/null
+#ifdef _USE_ITK_
+
+#include "bbitkExtractImageFilter.h"
+#include "bbitkPackage.h"
+
+namespace bbitk
+{
+
+ BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ExtractImageFilter,
+ bbtk::UserBlackBox);
+ BBTK_USER_BLACK_BOX_IMPLEMENTATION(ExtractImageFilterGeneric,
+ bbtk::UserBlackBox);
+
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ExtractImageFilterGeneric)
+
+
+}
+// EO namespace bbitk
+
+
+#endif // _USE_ITK_
+
--- /dev/null
+#ifdef _USE_ITK_
+
+#include "bbtkUserBlackBox.h"
+#include "itkExtractImageFilter.h"
+#include "bbitkImage.h"
+#include "bbitkImageRegion.h"
+
+namespace bbitk
+{
+
+
+ template <class T>
+ class /*BBTK_EXPORT*/ ExtractImageFilter
+ :
+ public bbtk::UserBlackBox,
+ public itk::ExtractImageFilter<T,T>
+ {
+ BBTK_USER_BLACK_BOX_INTERFACE(ExtractImageFilter,bbtk::UserBlackBox);
+ typedef itk::ExtractImageFilter<T,T> itkParent;
+
+ BBTK_DECLARE_ITK_INPUT(itkParent,In,const T*);
+ BBTK_DECLARE_ITK_PARAM(itkParent,ExtractionRegion,typename T::RegionType);
+ BBTK_DECLARE_ITK_OUTPUT(itkParent,Out,T*);
+ BBTK_PROCESS(itkParent::Update);
+
+ void bbDelete() { itkParent::UnRegister(); }
+ };
+
+
+ BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(ExtractImageFilter);
+ BBTK_NAME("ExtractImageFilter<"+bbtk::TypeName<T>()+">");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Decrease the image size by cropping the image to the selected region bounds (bbification of itk::ExtractImageFilter)");
+ BBTK_TEMPLATE_INPUT(ExtractImageFilter,In,"Input image",const T*);
+ BBTK_TEMPLATE_INPUT(ExtractImageFilter,ExtractionRegion,"Extraction region",typename T::RegionType);
+ BBTK_TEMPLATE_OUTPUT(ExtractImageFilter,Out,"Output image",T*);
+ BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(ExtractImageFilter);
+
+ //===================================================
+ // Generic "untemplatized" filter
+ //===================================================
+ class /*BBTK_EXPORT*/ ExtractImageFilterGeneric
+ : public bbtk::UserBlackBox
+ {
+ BBTK_USER_BLACK_BOX_INTERFACE(ExtractImageFilterGeneric,
+ bbtk::UserBlackBox);
+ BBTK_DECLARE_INPUT(In,anyImagePointer);
+ BBTK_DECLARE_INPUT(Region,anyImageRegion);
+ BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
+ BBTK_PROCESS(ProcessSwitch);
+ private :
+ inline void ProcessSwitch();
+ template <class T> void Process();
+ };
+
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ExtractImageFilterGeneric,bbtk::UserBlackBox);
+ BBTK_NAME("ExtractImageFilter");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Decrease the image size by cropping the image to the selected region bounds (bbification of itk::ExtractImageFilter)");
+ BBTK_INPUT(ExtractImageFilterGeneric,In,"Input image",anyImagePointer);
+ BBTK_INPUT(ExtractImageFilterGeneric,Region,"Extraction region",anyImageRegion);
+ BBTK_OUTPUT(ExtractImageFilterGeneric,Out,"Output image",anyImagePointer);
+ BBTK_END_DESCRIBE_BLACK_BOX(ExtractImageFilterGeneric);
+ void ExtractImageFilterGeneric::ProcessSwitch()
+ {
+ BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process);
+ }
+
+ template <class T>
+ void ExtractImageFilterGeneric::Process()
+ {
+ bbtkDebugMessageInc("Core",9,
+ "bbitk::ExtractImageFilterGeneric::Process<"
+ <<bbtk::TypeName<T>()<<">()"<<std::endl);
+ typedef T ImageType;
+ typedef ExtractImageFilter<ImageType> FilterType;
+ FilterType* f = FilterType::bbNew("Temp");
+ f->bbSetInputIn( this->bbGetInputIn().unsafe_get<T*>() );
+ f->bbSetInputExtractionRegion ( this->bbGetInputRegion().get<typename T::RegionType>() );
+ f->bbExecute();
+ f->bbGetOutputOut()->Register();
+ this->bbSetOutputOut( f->bbGetOutputOut() );
+ f->bbDelete();
+
+ bbtkDebugDecTab("Core",9);
+ }
+
+}
+// EO namespace bbitk
+
+#endif
--- /dev/null
+#ifdef _USE_ITK_
+
+#include "bbitkImage.h"
+#include "bbstdRelay.h"
+#include "bbitkPackage.h"
+
+namespace bbstd
+{
+
+ //====================================================================
+ BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(Relay,
+ bbtk::UserBlackBox);
+ //====================================================================
+}
+using namespace bbstd;
+namespace bbitk
+{
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,Relay,anyImagePointer);
+} // namespace bbitk
+
+#endif
--- /dev/null
+#ifdef _USE_ITK_
+
+#ifndef __BBITKIMAGE_H_INCLUDED__
+#define __BBITKIMAGE_H_INCLUDED__
+
+#include "itkImage.h"
+#include "bbtkAny.h"
+#include "bbtkSystem.h"
+
+namespace bbitk
+{
+
+ // bbtk typedefs for itk images
+#define BBTK_TYPEDEF_ITK_IMAGE(TYPE,DIM) \
+ typedef itk::Image<TYPE,DIM> Image_##TYPE##_##DIM; \
+ typedef const Image_##TYPE##_##DIM Image_##TYPE##_##DIM##_c; \
+ typedef Image_##TYPE##_##DIM * Image_##TYPE##_##DIM##_ptr; \
+ typedef Image_##TYPE##_##DIM##_c * Image_##TYPE##_##DIM##_cptr;
+
+
+#define BBTK_TYPEDEF_ITK_IMAGES_DIM(DIM) \
+ BBTK_TYPEDEF_ITK_IMAGE(int8_t,DIM); \
+ BBTK_TYPEDEF_ITK_IMAGE(uint8_t,DIM); \
+ BBTK_TYPEDEF_ITK_IMAGE(int16_t,DIM); \
+ BBTK_TYPEDEF_ITK_IMAGE(uint16_t,DIM); \
+ BBTK_TYPEDEF_ITK_IMAGE(int32_t,DIM); \
+ BBTK_TYPEDEF_ITK_IMAGE(uint32_t,DIM); \
+ BBTK_TYPEDEF_ITK_IMAGE(float,DIM); \
+ BBTK_TYPEDEF_ITK_IMAGE(double,DIM)
+
+ BBTK_TYPEDEF_ITK_IMAGES_DIM(2);
+ BBTK_TYPEDEF_ITK_IMAGES_DIM(3);
+ BBTK_TYPEDEF_ITK_IMAGES_DIM(4);
+ //BBTK_TYPEDEF_ITK_IMAGES_DIM(5)
+
+
+
+#define BBTK_BEGIN_TEMPLATE_SWITCH(TYPE_INFO) if (false) {}
+
+#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())<<">"); }
+
+#define BBTK_END_TEMPLATE_SWITCH_MESSAGE(TYPE_INFO,MESSAGE) else { bbtkError(MESSAGE); }
+
+ /// Generic macro which calls a TEMPLATE_FUNCTION instanciated
+ /// on TEMPLATE_TYPE iff TYPE_INFO == typeid(TEST_TYPE).
+ /// This macro must be used (maybe several times) between a pair of BEGIN_TEMPLATE_SWITCH and END_TEMPLATE_SWITCH macros
+#define TEMPLATE_SWITCH(TYPE_INFO,TEST_TYPE,TEMPLATE_FUNCTION,TEMPLATE_TYPE) \
+ else if (TYPE_INFO == typeid(bbitk::TEST_TYPE)) \
+ { TEMPLATE_FUNCTION<bbitk::TEMPLATE_TYPE>(); }
+
+
+// DIMENSION 2
+#ifdef BBTK_ITK_IMAGE_DIM_2
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+# define BBTK_SWITCH_ITK_IMAGE_int8_t_2(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_int8_t_2_##CONST##ptr,FUN,Image_int8_t_2)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_int8_t_2(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+# define BBTK_SWITCH_ITK_IMAGE_int16_t_2(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_int16_t_2_##CONST##ptr,FUN,Image_int16_t_2)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_int16_t_2(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+# define BBTK_SWITCH_ITK_IMAGE_int32_t_2(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_int32_t_2_##CONST##ptr,FUN,Image_int32_t_2)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_int32_t_2(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+# define BBTK_SWITCH_ITK_IMAGE_uint8_t_2(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_uint8_t_2_##CONST##ptr,FUN,Image_uint8_t_2)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_uint8_t_2(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+# define BBTK_SWITCH_ITK_IMAGE_uint16_t_2(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_uint16_t_2_##CONST##ptr,FUN,Image_uint16_t_2)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_uint16_t_2(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+# define BBTK_SWITCH_ITK_IMAGE_uint32_t_2(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_uint32_t_2_##CONST##ptr,FUN,Image_uint32_t_2)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_uint32_t_2(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+# define BBTK_SWITCH_ITK_IMAGE_float_2(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_float_2_##CONST##ptr,FUN,Image_float_2)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_float_2(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+# define BBTK_SWITCH_ITK_IMAGE_double_2(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_double_2_##CONST##ptr,FUN,Image_double_2)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_double_2(TYPE_INFO,FUN,CONST)
+# endif
+#else
+# define BBTK_SWITCH_ITK_IMAGE_int8_t_2(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_int16_t_2(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_int32_t_2(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_uint8_t_2(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_uint16_t_2(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_uint32_t_2(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_float_2(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_double_2(TYPE_INFO,FUN,CONST)
+#endif
+
+
+// DIMENSION 3
+#ifdef BBTK_ITK_IMAGE_DIM_3
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+# define BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_int8_t_3_##CONST##ptr,FUN,Image_int8_t_3)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+# define BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_int16_t_3_##CONST##ptr,FUN,Image_int16_t_3)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+# define BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_int32_t_3_##CONST##ptr,FUN,Image_int32_t_3)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+# define BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_uint8_t_3_##CONST##ptr,FUN,Image_uint8_t_3)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+# define BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_uint16_t_3_##CONST##ptr,FUN,Image_uint16_t_3)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+# define BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_uint32_t_3_##CONST##ptr,FUN,Image_uint32_t_3)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+# define BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_float_3_##CONST##ptr,FUN,Image_float_3)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+# define BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_double_3_##CONST##ptr,FUN,Image_double_3)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,CONST)
+# endif
+#else
+# define BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,CONST)
+#endif
+
+
+ // DIMENSION 4
+#ifdef BBTK_ITK_IMAGE_DIM_4
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+# define BBTK_SWITCH_ITK_IMAGE_int8_t_4(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_int8_t_4_##CONST##ptr,FUN,Image_int8_t_4)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_int8_t_4(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+# define BBTK_SWITCH_ITK_IMAGE_int16_t_4(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_int16_t_4_##CONST##ptr,FUN,Image_int16_t_4)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_int16_t_4(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+# define BBTK_SWITCH_ITK_IMAGE_int32_t_4(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_int32_t_4_##CONST##ptr,FUN,Image_int32_t_4)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_int32_t_4(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+# define BBTK_SWITCH_ITK_IMAGE_uint8_t_4(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_uint8_t_4_##CONST##ptr,FUN,Image_uint8_t_4)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_uint8_t_4(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+# define BBTK_SWITCH_ITK_IMAGE_uint16_t_4(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_uint16_t_4_##CONST##ptr,FUN,Image_uint16_t_4)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_uint16_t_4(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+# define BBTK_SWITCH_ITK_IMAGE_uint32_t_4(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_uint32_t_4_##CONST##ptr,FUN,Image_uint32_t_4)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_uint32_t_4(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+# define BBTK_SWITCH_ITK_IMAGE_float_4(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_float_4_##CONST##ptr,FUN,Image_float_4)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_float_4(TYPE_INFO,FUN,CONST)
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+# define BBTK_SWITCH_ITK_IMAGE_double_4(TYPE_INFO,FUN,CONST) \
+ TEMPLATE_SWITCH(TYPE_INFO,Image_double_4_##CONST##ptr,FUN,Image_double_4)
+# else
+# define BBTK_SWITCH_ITK_IMAGE_double_4(TYPE_INFO,FUN,CONST)
+# endif
+#else
+# define BBTK_SWITCH_ITK_IMAGE_int8_t_4(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_int16_t_4(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_int32_t_4(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_uint8_t_4(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_uint16_t_4(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_uint32_t_4(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_float_4(TYPE_INFO,FUN,CONST)
+# define BBTK_SWITCH_ITK_IMAGE_double_4(TYPE_INFO,FUN,CONST)
+#endif
+
+
+ /// General macro which calls the template function FUN instanciated
+ /// on the right type of itk image depending on the value of TYPE_INFO (which must be of type type_info).
+#define BBTK_TEMPLATE_ITK_IMAGE_SWITCH(TYPE_INFO,FUN) \
+ BBTK_BEGIN_TEMPLATE_SWITCH(TYPE_INFO) \
+ BBTK_SWITCH_ITK_IMAGE_int8_t_2(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_int16_t_2(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_int32_t_2(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_uint8_t_2(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_uint16_t_2(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_uint32_t_2(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_float_2(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_double_2(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_int8_t_4(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_int16_t_4(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_int32_t_4(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_uint8_t_4(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_uint16_t_4(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_uint32_t_4(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_float_4(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_double_4(TYPE_INFO,FUN,) \
+ BBTK_END_TEMPLATE_SWITCH(TYPE_INFO)
+
+ /// General macro which calls the template function FUN instanciated
+ /// on the right type of itk image depending on the value of TYPE_INFO (which must be of type type_info).
+#define BBTK_TEMPLATE_ITK_IMAGE_DIM_3_SWITCH(TYPE_INFO,FUN,ERROR_MESSAGE) \
+ BBTK_BEGIN_TEMPLATE_SWITCH(TYPE_INFO) \
+ BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,) \
+ BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,) \
+ BBTK_END_TEMPLATE_SWITCH_MESSAGE(TYPE_INFO,ERROR_MESSAGE)
+
+
+ /// General macro which calls the template function FUN instanciated
+ /// on the right type of itk image depending on the value of TYPE_INFO (which must be of type type_info).
+
+#define BBTK_TEMPLATE_CONST_ITK_IMAGE_SWITCH(TYPE_INFO,FUN) \
+ BBTK_BEGIN_TEMPLATE_SWITCH(TYPE_INFO) \
+ BBTK_SWITCH_ITK_IMAGE_int8_t_2(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_int16_t_2(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_int32_t_2(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_uint8_t_2(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_uint16_t_2(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_uint32_t_2(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_float_2(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_double_2(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_int8_t_4(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_int16_t_4(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_int32_t_4(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_uint8_t_4(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_uint16_t_4(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_uint32_t_4(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_float_4(TYPE_INFO,FUN,c) \
+ BBTK_SWITCH_ITK_IMAGE_double_4(TYPE_INFO,FUN,c) \
+ BBTK_END_TEMPLATE_SWITCH(TYPE_INFO)
+
+#define BBTK_GITIFPTI_DIM(DIM) \
+ if (pti == typeid(unsigned char)) \
+ return typeid(itk::Image<unsigned char,DIM>*); \
+ if (pti == typeid(unsigned short)) \
+ return typeid(itk::Image<unsigned short,DIM>*); \
+ if (pti == typeid(unsigned int)) \
+ return typeid(itk::Image<unsigned int,DIM>*); \
+ if (pti == typeid(unsigned long)) \
+ return typeid(itk::Image<unsigned long,DIM>*); \
+ if (pti == typeid(signed char)) \
+ return typeid(itk::Image<signed char,DIM>*); \
+ if (pti == typeid(signed short)) \
+ return typeid(itk::Image<signed short,DIM>*); \
+ if (pti == typeid(signed int)) \
+ return typeid(itk::Image<signed int,DIM>*); \
+ if (pti == typeid(signed long)) \
+ return typeid(itk::Image<signed long,DIM>*); \
+ if (pti == typeid(float)) \
+ return typeid(itk::Image<float,DIM>*); \
+ if (pti == typeid(double)) \
+ return typeid(itk::Image<double,DIM>*);
+
+
+ inline bbtk::TypeInfo GetITKImagePtrTypeInfoFromPixelTypeInfoAndDimension(
+ bbtk::TypeInfo pti,
+ unsigned int dim )
+ {
+ if (dim==2) { BBTK_GITIFPTI_DIM(2); }
+ else if (dim==3) { BBTK_GITIFPTI_DIM(3); }
+ else if (dim==4) { BBTK_GITIFPTI_DIM(4); }
+ else
+ {
+ //bbtkGlobalError("GetImageTypeInfoFromPixelTypeInfo : itk::Images not compiled for dim "<<dim);
+ }
+ }
+
+
+#undef BBTK_GITIFPTI_DIM
+
+
+///
+template <typename ValueType>
+class TypeMapping
+{
+public:
+ TypeMapping() {}
+
+ template <typename T>
+ ValueType& value()
+ {
+ return m_map[ (void*)typeid(T).name() ];
+ }
+ template <typename T>
+ ValueType& operator[]( const T& )
+ {
+ return m_map[ (void*)typeid(T).name() ];
+ }
+
+ ValueType& operator[]( const std::type_info& t)
+ {
+ return m_map[ (void*)t.name() ];
+ }
+
+ unsigned int size() const { return m_map.size(); }
+
+ typedef typename std::map<void*, ValueType>::const_iterator const_iterator;
+
+ const_iterator begin() const { return m_map.begin(); }
+ const_iterator end() const { return m_map.end(); }
+
+protected:
+ std::map<void*, ValueType> m_map;
+};
+
+#define BBTK_BUILD_ITK_IMAGE_FUNCTION_MAPPING(MAP,FUN) \
+ MAP.value<bbtk::Image_int8_t_2_ptr>() = FUN<bbtk::Image_int8_t_2_ptr>; \
+ MAP.value<bbtk::Image_int16_t_2_ptr>() = FUN<bbtk::Image_int16_t_2_ptr>; \
+ MAP.value<bbtk::Image_int32_t_2_ptr>() = FUN<bbtk::Image_int32_t_2_ptr>; \
+ MAP.value<bbtk::Image_uint8_t_2_ptr>() = FUN<bbtk::Image_uint8_t_2_ptr>; \
+ MAP.value<bbtk::Image_uint16_t_2_ptr>() = FUN<bbtk::Image_uint16_t_2_ptr>; \
+ MAP.value<bbtk::Image_uint32_t_2_ptr>() = FUN<bbtk::Image_uint32_t_2_ptr>; \
+ MAP.value<bbtk::Image_float_2_ptr>() = FUN<bbtk::Image_float_2_ptr>; \
+ MAP.value<bbtk::Image_double_2_ptr>() = FUN<bbtk::Image_double_2_ptr>; \
+ MAP.value<bbtk::Image_int8_t_3_ptr>() = FUN<bbtk::Image_int8_t_3_ptr>; \
+ MAP.value<bbtk::Image_int16_t_3_ptr>() = FUN<bbtk::Image_int16_t_3_ptr>; \
+ MAP.value<bbtk::Image_int32_t_3_ptr>() = FUN<bbtk::Image_int32_t_3_ptr>; \
+ MAP.value<bbtk::Image_uint8_t_3_ptr>() = FUN<bbtk::Image_uint8_t_3_ptr>; \
+ MAP.value<bbtk::Image_uint16_t_3_ptr>() = FUN<bbtk::Image_uint16_t_3_ptr>; \
+ MAP.value<bbtk::Image_uint32_t_3_ptr>() = FUN<bbtk::Image_uint32_t_3_ptr>; \
+ MAP.value<bbtk::Image_float_3_ptr>() = FUN<bbtk::Image_float_3_ptr>; \
+ MAP.value<bbtk::Image_double_3_ptr>() = FUN<bbtk::Image_double_3_ptr>; \
+ MAP.value<bbtk::Image_int8_t_4_ptr>() = FUN<bbtk::Image_int8_t_4_ptr>; \
+ MAP.value<bbtk::Image_int16_t_4_ptr>() = FUN<bbtk::Image_int16_t_4_ptr>; \
+ MAP.value<bbtk::Image_int32_t_4_ptr>() = FUN<bbtk::Image_int32_t_4_ptr>; \
+ MAP.value<bbtk::Image_uint8_t_4_ptr>() = FUN<bbtk::Image_uint8_t_4_ptr>; \
+ MAP.value<bbtk::Image_uint16_t_4_ptr>() = FUN<bbtk::Image_uint16_t_4_ptr>; \
+ MAP.value<bbtk::Image_uint32_t_4_ptr>() = FUN<bbtk::Image_uint32_t_4_ptr>; \
+ MAP.value<bbtk::Image_float_4_ptr>() = FUN<bbtk::Image_float_4_ptr>; \
+ MAP.value<bbtk::Image_double_4_ptr>() = FUN<bbtk::Image_double_4_ptr>;
+
+ //=======================================================================
+
+
+ //=======================================================================
+ // Type traits ImagePointer to define bbtk::any<ImagePointer>
+ /// The TypeTraits for all itk::Image pointer types
+ template <typename T> struct ImagePointer { static const bool value = false; };
+
+ typedef bbtk::any<ImagePointer> anyImagePointer;
+
+ // Specialisations for instantiated image types
+ // DIMENSION 2
+#ifdef BBTK_ITK_IMAGE_DIM_2
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+ template <> struct ImagePointer<Image_int8_t_2_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+ template <> struct ImagePointer<Image_int16_t_2_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+ template <> struct ImagePointer<Image_int32_t_2_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+ template <> struct ImagePointer<Image_uint8_t_2_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
+ template <> struct ImagePointer<Image_uint16_t_2_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+ template <> struct ImagePointer<Image_uint32_t_2_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+ template <> struct ImagePointer<Image_float_2_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+ template <> struct ImagePointer<Image_double_2_ptr> { static const bool value = true; };
+# endif
+#endif
+
+
+
+#ifdef BBTK_ITK_IMAGE_DIM_3
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+ template <> struct ImagePointer<Image_int8_t_3_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+ template <> struct ImagePointer<Image_int16_t_3_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+ template <> struct ImagePointer<Image_int32_t_3_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+ template <> struct ImagePointer<Image_uint8_t_3_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
+ template <> struct ImagePointer<Image_uint16_t_3_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+ template <> struct ImagePointer<Image_uint32_t_3_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+ template <> struct ImagePointer<Image_float_3_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+ template <> struct ImagePointer<Image_double_3_ptr> { static const bool value = true; };
+# endif
+#endif
+
+
+
+#ifdef BBTK_ITK_IMAGE_DIM_4
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+ template <> struct ImagePointer<Image_int8_t_4_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+ template <> struct ImagePointer<Image_int16_t_4_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+ template <> struct ImagePointer<Image_int32_t_4_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+ template <> struct ImagePointer<Image_uint8_t_4_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
+ template <> struct ImagePointer<Image_uint16_t_4_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+ template <> struct ImagePointer<Image_uint32_t_4_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+ template <> struct ImagePointer<Image_float_4_ptr> { static const bool value = true; };
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+ template <> struct ImagePointer<Image_double_4_ptr> { static const bool value = true; };
+# endif
+#endif
+
+
+} // namespace bbitk
+
+namespace bbtk
+{
+ BBTK_DEFINE_HUMAN_READABLE_TYPE_NAME(bbitk::anyImagePointer,"anyItkImagePointer");
+// BBTK_DEFINE_HUMAN_READABLE_TYPE_NAME(bbitk::Image_double_2_ptr,"itkImageDouble3ptr");
+// BBTK_DEFINE_HUMAN_READABLE_TYPE_NAME(bbitk::Image_double_3_ptr,"itkImageDouble3ptr");
+
+ // Human readable names for itk images
+// #define BBTK_HUMAN_READABLE_ITK_IMAGE_NAME(TYPE,DIM) std::string("itkImage")+HumanTypeName<TYPE>()+std::string(#DIM)+std::string("ptr")
+
+#define BBTK_HUMAN_READABLE_ITK_IMAGE(TYPE,DIM) \
+template <> inline std::string HumanTypeName< bbitk::Image_##TYPE##_##DIM##_ptr >() \
+ { std::string n("itkImage"); \
+ n+= HumanTypeName<TYPE>();\
+ n += std::string(#DIM);\
+n += std::string("ptr"); \
+ return n; } \
+ template <> inline std::string HumanTypeName< bbitk::Image_##TYPE##_##DIM##_ptr >(const bbitk::Image_##TYPE##_##DIM##_ptr &) \
+ { std::string n("itkImage");\
+ n+= HumanTypeName<TYPE>(); \
+ n += std::string(#DIM); \
+n+= std::string("ptr"); \
+ return n; }
+
+//BBTK_HUMAN_READABLE_ITK_IMAGE(int8_t,2);
+
+// BBTK_DEFINE_HUMAN_READABLE_TYPE_NAME(bbitk::Image_##TYPE##_##DIM##_ptr,BBTK_HUMAN_READABLE_ITK_IMAGE_NAME(TYPE,DIM) )
+
+
+#define BBTK_HUMAN_READABLE_ITK_IMAGES_DIM(DIM) \
+ BBTK_HUMAN_READABLE_ITK_IMAGE(int8_t,DIM); \
+ BBTK_HUMAN_READABLE_ITK_IMAGE(uint8_t,DIM); \
+ BBTK_HUMAN_READABLE_ITK_IMAGE(int16_t,DIM); \
+ BBTK_HUMAN_READABLE_ITK_IMAGE(uint16_t,DIM); \
+ BBTK_HUMAN_READABLE_ITK_IMAGE(int32_t,DIM); \
+ BBTK_HUMAN_READABLE_ITK_IMAGE(uint32_t,DIM); \
+ BBTK_HUMAN_READABLE_ITK_IMAGE(float,DIM); \
+ BBTK_HUMAN_READABLE_ITK_IMAGE(double,DIM)
+
+ BBTK_HUMAN_READABLE_ITK_IMAGES_DIM(2);
+ BBTK_HUMAN_READABLE_ITK_IMAGES_DIM(3);
+ BBTK_HUMAN_READABLE_ITK_IMAGES_DIM(4);
+ //BBTK_HUMAN_READABLE_ITK_IMAGES_DIM(5)
+
+
+} // namespace bbtk
+
+#endif
+#endif
--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbitkImageProperties.cxx,v $
+ Language: C++
+ Date: $Date: 2008/02/05 12:03:01 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+/**
+ * \file
+ * \brief
+ */
+#ifdef _USE_ITK_
+
+#include "bbitkImageProperties.h"
+#include "bbitkPackage.h"
+
+namespace bbitk
+{
+ BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageProperties,bbtk::UserBlackBox);
+
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageProperties);
+
+
+
+
+ void ImageProperties::DoIt()
+ {
+ BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(),DoIt);
+ }
+
+
+
+ /**
+ Template Processing
+ */
+ template<class itkImageType>
+ void ImageProperties::DoIt()
+ {
+ bbtkDebugMessageInc("Core",9,"bbitk::ImageProperties::DoIt<"
+ <<bbtk::TypeName<itkImageType>()
+ <<">()"<<std::endl);
+
+ itkImageType* im = bbGetInputIn().get<itkImageType*>();
+ unsigned int dim = im->GetImageDimension();
+
+ bbSetOutputTypeName(bbtk::TypeName<typename itkImageType::PixelType>());
+ bbSetOutputDimension(dim);
+ const typename itkImageType::RegionType& r =im->GetLargestPossibleRegion();
+ bbSetOutputLargestPossibleRegion(r);
+
+ const typename itkImageType::IndexType& ind = r.GetIndex();
+ std::vector<int> vind;
+ for (int i=0;i<dim;++i) vind.push_back(ind[i]);
+ bbSetOutputIndex(vind);
+
+ const typename itkImageType::SizeType& sz = r.GetSize();
+ std::vector<int> vsz;
+ for (int i=0;i<dim;++i) vsz.push_back(sz[i]);
+ bbSetOutputSize(vsz);
+
+ typename itkImageType::SpacingType sp = im->GetSpacing();
+ std::vector<float> vsp;
+ for (int i=0;i<dim;++i) vsp.push_back(sp[i]);
+ bbSetOutputSpacing(vsp);
+
+ bbtkDebugDecTab("Core",9);
+ }
+
+
+
+
+
+
+}
+// eo namespace bbtk
+
+#endif
--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbitkImageProperties.h,v $
+ Language: C++
+ Date: $Date: 2008/02/05 12:03:01 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*//**
+/**
+ * \file
+ * \brief class ITKImageProperties : generic ITKImage reader
+ */
+/**
+ * \class bbtk::ITKImageProperties
+ * \brief Generic ITKImage reader
+ */
+#ifdef _USE_ITK_
+
+#ifndef __bbtkITKImageProperties_h__
+#define __bbtkITKImageProperties_h__
+
+#include "bbtkUserBlackBox.h"
+#include "bbitkImage.h"
+#include "bbitkImageRegion.h"
+
+namespace bbitk
+{
+
+ class ImageProperties : public bbtk::UserBlackBox
+ {
+
+ BBTK_USER_BLACK_BOX_INTERFACE(ImageProperties,
+ bbtk::UserBlackBox);
+
+ BBTK_DECLARE_INPUT(In,anyImagePointer);
+ BBTK_DECLARE_OUTPUT(TypeName,std::string);
+ BBTK_DECLARE_OUTPUT(Dimension,unsigned int);
+ BBTK_DECLARE_OUTPUT(LargestPossibleRegion,anyImageRegion);
+ BBTK_DECLARE_OUTPUT(Index,std::vector<int>);
+ BBTK_DECLARE_OUTPUT(Size,std::vector<int>);
+ BBTK_DECLARE_OUTPUT(Spacing,std::vector<float>);
+ BBTK_PROCESS(DoIt);
+ void DoIt();
+
+ private:
+ // Template doit method
+ template<class ImageType> void DoIt();
+ };
+
+
+ //=================================================================
+ // UserBlackBox description
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageProperties,bbtk::UserBlackBox);
+ BBTK_NAME("ImageProperties");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Extracts the different properties of an image (type, dimension, size, spacing, ...)");
+ BBTK_INPUT(ImageProperties,In,"Input image",anyImagePointer);
+ BBTK_OUTPUT(ImageProperties,TypeName,"Pixel type name",std::string);
+ BBTK_OUTPUT(ImageProperties,Dimension,"Dimension",unsigned int);
+ BBTK_OUTPUT(ImageProperties,LargestPossibleRegion,"Global extent of the image",anyImageRegion);
+ BBTK_OUTPUT(ImageProperties,Index,"Origin of the image",std::vector<int>);
+ BBTK_OUTPUT(ImageProperties,Size,"Size in each dimension",std::vector<int>);
+ BBTK_OUTPUT(ImageProperties,Spacing,"Size of the voxels",std::vector<float>);
+ BBTK_END_DESCRIBE_BLACK_BOX(ImageProperties);
+ //=================================================================
+
+
+}
+//namespace bbitk
+#endif
+
+#endif
--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbitkImageReader.cxx,v $
+ Language: C++
+ Date: $Date: 2008/02/05 12:03:01 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+/**
+ * \file
+ * \brief
+ */
+#ifdef _USE_ITK_
+
+#include "bbitkImageReader.h"
+#include "bbitkPackage.h"
+#include "itkImageFileReader.h"
+
+namespace bbitk
+{
+ BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageReader,bbtk::UserBlackBox);
+
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageReader);
+
+
+
+
+ void ImageReader::Read()
+ {
+ std::string filename = bbGetInputFilename();
+
+ itk::ImageIOBase::Pointer genericReader =
+ itk::ImageIOFactory::CreateImageIO(filename.c_str(),
+ itk::ImageIOFactory::ReadMode);
+ if (!genericReader)
+ {
+ bbtkError("File format unknown (while reading \"" << filename << "\")");
+ }
+ genericReader->SetFileName(filename.c_str());
+ genericReader->ReadImageInformation();
+
+ bbtk::TypeInfo typ = GetITKImagePtrTypeInfoFromPixelTypeInfoAndDimension(genericReader->GetComponentTypeInfo(), genericReader->GetNumberOfDimensions());
+
+ BBTK_TEMPLATE_ITK_IMAGE_SWITCH( typ, Read);
+ }
+
+
+
+ /**
+ Template Processing
+ */
+ template<class itkImageType>
+ void ImageReader::Read()
+ {
+ bbtkDebugMessageInc("Core",9,"itkImageReader<"<<
+ bbtk::TypeName<itkImageType>()
+ <<">::Read()"<<std::endl);
+
+ typedef itk::ImageFileReader< itkImageType > itkReaderType;
+
+ typename itkReaderType::Pointer reader = itkReaderType::New();
+ std::string filename = bbGetInputFilename();
+ reader->SetFileName(filename.c_str());
+ try { reader->Update(); }
+ catch( std::exception& e )
+ {
+ bbtkError("could not read image \""<< filename << "\" : "<<e.what());
+ }
+
+ reader->GetOutput()->Register();
+ bbSetOutputOut( reader->GetOutput() );
+
+ bbtkDebugDecTab("Core",9);
+ }
+
+
+
+
+
+
+}
+// eo namespace bbtk
+
+#endif
--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbitkImageReader.h,v $
+ Language: C++
+ Date: $Date: 2008/02/05 12:03:01 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*//**
+/**
+ * \file
+ * \brief class ITKImageReader : generic ITKImage reader
+ */
+/**
+ * \class bbtk::ITKImageReader
+ * \brief Generic ITKImage reader
+ */
+#ifdef _USE_ITK_
+
+#ifndef __bbitkImageReader_h_INCLUDED__
+#define __bbitkImageReader_h_INCLUDED__
+
+#include "bbtkUserBlackBox.h"
+#include "bbitkImage.h"
+
+namespace bbitk
+{
+
+ class ImageReader : public bbtk::UserBlackBox
+ {
+
+ BBTK_USER_BLACK_BOX_INTERFACE(ImageReader,
+ bbtk::UserBlackBox);
+
+ BBTK_DECLARE_INPUT(Filename,std::string);
+ BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
+ BBTK_PROCESS(Read);
+ void Read();
+
+ private:
+ // Template read method
+ template<class itkImageType> void Read();
+ };
+
+
+ //=================================================================
+ // UserBlackBox description
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageReader,bbtk::UserBlackBox);
+ BBTK_NAME("ImageReader");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Generic itk image reader");
+ BBTK_INPUT(ImageReader,Filename,
+ "filename with complete path",std::string);
+ BBTK_OUTPUT(ImageReader,Out,"Output image",anyImagePointer);
+ BBTK_END_DESCRIBE_BLACK_BOX(ImageReader);
+ //=================================================================
+
+
+}
+//namespace bbtk
+#endif
+
+#endif
--- /dev/null
+#ifdef _USE_ITK_
+
+#include "bbitkImageRegion.h"
+#include "bbitkPackage.h"
+
+namespace bbitk
+{
+
+ BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageRegionCreator,
+ bbtk::UserBlackBox);
+
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageRegionCreator);
+
+
+ void ImageRegionCreator::DoIt()
+ {
+ const std::vector<long>& index = bbGetInputIndex();
+ const std::vector<long>& size = bbGetInputSize();
+ // std::cout<< "isize="<<index.size()<<std::endl;
+ // std::cout<< "ssize="<<size.size()<<std::endl;
+ unsigned long maxs = index.size() > size.size() ? index.size() : size.size();
+ switch (maxs)
+ {
+ case 2 : DoIt<2>(); break;
+ case 3 : DoIt<3>(); break;
+ case 4 : DoIt<4>(); break;
+ default : bbtkError("ImageRegionCreator : cannot build a region of dimension "<<maxs);
+ }
+
+
+ }
+
+ template <unsigned int Dimension>
+ void ImageRegionCreator::DoIt()
+ {
+ std::vector<long> index = bbGetInputIndex();
+ std::vector<long> size = bbGetInputSize();
+ // std::cout<< "isize="<<index.size()<<std::endl;
+ // std::cout<< "ssize="<<size.size()<<std::endl;
+
+ int ds = index.size() - size.size();
+ if (ds<0)
+ {
+ for (int i=0;i<-ds;++i)
+ index.push_back(0);
+ }
+ else
+ {
+ for (int i=0;i<ds;++i) size.push_back(0);
+ }
+
+ typename itk::ImageRegion<Dimension>::IndexType I;
+ typename itk::ImageRegion<Dimension>::SizeType S;
+
+ std::vector<long>::const_iterator ii,si;
+ int d(0);
+ for (ii=index.begin(), si=size.begin();
+ ii!=index.end(); ++ii, ++si, ++d)
+ {
+ I[d] = *ii;
+ S[d] = *si;
+ // std::cout << "o="<<*ii<<" d="<<*si<<std::endl;
+ }
+
+
+ bbSetOutputOut ( itk::ImageRegion<Dimension>(I,S) );
+ }
+
+}
+// eo namespace
+
+#endif
--- /dev/null
+#ifdef _USE_ITK_
+
+#ifndef __bbitkImageRegion_h_INCLUDED__
+#define __bbitkImageRegion_h_INCLUDED__
+
+#include "itkImageRegion.h"
+#include "bbtkMessageManager.h"
+#include "bbtkAny.h"
+#include "bbtkUserBlackBox.h"
+
+namespace bbitk
+{
+ //=======================================================================
+ /// Type traits ImageRegion to define bbtk::any<ImageRegion>
+ template <typename T> struct ImageRegion { static const bool value = false; };
+ // Specialisations for instantiated image types
+#ifdef BBTK_ITK_IMAGE_DIM_2
+ typedef itk::ImageRegion<2> ImageRegion_2;
+ template <> struct ImageRegion<ImageRegion_2> { static const bool value = true; };
+#endif
+#ifdef BBTK_ITK_IMAGE_DIM_3
+ typedef itk::ImageRegion<3> ImageRegion_3;
+ template <> struct ImageRegion<ImageRegion_3> { static const bool value = true; };
+#endif
+#ifdef BBTK_ITK_IMAGE_DIM_4
+ typedef itk::ImageRegion<4> ImageRegion_4;
+ template <> struct ImageRegion<ImageRegion_4> { static const bool value = true; };
+#endif
+
+ ///
+ typedef bbtk::any<ImageRegion> anyImageRegion;
+} // namespace bbitk
+
+namespace bbtk
+{
+ /// Human readable name for bbtk::any<bbitk::ImageRegion>
+ BBTK_DEFINE_HUMAN_READABLE_TYPE_NAME(bbitk::anyImageRegion,"anyItkImageRegion");
+} // namespace bbtk
+
+
+
+namespace bbitk
+{
+ //=======================================================================
+ /// Black Box which creates an anyImageRegion
+ class /*BBTK_EXPORT*/ ImageRegionCreator
+ : public bbtk::UserBlackBox
+ {
+ BBTK_USER_BLACK_BOX_INTERFACE(ImageRegionCreator,bbtk::UserBlackBox);
+ BBTK_DECLARE_INPUT(Index,std::vector<long>);
+ BBTK_DECLARE_INPUT(Size,std::vector<long>);
+ BBTK_DECLARE_OUTPUT(Out,anyImageRegion);
+ BBTK_PROCESS(DoIt);
+ private:
+ void DoIt();
+ template <unsigned int Dimension> void DoIt();
+ };
+
+
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageRegionCreator,bbtk::UserBlackBox);
+ BBTK_NAME("ImageRegion");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Creates a generic ImageRegion ("+bbtk::TypeName<anyImageRegion>()+") from two vectors providing the index and size of the region. The dimension D of the actual itk::ImageRegion<D> created is the max of the sizes of Index and Size (the smallest vector is padded by zeros).");
+ typedef std::vector<long> vectoroflong;
+ BBTK_INPUT(ImageRegionCreator,Index,"Vector of region indices",
+ vectoroflong);
+ BBTK_INPUT(ImageRegionCreator,Size,"Vector of region sizes",
+ vectoroflong);
+ BBTK_OUTPUT(ImageRegionCreator,Out,"Output generic region",anyImageRegion);
+ BBTK_END_DESCRIBE_BLACK_BOX(ImageRegionCreator);
+
+} // namespace bbitk
+
+
+#endif
+#endif
--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbitkImageSeriesReader.cxx,v $
+ Language: C++
+ Date: $Date: 2008/02/05 12:03:01 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+/**
+ * \file
+ * \brief
+ */
+#ifdef _USE_ITK_
+
+#include "bbitkImageSeriesReader.h"
+#include "bbitkPackage.h"
+#include "itkImageSeriesReader.h"
+
+namespace bbitk
+{
+ BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageSeriesReader,bbtk::UserBlackBox);
+
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageSeriesReader);
+
+
+
+
+ void ImageSeriesReader::Read()
+ {
+ const std::vector<std::string>& filenames = bbGetInputFileNames();
+ if (!filenames.size())
+ {
+ bbtkError("Void vector passed to "<<bbGetFullName());
+ }
+
+ std::string filename = filenames[0];
+
+ itk::ImageIOBase::Pointer genericReader =
+ itk::ImageIOFactory::CreateImageIO(filename.c_str(),
+ itk::ImageIOFactory::ReadMode);
+ if (!genericReader)
+ {
+ bbtkError(bbGetFullName()<<" : File format unknown (while reading \"" << filename << "\")");
+ }
+ genericReader->SetFileName(filename.c_str());
+ genericReader->ReadImageInformation();
+
+ bbtk::TypeInfo typ = GetITKImagePtrTypeInfoFromPixelTypeInfoAndDimension(genericReader->GetComponentTypeInfo(), genericReader->GetNumberOfDimensions());
+
+ BBTK_TEMPLATE_ITK_IMAGE_SWITCH(typ,Read);
+
+ }
+
+
+
+ /**
+ Template Processing
+ */
+ template<class T>
+ void ImageSeriesReader::Read()
+ {
+ bbtkDebugMessageInc("Core",9,"bbitk::ImageSeriesReader<"
+ <<bbtk::TypeName<T>()
+ <<">::Read()"<<std::endl);
+
+
+
+ typedef T itkImageType;
+ typedef itk::ImageSeriesReader< itkImageType > itkReaderType;
+
+ typename itkReaderType::Pointer reader = itkReaderType::New();
+ const std::vector<std::string>& filenames = bbGetInputFileNames();
+ reader->SetFileNames(filenames);
+ try { reader->Update(); }
+ catch( std::exception& e )
+ {
+ bbtkError("could not read image series : "<<e.what());
+ }
+
+ reader->GetOutput()->Register();
+ bbSetOutputOut ( reader->GetOutput() );
+
+ bbtkDebugDecTab("Core",9);
+ }
+
+
+
+
+
+
+}
+// eo namespace bbtk
+
+#endif
--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbitkImageSeriesReader.h,v $
+ Language: C++
+ Date: $Date: 2008/02/05 12:03:02 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*//**
+/**
+ * \file
+ * \brief class ITKImageSeriesReader : generic ITKImage reader
+ */
+/**
+ * \class bbtk::ITKImageSeriesReader
+ * \brief Generic ITKImage reader
+ */
+#ifdef _USE_ITK_
+
+#ifndef __bbitkImageSeriesReader_h_INCLUDED__
+#define __bbitkImageSeriesReader_h_INCLUDED__
+
+#include "bbtkUserBlackBox.h"
+#include "bbitkImage.h"
+
+namespace bbitk
+{
+
+ class ImageSeriesReader : public bbtk::UserBlackBox
+ {
+
+ BBTK_USER_BLACK_BOX_INTERFACE(ImageSeriesReader,
+ bbtk::UserBlackBox);
+
+ BBTK_DECLARE_INPUT(FileNames,std::vector<std::string>);
+ BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
+ BBTK_PROCESS(Read);
+ void Read();
+
+ private:
+ // Template read method
+ template<class T> void Read();
+ };
+
+
+ //=================================================================
+ // UserBlackBox description
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageSeriesReader,bbtk::UserBlackBox);
+ BBTK_NAME("ImageSeriesReader");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Generic itk image series reader");
+ typedef std::vector<std::string> vectorofstring;
+ BBTK_INPUT(ImageSeriesReader,FileNames,
+ "vector of file names with complete paths",vectorofstring);
+ BBTK_OUTPUT(ImageSeriesReader,Out,"Output itk::image<T,D> with type T and dimension D determined by the content of the files",anyImagePointer);
+ BBTK_END_DESCRIBE_BLACK_BOX(ImageSeriesReader);
+ //=================================================================
+
+
+}
+//namespace bbtk
+#endif
+
+#endif
--- /dev/null
+#ifdef _USE_ITK_
+
+#include "bbstdToString.h"
+#include "bbitkImage.h"
+#include "bbitkPackage.h"
+#include <sstream>
+
+namespace bbstd
+{
+
+
+ //====================================================================
+ BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ToString,
+ bbtk::UserBlackBox);
+ //====================================================================
+
+ //====================================================================
+ template <> void ToString<bbtk::any<bbitk::ImagePointer> > ::DoIt()
+ {
+ std::ostringstream s;
+ itk::Object* o1 = bbGetInputIn().unsafe_get<itk::Object*>();
+ o1->Print(s);
+
+ bbSetOutputOut( s.str() );
+ }
+ //====================================================================
+} // namespace bbstd
+
+
+using namespace bbstd;
+namespace bbitk
+{
+ // typedef bbstd::ToString ToString;
+ //====================================================================
+ // Add the specialized adaptors to the package
+ typedef bbitk::anyImagePointer anyItkImagePointer;
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,ToString,
+ anyItkImagePointer);
+ //typedef const bbtk::itkImage* itkImageConstPointer;
+ //BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itkBase,ScalarToString,itkImageConstPointer);
+
+}
+
+
+#endif //_USE_ITK_
--- /dev/null
+/*
+#include "ScalarToString.h"
+#include "ITKImage.h"
+#include "bbPackageITKBase.h"
+
+//====================================================================
+template <> void ScalarToString<itkImage*> ::DoIt()
+{
+ bbSetOutputOut( bbGetInputIn()->GetInfoString() );
+}
+//====================================================================
+
+//====================================================================
+// Add the specialized adaptors to the package
+typedef itkImage* itkImagePointer;
+BBTK_ADD_TEMPLATE_ADAPTOR_TO_PACKAGE(ITKBase,ScalarToString,itkImagePointer);
+*/
--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbitkImageWriter.cxx,v $
+ Language: C++
+ Date: $Date: 2008/02/05 12:03:02 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+/**
+ * \file
+ * \brief
+ */
+#ifdef _USE_ITK_
+
+#include "bbitkImageWriter.h"
+#include "bbitkPackage.h"
+#include "itkImageFileWriter.h"
+
+namespace bbitk
+{
+ BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageWriter,bbtk::UserBlackBox);
+
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageWriter);
+
+
+
+
+ void ImageWriter::Write()
+ {
+ BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(),Write);
+ }
+
+
+
+ /**
+ Template Processing
+ */
+ template<class itkImageType>
+ void ImageWriter::Write()
+ {
+ bbtkDebugMessageInc("Core",9,"bbitk::ImageWriter::Write<"
+ <<bbtk::TypeName<itkImageType>()
+ <<">()"<<std::endl);
+
+ typedef itk::ImageFileWriter< itkImageType > itkWriterType;
+ typename itkWriterType::Pointer writer = itkWriterType::New();
+ writer->SetInput(bbGetInputIn().unsafe_get<const itkImageType*>());
+ writer->SetFileName(bbGetInputFilename().c_str());
+
+ try { writer->Update(); }
+ catch( std::exception & e )
+ {
+ bbtkError("could not write image \""<< bbGetInputFilename()
+ << "\" : "<<e.what());
+ }
+
+ bbtkDebugDecTab("Core",9);
+ }
+
+
+
+
+
+
+}
+// eo namespace bbtk
+
+#endif
--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbitkImageWriter.h,v $
+ Language: C++
+ Date: $Date: 2008/02/05 12:03:02 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See Doc/License.txt or
+ http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*//**
+/**
+ * \file
+ * \brief class ITKImageWriter : generic ITKImage reader
+ */
+/**
+ * \class bbtk::ITKImageWriter
+ * \brief Generic ITKImage reader
+ */
+#ifdef _USE_ITK_
+
+#ifndef __bbtkITKImageWriter_h__
+#define __bbtkITKImageWriter_h__
+
+#include "bbtkUserBlackBox.h"
+#include "bbitkImage.h"
+
+namespace bbitk
+{
+
+ class ImageWriter : public bbtk::UserBlackBox
+ {
+
+ BBTK_USER_BLACK_BOX_INTERFACE(ImageWriter,
+ bbtk::UserBlackBox);
+
+ BBTK_DECLARE_INPUT(Filename,std::string);
+ BBTK_DECLARE_INPUT(In,anyImagePointer);
+ BBTK_PROCESS(Write);
+ void Write();
+
+ private:
+ // Template write method
+ template<class ImageType> void Write();
+ };
+
+
+ //=================================================================
+ // UserBlackBox description
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ImageWriter,bbtk::UserBlackBox);
+ BBTK_NAME("ImageWriter");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Generic itk image writer");
+ BBTK_INPUT(ImageWriter,Filename,
+ "filename with complete path",std::string);
+ BBTK_INPUT(ImageWriter,In,"Image to write",anyImagePointer);
+ BBTK_END_DESCRIBE_BLACK_BOX(ImageWriter);
+ //=================================================================
+
+
+}
+//namespace bbitk
+#endif
+
+#endif // _USE_ITK_
--- /dev/null
+#ifdef _USE_ITK_
+
+#include "bbitkResampleImageFilter.h"
+#include "bbitkPackage.h"
+namespace bbitk
+{
+
+ BBTK_USER_BLACK_BOX_IMPLEMENTATION(ResampleImageFilter,bbtk::UserBlackBox);
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ResampleImageFilter);
+}
+
+// EO namespace bbitk
+
+#endif //_USE_ITK_
+
--- /dev/null
+#ifdef _USE_ITK_
+
+#include <math.h>
+#include "bbtkUserBlackBox.h"
+#include "itkResampleImageFilter.h"
+#include "bbitkImage.h"
+#include "itkNearestNeighborInterpolateImageFunction.h"
+#include "itkLinearInterpolateImageFunction.h"
+#include "itkBSplineInterpolateImageFunction.h"
+
+namespace bbitk
+{
+
+
+ class /*BBTK_EXPORT*/ ResampleImageFilter
+ :
+ public bbtk::UserBlackBox
+ {
+ BBTK_USER_BLACK_BOX_INTERFACE(ResampleImageFilter,
+ bbtk::UserBlackBox);
+ BBTK_DECLARE_INPUT(In,anyImagePointer);
+ BBTK_DECLARE_INPUT(Spacing,std::vector<double>);
+ BBTK_DECLARE_INPUT(Interpolation,std::string);
+ BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
+ BBTK_PROCESS(ProcessSwitch);
+ private :
+ inline void ProcessSwitch();
+ template <class T> void Process();
+ void bbUserConstructor() { Init(); }
+ void bbUserCopyConstructor() { Init(); }
+ void Init();
+ itk::Object* mOutput;
+ };
+
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ResampleImageFilter,
+ bbtk::UserBlackBox);
+ BBTK_NAME("ResampleImageFilter");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Resamples an image");
+ BBTK_INPUT(ResampleImageFilter,In,
+ "Input image. Can be any itk::Image<T,D>*",anyImagePointer);
+ BBTK_INPUT(ResampleImageFilter,Spacing,
+ "Spacing",std::vector<double>);
+ BBTK_INPUT(ResampleImageFilter,Interpolation,
+ "Interpolation",std::string);
+ BBTK_OUTPUT(ResampleImageFilter,Out,
+ "Output image. Of the same type and dimension than the input image",
+ anyImagePointer);
+ BBTK_END_DESCRIBE_BLACK_BOX(ResampleImageFilter);
+
+
+
+ void ResampleImageFilter::ProcessSwitch()
+ {
+ bbtk::TypeInfo t = bbGetInputIn().type();
+ BBTK_TEMPLATE_ITK_IMAGE_SWITCH(t, this->Process);
+ }
+
+ template <class T>
+ void ResampleImageFilter::Process()
+ {
+ bbtkDebugMessageInc("Core",9,
+ "bbitk::ResampleImageFilter::Process<"
+ <<bbtk::TypeName<T>()<<">()"<<std::endl);
+
+ typedef T ImageType;
+ typedef itk::ResampleImageFilter<ImageType,ImageType> FilterType;
+ typename FilterType::Pointer filter = FilterType::New();
+ const unsigned int Dimension = ImageType::ImageDimension;
+
+ // Input
+ T* in = this->bbGetInputIn().get<T*>();
+ filter->SetInput( in );
+
+ // Size, Spacing, Origin and DefaultPixelVal
+ typename ImageType::SizeType size;
+ typename ImageType::SpacingType spacing;
+ typename ImageType::PointType origin;
+ typename ImageType::RegionType LPR;
+ LPR = in->GetLargestPossibleRegion();
+ size = LPR.GetSize();
+ // origin = LPR.GetIndex(); //in->GetOrigin();
+ for (int i=0;i<Dimension;++i)
+ {
+ origin[i] = LPR.GetIndex()[i]*in->GetSpacing()[i];
+ spacing[i] = bbGetInputSpacing()[i];
+ double tmp = (LPR.GetSize()[i]*in->GetSpacing()[i]/spacing[i] ) + 0.5;
+ size[i] = (long)floor(tmp);
+// size[i] = (long)lrint(LPR.GetSize()[i]*in->GetSpacing()[i]/spacing[i]);
+ }
+
+ filter->SetOutputOrigin (origin);
+ filter->SetSize (size);
+ filter->SetOutputSpacing( spacing );
+
+ filter->SetDefaultPixelValue (0);
+ filter->SetOutputDirection( in->GetDirection() );
+
+
+
+ // Transform
+ typedef itk::AffineTransform < double, Dimension> TransformType;
+
+ // Instance of the transform object to be passed to the resample filter
+ // By default, identity transform is applied
+ typename TransformType::Pointer transform = TransformType::New();
+ filter->SetTransform ( transform );
+
+
+ // Interpolation
+ if ( bbGetInputInterpolation() == "Linear" ) {
+ typedef itk::LinearInterpolateImageFunction < ImageType, double > InterpolatorType;
+ // We create an interpolator of the found type
+ typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
+ filter->SetInterpolator( interpolator );
+ }
+ else if ( bbGetInputInterpolation() == "NearestNeighbor" ) {
+ typedef itk::NearestNeighborInterpolateImageFunction < ImageType, double > InterpolatorType;
+ // We create an interpolator of the found type
+ typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
+ filter->SetInterpolator( interpolator );
+ }
+ else if ( bbGetInputInterpolation() == "BSpline") {
+ typedef itk::BSplineInterpolateImageFunction < ImageType, double > InterpolatorType;
+ // We create an interpolator of the found type
+ typename InterpolatorType::Pointer interpolator = InterpolatorType::New();
+ filter->SetInterpolator(interpolator);
+ // When handling unsigned data, it is possible that the interpolated value is negative
+ // if ( (m_InputImage->GetComponentTypeAsString() == "uchar") ||
+ // (m_InputImage->GetComponentTypeAsString() == "ushort") ||
+ // (m_InputImage->GetComponentTypeAsString() == "uint") ) {
+ // std::cout << "Warning! you're using unsigned data ! The interpolated value may result negative! "<< std::endl;
+ // }
+ } //end else if
+
+
+ filter->Update();
+ filter->GetOutput()->Register();
+ if (mOutput) mOutput->UnRegister();
+ this->bbSetOutputOut( filter->GetOutput() );
+ mOutput = filter->GetOutput();
+
+ bbtkDebugDecTab("Core",9);
+ }
+
+
+ void ResampleImageFilter::Init()
+ {
+ std::vector<double> res;
+ res.push_back(1);
+ res.push_back(1);
+ res.push_back(1);
+ bbSetInputSpacing(res);
+ mOutput = 0;
+ }
+
+}
+// EO namespace bbtk
+
+#endif
--- /dev/null
+#ifdef _USE_ITK_
+#include "bbitkTypedImageToAnyImage.h"
+#include "bbitkPackage.h"
+
+namespace bbitk
+{
+ //====================================================================
+ BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(TypedImageToAnyImage,
+ bbtk::UserBlackBox);
+
+ //====================================================================
+
+
+#ifdef BBTK_ITK_IMAGE_DIM_2
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int8_t_2_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int8_t_2_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int16_t_2_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int16_t_2_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int32_t_2_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int32_t_2_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint8_t_2_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint8_t_2_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint16_t_2_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint16_t_2_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint32_t_2_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint32_t_2_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_float_2_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_float_2_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_double_2_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_double_2_cptr);
+# endif
+#endif
+
+
+
+#ifdef BBTK_ITK_IMAGE_DIM_3
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int8_t_3_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int8_t_3_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int16_t_3_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int16_t_3_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int32_t_3_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int32_t_3_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint8_t_3_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint8_t_3_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint16_t_3_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint16_t_3_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint32_t_3_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint32_t_3_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_float_3_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_float_3_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_double_3_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_double_3_cptr);
+# endif
+#endif
+
+
+
+
+#ifdef BBTK_ITK_IMAGE_DIM_4
+# ifdef BBTK_ITK_IMAGE_TYPE_int8_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int8_t_4_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int8_t_4_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int16_t_4_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int16_t_4_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_int32_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int32_t_4_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_int32_t_4_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint8_t_4_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint8_t_4_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint16_t_4_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint16_t_4_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint32_t_4_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_uint32_t_4_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_float
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_float_4_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_float_4_cptr);
+# endif
+# ifdef BBTK_ITK_IMAGE_TYPE_double
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_double_4_ptr);
+ BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(itk,TypedImageToAnyImage,Image_double_4_cptr);
+# endif
+#endif
+
+}
+#endif
--- /dev/null
+#ifdef _USE_ITK_
+
+#ifndef __bbTypedItkImage2GenericItkImage_h__
+#define __bbTypedItkImage2GenericItkImage_h__
+
+#include "bbtkUserBlackBox.h"
+#include "bbitkImage.h"
+#include "bbtkSystem.h"
+
+namespace bbitk
+{
+
+ //=================================================================
+ // UserBlackBox declaration
+ template <class itkImageTypePointer>
+ class TypedImageToAnyImage : public bbtk::UserBlackBox
+ {
+ BBTK_USER_BLACK_BOX_INTERFACE(TypedImageToAnyImage,
+ bbtk::UserBlackBox);
+ BBTK_DECLARE_INPUT(In,itkImageTypePointer);
+ BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
+ BBTK_PROCESS(DoIt);
+ void DoIt() { bbSetOutputOut( bbGetInputIn() ); bbGetInputIn()->Register(); }
+ };
+ //=================================================================
+
+ //=================================================================
+ // UserBlackBox description
+ BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(TypedImageToAnyImage);
+ BBTK_NAME(bbtk::HumanTypeName<T>()
+ + "To" + bbtk::HumanTypeName<anyImagePointer>());
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Transforms a typed itk image ("+bbtk::HumanTypeName<T>()+
+ ") into a generic itk image ("+
+ bbtk::HumanTypeName<anyImagePointer>()+")");
+ BBTK_DEFAULT_ADAPTOR();
+ BBTK_TEMPLATE_INPUT(TypedImageToAnyImage,In,
+ "Input typed image",T);
+ BBTK_TEMPLATE_OUTPUT(TypedImageToAnyImage,Out,
+ "Output generic image",anyImagePointer);
+ BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(TypedImageToAnyImage);
+ //=================================================================
+
+
+}
+#endif
+#endif
--- /dev/null
+#ifndef __bbstdRelay_h_INCLUDED_H__
+#define __bbstdRelay_h_INCLUDED_H__
+
+#include "bbtkUserBlackBox.h"
+
+namespace bbstd
+{
+
+ template <class T>
+ class /*BBTK_EXPORT*/ Relay
+ :
+ public bbtk::UserBlackBox
+ {
+ BBTK_USER_BLACK_BOX_INTERFACE(Relay,bbtk::UserBlackBox);
+ BBTK_DECLARE_INPUT(In,T);
+ BBTK_DECLARE_OUTPUT(Out,T);
+ BBTK_PROCESS(Process);
+ protected:
+ void Process() { bbSetOutputOut ( bbGetInputIn() ); }
+ };
+
+
+ BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(Relay);
+ BBTK_NAME(bbtk::HumanTypeName<T>()+"Relay");
+ BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Relays a "+bbtk::TypeName<T>());
+ BBTK_TEMPLATE_INPUT(Relay,In,"Input",T);
+ BBTK_TEMPLATE_OUTPUT(Relay,Out,"Output",T);
+ BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(Relay);
+
+}
+// namespace bbstd
+
+#endif // __bbstdRelay_h_INCLUDED_H__