3 #include "bbtkUserBlackBox.h"
4 #include "itkBinaryThresholdImageFilter.h"
5 #include "bbitkImage.h"
11 class /*BBTK_EXPORT*/ BinaryThresholdImageFilter
13 public bbtk::UserBlackBox,
14 public itk::BinaryThresholdImageFilter<T,T>
16 BBTK_USER_BLACK_BOX_INTERFACE(BinaryThresholdImageFilter,
18 typedef itk::BinaryThresholdImageFilter<T,T> itkParent;
19 BBTK_DECLARE_ITK_INPUT(itkParent,In,const T*);
20 BBTK_DECLARE_ITK_PARAM(itkParent,LowerThreshold,typename T::PixelType);
21 BBTK_DECLARE_ITK_PARAM(itkParent,UpperThreshold,typename T::PixelType);
22 BBTK_DECLARE_ITK_PARAM(itkParent,InsideValue,typename T::PixelType);
23 BBTK_DECLARE_ITK_PARAM(itkParent,OutsideValue,typename T::PixelType);
24 BBTK_DECLARE_ITK_OUTPUT(itkParent,Out,T*);
25 BBTK_PROCESS(itkParent::Update);
26 void bbDelete() { itkParent::UnRegister(); }
28 void bbUserConstructor() { Init(); }
29 void bbUserCopyConstructor() { Init(); }
34 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter);
35 BBTK_NAME("BinaryThresholdImageFilter<"+bbtk::TypeName<T>()+">");
36 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
37 BBTK_DESCRIPTION("Binarizes an image by thresholding (bbification of itk::BinaryThresholdImageFilter)");
38 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,In,"Input image",const T*);
39 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,LowerThreshold,
40 "Lower threshold",typename T::PixelType);
41 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,UpperThreshold,
42 "Upper threshold",typename T::PixelType);
43 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,InsideValue,
44 "Output value for pixels inside thresholds",
45 typename T::PixelType);
46 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,OutsideValue,
47 "Output value for pixels outside thresholds",
48 typename T::PixelType);
49 BBTK_TEMPLATE_OUTPUT(BinaryThresholdImageFilter,Out,"Output image",T*);
50 BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter);
52 //===================================================
53 // Generic "untemplatized" filter
54 //===================================================
55 class /*BBTK_EXPORT*/ BinaryThresholdImageFilterGeneric
57 public bbtk::UserBlackBox
59 BBTK_USER_BLACK_BOX_INTERFACE(BinaryThresholdImageFilterGeneric,
61 BBTK_DECLARE_INPUT(In,anyImagePointer);
62 BBTK_DECLARE_INPUT(LowerThreshold,double);
63 BBTK_DECLARE_INPUT(UpperThreshold,double);
64 BBTK_DECLARE_INPUT(InsideValue,double);
65 BBTK_DECLARE_INPUT(OutsideValue,double);
66 BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
67 BBTK_PROCESS(ProcessSwitch);
69 inline void ProcessSwitch();
70 template <class T> void Process();
71 void bbUserConstructor() { Init(); }
72 void bbUserCopyConstructor() { Init(); }
76 BBTK_BEGIN_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric,
78 BBTK_NAME("BinaryThresholdImageFilter");
79 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
80 BBTK_DESCRIPTION("Binarizes an image by thresholding (generic bbification of itk::BinaryThresholdImageFilter)");
81 BBTK_INPUT(BinaryThresholdImageFilterGeneric,In,
82 "Input image. Can be any itk::Image<T,D>*",anyImagePointer);
83 BBTK_INPUT(BinaryThresholdImageFilterGeneric,LowerThreshold,
84 "Lower threshold",double);
85 BBTK_INPUT(BinaryThresholdImageFilterGeneric,UpperThreshold,
86 "Upper threshold",double);
87 BBTK_INPUT(BinaryThresholdImageFilterGeneric,InsideValue,
88 "Output value for pixels inside thresholds",double);
89 BBTK_INPUT(BinaryThresholdImageFilterGeneric,OutsideValue,
90 "Output value for pixels outside thresholds",double);
91 BBTK_OUTPUT(BinaryThresholdImageFilterGeneric,Out,
92 "Output image. Of the same type and dimension than the input image",
94 BBTK_END_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric);
98 void BinaryThresholdImageFilterGeneric::ProcessSwitch()
100 BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process);
104 void BinaryThresholdImageFilterGeneric::Process()
106 bbtkDebugMessageInc("Core",9,
107 "bbitk::BinaryThresholdImageFilterGeneric::Process<"
108 <<bbtk::TypeName<T>()<<">()"<<std::endl);
110 typedef BinaryThresholdImageFilter<T> FilterType;
111 FilterType* f = FilterType::bbNew("Temp");
112 f->bbSetInputIn( this->bbGetInputIn().get<T*>());
113 f->bbSetInputLowerThreshold ( (typename T::PixelType)
114 this->bbGetInputLowerThreshold() );
115 f->bbSetInputUpperThreshold ( (typename T::PixelType)
116 this->bbGetInputUpperThreshold() );
117 f->bbSetInputInsideValue ( (typename T::PixelType)
118 this->bbGetInputInsideValue() );
119 f->bbSetInputOutsideValue ( (typename T::PixelType)
120 this->bbGetInputOutsideValue() );
122 f->bbGetOutputOut()->Register();
123 this->bbSetOutputOut( f->bbGetOutputOut() );
125 bbtkDebugDecTab("Core",9);
129 void BinaryThresholdImageFilter<T>::Init()
131 bbSetInputLowerThreshold(0);
132 bbSetInputUpperThreshold(100);
133 bbSetInputInsideValue(255);
134 bbSetInputOutsideValue(0);
137 void BinaryThresholdImageFilterGeneric::Init()
139 bbSetInputLowerThreshold(0);
140 bbSetInputUpperThreshold(100);
141 bbSetInputInsideValue(255);
142 bbSetInputOutsideValue(0);