--- /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