00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifdef _USE_ITK_
00033
00034 #include "bbtkAtomicBlackBox.h"
00035 #include "itkBinaryThresholdImageFilter.h"
00036 #include "bbtkItkBlackBoxMacros.h"
00037 #include "bbitkImage.h"
00038
00039 namespace bbitk
00040 {
00041
00042 template <class T>
00043 class BinaryThresholdImageFilter
00044 :
00045 public bbtk::AtomicBlackBox,
00046 public itk::BinaryThresholdImageFilter<T,T>
00047 {
00048 BBTK_TEMPLATE_BLACK_BOX_INTERFACE(BinaryThresholdImageFilter,
00049 bbtk::AtomicBlackBox,T);
00050 typedef itk::BinaryThresholdImageFilter<T,T> itkParent;
00051 BBTK_DECLARE_ITK_INPUT(In,const T*);
00052 BBTK_DECLARE_ITK_PARAM(LowerThreshold,typename T::PixelType);
00053 BBTK_DECLARE_ITK_PARAM(UpperThreshold,typename T::PixelType);
00054 BBTK_DECLARE_ITK_PARAM(InsideValue,typename T::PixelType);
00055 BBTK_DECLARE_ITK_PARAM(OutsideValue,typename T::PixelType);
00056 BBTK_DECLARE_ITK_OUTPUT(Out,T*);
00057 BBTK_ITK_PROCESS();
00058 BBTK_ITK_DELETE();
00059
00060 void bbUserConstructor() { Init(); }
00061 void bbUserCopyConstructor() { Init(); }
00062 void Init();
00063
00064 };
00065
00066 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter,
00067 bbtk::AtomicBlackBox);
00068 BBTK_NAME("BinaryThresholdImageFilter<"+bbtk::TypeName<T>()+">");
00069 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
00070 BBTK_DESCRIPTION("Binarizes an image by thresholding (bbification of itk::BinaryThresholdImageFilter)");
00071 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,In,"Input image",const T*);
00072 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,LowerThreshold,
00073 "Lower threshold",typename T::PixelType);
00074 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,UpperThreshold,
00075 "Upper threshold",typename T::PixelType);
00076 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,InsideValue,
00077 "Output value for pixels inside thresholds",
00078 typename T::PixelType);
00079 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,OutsideValue,
00080 "Output value for pixels outside thresholds",
00081 typename T::PixelType);
00082 BBTK_TEMPLATE_OUTPUT(BinaryThresholdImageFilter,Out,"Output image",T*);
00083 BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter);
00084
00085
00086
00087
00088 class BinaryThresholdImageFilterGeneric
00089 :
00090 public bbtk::AtomicBlackBox
00091 {
00092 BBTK_BLACK_BOX_INTERFACE(BinaryThresholdImageFilterGeneric,
00093 bbtk::AtomicBlackBox);
00094 BBTK_DECLARE_INPUT(In,anyImagePointer);
00095 BBTK_DECLARE_INPUT(LowerThreshold,double);
00096 BBTK_DECLARE_INPUT(UpperThreshold,double);
00097 BBTK_DECLARE_INPUT(InsideValue,double);
00098 BBTK_DECLARE_INPUT(OutsideValue,double);
00099 BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
00100 BBTK_PROCESS(ProcessSwitch);
00101 private :
00102 inline void ProcessSwitch();
00103 template <class T> void Process();
00104 void bbUserConstructor() { Init(); }
00105 void bbUserCopyConstructor() { Init(); }
00106 void Init();
00107 };
00108
00109 BBTK_BEGIN_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric,
00110 bbtk::AtomicBlackBox);
00111 BBTK_NAME("BinaryThresholdImageFilter");
00112 BBTK_AUTHOR("laurent.guigues at creatis.insa-lyon.fr");
00113 BBTK_CATEGORY("filter;image");
00114 BBTK_DESCRIPTION("Binarizes an image by thresholding (generic bbification of itk::BinaryThresholdImageFilter)");
00115 BBTK_INPUT(BinaryThresholdImageFilterGeneric,In,
00116 "Input image. Can be any itk::Image<T,D>*",anyImagePointer,"");
00117 BBTK_INPUT(BinaryThresholdImageFilterGeneric,LowerThreshold,
00118 "Lower threshold",double,"");
00119 BBTK_INPUT(BinaryThresholdImageFilterGeneric,UpperThreshold,
00120 "Upper threshold",double,"");
00121 BBTK_INPUT(BinaryThresholdImageFilterGeneric,InsideValue,
00122 "Output value for pixels inside thresholds",double,"");
00123 BBTK_INPUT(BinaryThresholdImageFilterGeneric,OutsideValue,
00124 "Output value for pixels outside thresholds",double,"");
00125 BBTK_OUTPUT(BinaryThresholdImageFilterGeneric,Out,
00126 "Output image. Of the same type and dimension than the input image",
00127 anyImagePointer,"");
00128 BBTK_END_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric);
00129
00130
00131
00132 void BinaryThresholdImageFilterGeneric::ProcessSwitch()
00133 {
00134 BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process);
00135 }
00136
00137 template <class T>
00138 void BinaryThresholdImageFilterGeneric::Process()
00139 {
00140 bbtkDebugMessageInc("Core",9,
00141 "bbitk::BinaryThresholdImageFilterGeneric::Process<"
00142 <<bbtk::TypeName<T>()<<">()"<<std::endl);
00143
00144 typedef BinaryThresholdImageFilter<T> FilterType;
00145 typename FilterType::Pointer f = FilterType::New("Temp");
00146 f->bbSetInputIn( this->bbGetInputIn().get<T*>());
00147 f->bbSetInputLowerThreshold ( (typename T::PixelType)
00148 this->bbGetInputLowerThreshold() );
00149 f->bbSetInputUpperThreshold ( (typename T::PixelType)
00150 this->bbGetInputUpperThreshold() );
00151 f->bbSetInputInsideValue ( (typename T::PixelType)
00152 this->bbGetInputInsideValue() );
00153 f->bbSetInputOutsideValue ( (typename T::PixelType)
00154 this->bbGetInputOutsideValue() );
00155 f->bbExecute();
00156 f->bbGetOutputOut()->Register();
00157 this->bbSetOutputOut( f->bbGetOutputOut() );
00158
00159 bbtkDebugDecTab("Core",9);
00160 }
00161
00162 template <class T>
00163 void BinaryThresholdImageFilter<T>::Init()
00164 {
00165 bbSetInputLowerThreshold(0);
00166 bbSetInputUpperThreshold(100);
00167 bbSetInputInsideValue(255);
00168 bbSetInputOutsideValue(0);
00169 }
00170
00171 void BinaryThresholdImageFilterGeneric::Init()
00172 {
00173 bbSetInputLowerThreshold(0);
00174 bbSetInputUpperThreshold(100);
00175 bbSetInputInsideValue(255);
00176 bbSetInputOutsideValue(0);
00177 }
00178
00179 }
00180
00181
00182 #endif