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