3 #include "bbtkAtomicBlackBox.h"
4 #include "itkBinaryThresholdImageFilter.h"
5 #include "bbtkItkBlackBoxMacros.h"
6 #include "bbitkImage.h"
12 class /*BBTK_EXPORT*/ BinaryThresholdImageFilter
14 public bbtk::AtomicBlackBox,
15 public itk::BinaryThresholdImageFilter<T,T>
17 BBTK_TEMPLATE_BLACK_BOX_INTERFACE(BinaryThresholdImageFilter,
18 bbtk::AtomicBlackBox,T);
19 typedef itk::BinaryThresholdImageFilter<T,T> itkParent;
20 BBTK_DECLARE_ITK_INPUT(itkParent,In,const T*);
21 BBTK_DECLARE_ITK_PARAM(itkParent,LowerThreshold,typename T::PixelType);
22 BBTK_DECLARE_ITK_PARAM(itkParent,UpperThreshold,typename T::PixelType);
23 BBTK_DECLARE_ITK_PARAM(itkParent,InsideValue,typename T::PixelType);
24 BBTK_DECLARE_ITK_PARAM(itkParent,OutsideValue,typename T::PixelType);
25 BBTK_DECLARE_ITK_OUTPUT(itkParent,Out,T*);
26 BBTK_PROCESS(itkParent::Update);
27 void bbDelete() { itkParent::UnRegister(); }
29 void bbUserConstructor() { Init(); }
30 void bbUserCopyConstructor() { Init(); }
35 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter,
36 bbtk::AtomicBlackBox);
37 BBTK_NAME("BinaryThresholdImageFilter<"+bbtk::TypeName<T>()+">");
38 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
39 BBTK_DESCRIPTION("Binarizes an image by thresholding (bbification of itk::BinaryThresholdImageFilter)");
40 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,In,"Input image",const T*);
41 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,LowerThreshold,
42 "Lower threshold",typename T::PixelType);
43 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,UpperThreshold,
44 "Upper threshold",typename T::PixelType);
45 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,InsideValue,
46 "Output value for pixels inside thresholds",
47 typename T::PixelType);
48 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,OutsideValue,
49 "Output value for pixels outside thresholds",
50 typename T::PixelType);
51 BBTK_TEMPLATE_OUTPUT(BinaryThresholdImageFilter,Out,"Output image",T*);
52 BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter);
54 //===================================================
55 // Generic "untemplatized" filter
56 //===================================================
57 class /*BBTK_EXPORT*/ BinaryThresholdImageFilterGeneric
59 public bbtk::AtomicBlackBox
61 BBTK_BLACK_BOX_INTERFACE(BinaryThresholdImageFilterGeneric,
62 bbtk::AtomicBlackBox);
63 BBTK_DECLARE_INPUT(In,anyImagePointer);
64 BBTK_DECLARE_INPUT(LowerThreshold,double);
65 BBTK_DECLARE_INPUT(UpperThreshold,double);
66 BBTK_DECLARE_INPUT(InsideValue,double);
67 BBTK_DECLARE_INPUT(OutsideValue,double);
68 BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
69 BBTK_PROCESS(ProcessSwitch);
71 inline void ProcessSwitch();
72 template <class T> void Process();
73 void bbUserConstructor() { Init(); }
74 void bbUserCopyConstructor() { Init(); }
78 BBTK_BEGIN_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric,
79 bbtk::AtomicBlackBox);
80 BBTK_NAME("BinaryThresholdImageFilter");
81 BBTK_AUTHOR("laurent.guigues at creatis.insa-lyon.fr");
82 BBTK_CATEGORY("filter;image");
83 BBTK_DESCRIPTION("Binarizes an image by thresholding (generic bbification of itk::BinaryThresholdImageFilter)");
84 BBTK_INPUT(BinaryThresholdImageFilterGeneric,In,
85 "Input image. Can be any itk::Image<T,D>*",anyImagePointer,"");
86 BBTK_INPUT(BinaryThresholdImageFilterGeneric,LowerThreshold,
87 "Lower threshold",double,"");
88 BBTK_INPUT(BinaryThresholdImageFilterGeneric,UpperThreshold,
89 "Upper threshold",double,"");
90 BBTK_INPUT(BinaryThresholdImageFilterGeneric,InsideValue,
91 "Output value for pixels inside thresholds",double,"");
92 BBTK_INPUT(BinaryThresholdImageFilterGeneric,OutsideValue,
93 "Output value for pixels outside thresholds",double,"");
94 BBTK_OUTPUT(BinaryThresholdImageFilterGeneric,Out,
95 "Output image. Of the same type and dimension than the input image",
97 BBTK_END_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric);
101 void BinaryThresholdImageFilterGeneric::ProcessSwitch()
103 BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process);
107 void BinaryThresholdImageFilterGeneric::Process()
109 bbtkDebugMessageInc("Core",9,
110 "bbitk::BinaryThresholdImageFilterGeneric::Process<"
111 <<bbtk::TypeName<T>()<<">()"<<std::endl);
113 typedef BinaryThresholdImageFilter<T> FilterType;
114 typename FilterType::Pointer f = FilterType::New("Temp");
115 f->bbSetInputIn( this->bbGetInputIn().get<T*>());
116 f->bbSetInputLowerThreshold ( (typename T::PixelType)
117 this->bbGetInputLowerThreshold() );
118 f->bbSetInputUpperThreshold ( (typename T::PixelType)
119 this->bbGetInputUpperThreshold() );
120 f->bbSetInputInsideValue ( (typename T::PixelType)
121 this->bbGetInputInsideValue() );
122 f->bbSetInputOutsideValue ( (typename T::PixelType)
123 this->bbGetInputOutsideValue() );
125 f->bbGetOutputOut()->Register();
126 this->bbSetOutputOut( f->bbGetOutputOut() );
128 bbtkDebugDecTab("Core",9);
132 void BinaryThresholdImageFilter<T>::Init()
134 bbSetInputLowerThreshold(0);
135 bbSetInputUpperThreshold(100);
136 bbSetInputInsideValue(255);
137 bbSetInputOutsideValue(0);
140 void BinaryThresholdImageFilterGeneric::Init()
142 bbSetInputLowerThreshold(0);
143 bbSetInputUpperThreshold(100);
144 bbSetInputInsideValue(255);
145 bbSetInputOutsideValue(0);