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