#ifdef _USE_ITK_ #include "bbtkUserBlackBox.h" #include "itkBinaryThresholdImageFilter.h" #include "bbitkImage.h" namespace bbitk { template class /*BBTK_EXPORT*/ BinaryThresholdImageFilter : public bbtk::UserBlackBox, public itk::BinaryThresholdImageFilter { BBTK_USER_BLACK_BOX_INTERFACE(BinaryThresholdImageFilter, bbtk::UserBlackBox); typedef itk::BinaryThresholdImageFilter itkParent; BBTK_DECLARE_ITK_INPUT(itkParent,In,const T*); BBTK_DECLARE_ITK_PARAM(itkParent,LowerThreshold,typename T::PixelType); BBTK_DECLARE_ITK_PARAM(itkParent,UpperThreshold,typename T::PixelType); BBTK_DECLARE_ITK_PARAM(itkParent,InsideValue,typename T::PixelType); BBTK_DECLARE_ITK_PARAM(itkParent,OutsideValue,typename T::PixelType); BBTK_DECLARE_ITK_OUTPUT(itkParent,Out,T*); BBTK_PROCESS(itkParent::Update); void bbDelete() { itkParent::UnRegister(); } void bbUserConstructor() { Init(); } void bbUserCopyConstructor() { Init(); } void Init(); }; BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter); BBTK_NAME("BinaryThresholdImageFilter<"+bbtk::TypeName()+">"); BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr"); BBTK_DESCRIPTION("Binarizes an image by thresholding (bbification of itk::BinaryThresholdImageFilter)"); BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,In,"Input image",const T*); BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,LowerThreshold, "Lower threshold",typename T::PixelType); BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,UpperThreshold, "Upper threshold",typename T::PixelType); BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,InsideValue, "Output value for pixels inside thresholds", typename T::PixelType); BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,OutsideValue, "Output value for pixels outside thresholds", typename T::PixelType); BBTK_TEMPLATE_OUTPUT(BinaryThresholdImageFilter,Out,"Output image",T*); BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter); //=================================================== // Generic "untemplatized" filter //=================================================== class /*BBTK_EXPORT*/ BinaryThresholdImageFilterGeneric : public bbtk::UserBlackBox { BBTK_USER_BLACK_BOX_INTERFACE(BinaryThresholdImageFilterGeneric, bbtk::UserBlackBox); BBTK_DECLARE_INPUT(In,anyImagePointer); BBTK_DECLARE_INPUT(LowerThreshold,double); BBTK_DECLARE_INPUT(UpperThreshold,double); BBTK_DECLARE_INPUT(InsideValue,double); BBTK_DECLARE_INPUT(OutsideValue,double); BBTK_DECLARE_OUTPUT(Out,anyImagePointer); BBTK_PROCESS(ProcessSwitch); private : inline void ProcessSwitch(); template void Process(); void bbUserConstructor() { Init(); } void bbUserCopyConstructor() { Init(); } void Init(); }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric, bbtk::UserBlackBox); BBTK_NAME("BinaryThresholdImageFilter"); BBTK_AUTHOR("laurent.guigues at creatis.insa-lyon.fr"); BBTK_CATEGORY("filter;image"); BBTK_DESCRIPTION("Binarizes an image by thresholding (generic bbification of itk::BinaryThresholdImageFilter)"); BBTK_INPUT(BinaryThresholdImageFilterGeneric,In, "Input image. Can be any itk::Image*",anyImagePointer); BBTK_INPUT(BinaryThresholdImageFilterGeneric,LowerThreshold, "Lower threshold",double); BBTK_INPUT(BinaryThresholdImageFilterGeneric,UpperThreshold, "Upper threshold",double); BBTK_INPUT(BinaryThresholdImageFilterGeneric,InsideValue, "Output value for pixels inside thresholds",double); BBTK_INPUT(BinaryThresholdImageFilterGeneric,OutsideValue, "Output value for pixels outside thresholds",double); BBTK_OUTPUT(BinaryThresholdImageFilterGeneric,Out, "Output image. Of the same type and dimension than the input image", anyImagePointer); BBTK_END_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric); void BinaryThresholdImageFilterGeneric::ProcessSwitch() { BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process); } template void BinaryThresholdImageFilterGeneric::Process() { bbtkDebugMessageInc("Core",9, "bbitk::BinaryThresholdImageFilterGeneric::Process<" <()<<">()"< FilterType; FilterType* f = FilterType::bbNew("Temp"); f->bbSetInputIn( this->bbGetInputIn().get()); f->bbSetInputLowerThreshold ( (typename T::PixelType) this->bbGetInputLowerThreshold() ); f->bbSetInputUpperThreshold ( (typename T::PixelType) this->bbGetInputUpperThreshold() ); f->bbSetInputInsideValue ( (typename T::PixelType) this->bbGetInputInsideValue() ); f->bbSetInputOutsideValue ( (typename T::PixelType) this->bbGetInputOutsideValue() ); f->bbExecute(); f->bbGetOutputOut()->Register(); this->bbSetOutputOut( f->bbGetOutputOut() ); f->bbDelete(); bbtkDebugDecTab("Core",9); } template void BinaryThresholdImageFilter::Init() { bbSetInputLowerThreshold(0); bbSetInputUpperThreshold(100); bbSetInputInsideValue(255); bbSetInputOutsideValue(0); } void BinaryThresholdImageFilterGeneric::Init() { bbSetInputLowerThreshold(0); bbSetInputUpperThreshold(100); bbSetInputInsideValue(255); bbSetInputOutsideValue(0); } } // EO namespace bbtk #endif