3 #include "bbtkUserBlackBox.h"
4 #include "itkExtractImageFilter.h"
5 #include "bbitkImage.h"
6 #include "bbitkImageRegion.h"
13 class /*BBTK_EXPORT*/ ExtractImageFilter
15 public bbtk::UserBlackBox,
16 public itk::ExtractImageFilter<T,T>
18 BBTK_USER_BLACK_BOX_INTERFACE(ExtractImageFilter,bbtk::UserBlackBox);
19 typedef itk::ExtractImageFilter<T,T> itkParent;
21 BBTK_DECLARE_ITK_INPUT(itkParent,In,const T*);
22 BBTK_DECLARE_ITK_PARAM(itkParent,ExtractionRegion,typename T::RegionType);
23 BBTK_DECLARE_ITK_OUTPUT(itkParent,Out,T*);
24 BBTK_PROCESS(itkParent::Update);
26 void bbDelete() { itkParent::UnRegister(); }
30 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(ExtractImageFilter);
31 BBTK_NAME("ExtractImageFilter<"+bbtk::TypeName<T>()+">");
32 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
33 BBTK_DESCRIPTION("Decrease the image size by cropping the image to the selected region bounds (bbification of itk::ExtractImageFilter)");
34 BBTK_TEMPLATE_INPUT(ExtractImageFilter,In,"Input image",const T*);
35 BBTK_TEMPLATE_INPUT(ExtractImageFilter,ExtractionRegion,"Extraction region",typename T::RegionType);
36 BBTK_TEMPLATE_OUTPUT(ExtractImageFilter,Out,"Output image",T*);
37 BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(ExtractImageFilter);
39 //===================================================
40 // Generic "untemplatized" filter
41 //===================================================
42 class /*BBTK_EXPORT*/ ExtractImageFilterGeneric
43 : public bbtk::UserBlackBox
45 BBTK_USER_BLACK_BOX_INTERFACE(ExtractImageFilterGeneric,
47 BBTK_DECLARE_INPUT(In,anyImagePointer);
48 BBTK_DECLARE_INPUT(Region,anyImageRegion);
49 BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
50 BBTK_PROCESS(ProcessSwitch);
52 inline void ProcessSwitch();
53 template <class T> void Process();
56 BBTK_BEGIN_DESCRIBE_BLACK_BOX(ExtractImageFilterGeneric,bbtk::UserBlackBox);
57 BBTK_NAME("ExtractImageFilter");
58 BBTK_AUTHOR("laurent.guigues at creatis.insa-lyon.fr");
59 BBTK_CATEGORY("image;filter");
60 BBTK_DESCRIPTION("Decrease the image size by cropping the image to the selected region bounds (bbification of itk::ExtractImageFilter)");
61 BBTK_INPUT(ExtractImageFilterGeneric,In,"Input image",anyImagePointer);
62 BBTK_INPUT(ExtractImageFilterGeneric,Region,"Extraction region",anyImageRegion);
63 BBTK_OUTPUT(ExtractImageFilterGeneric,Out,"Output image",anyImagePointer);
64 BBTK_END_DESCRIBE_BLACK_BOX(ExtractImageFilterGeneric);
65 void ExtractImageFilterGeneric::ProcessSwitch()
67 BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process);
71 void ExtractImageFilterGeneric::Process()
73 bbtkDebugMessageInc("Core",9,
74 "bbitk::ExtractImageFilterGeneric::Process<"
75 <<bbtk::TypeName<T>()<<">()"<<std::endl);
77 typedef ExtractImageFilter<ImageType> FilterType;
78 FilterType* f = FilterType::bbNew("Temp");
79 f->bbSetInputIn( this->bbGetInputIn().unsafe_get<T*>() );
80 f->bbSetInputExtractionRegion ( this->bbGetInputRegion().get<typename T::RegionType>() );
82 f->bbGetOutputOut()->Register();
83 this->bbSetOutputOut( f->bbGetOutputOut() );
86 bbtkDebugDecTab("Core",9);