#ifndef __bbmySamplePackagemySampleBoxWithITK_h_INCLUDED__ #define __bbmySamplePackagemySampleBoxWithITK_h_INCLUDED__ #define BBTK_ITK_IMAGE_DIM_2 #define BBTK_ITK_IMAGE_DIM_3 #define BBTK_ITK_IMAGE_DIM_4 #define BBTK_ITK_IMAGE_TYPE_int8_t #define BBTK_ITK_IMAGE_TYPE_uint8_t #define BBTK_ITK_IMAGE_TYPE_int16_t #define BBTK_ITK_IMAGE_TYPE_uint16_t #define BBTK_ITK_IMAGE_TYPE_int32_t #define BBTK_ITK_IMAGE_TYPE_uint32_t #define BBTK_ITK_IMAGE_TYPE_float #define BBTK_ITK_IMAGE_TYPE_double #include "bbmySamplePackage_EXPORT.h" #include "bbtkAtomicBlackBox.h" #include "iostream" #include "bbitkImage.h" #include #include "itkResampleImageFilter.h" #include "itkNearestNeighborInterpolateImageFunction.h" namespace bbmySamplePackage { class bbmySamplePackage_EXPORT mySampleBoxWithITK : public bbtk::AtomicBlackBox { BBTK_BLACK_BOX_INTERFACE(mySampleBoxWithITK,bbtk::AtomicBlackBox); BBTK_DECLARE_INPUT(In,bbitk::anyImagePointer); BBTK_DECLARE_INPUT(Lower,double); BBTK_DECLARE_INPUT(Upper,double); BBTK_DECLARE_OUTPUT(Out,bbitk::anyImagePointer); BBTK_PROCESS(Process); private: inline void Process(); template void ProcessTemplated(); itk::Object* mOutput; }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(mySampleBoxWithITK,bbtk::AtomicBlackBox); BBTK_NAME("mySampleBoxWithITK"); BBTK_AUTHOR("Info-Dev"); BBTK_DESCRIPTION("Example ITK box - CreaNewProject"); BBTK_CATEGORY("filter"); BBTK_INPUT(mySampleBoxWithITK,In,"Input image. Can be any itk::Image*",bbitk::anyImagePointer,""); BBTK_INPUT(mySampleBoxWithITK,Lower,"(200 default) Lower value for the threshold*",double,""); BBTK_INPUT(mySampleBoxWithITK,Upper,"(1200 default) Upper value for the threshold*",double,""); BBTK_OUTPUT(mySampleBoxWithITK,Out,"Output Image",bbitk::anyImagePointer,""); BBTK_END_DESCRIBE_BLACK_BOX(mySampleBoxWithITK); //=================================================== void mySampleBoxWithITK::Process() { bbtk::TypeInfo t = bbGetInputIn().type(); BBTK_TEMPLATE_ITK_IMAGE_SWITCH(t, this->ProcessTemplated); } //=================================================== //=================================================== template void mySampleBoxWithITK::ProcessTemplated() { bbtkDebugMessageInc("Core",9,"bbitk::BinaryThresholdImageFilter::Process<"<()<<">()"< FilterType; typename FilterType::Pointer filter = FilterType::New(); // Input ImageType* in = this->bbGetInputIn().get(); filter->SetInput( in ); filter->SetInsideValue (255); filter->SetOutsideValue (0); filter->SetLowerThreshold( bbGetInputLower() ); filter->SetUpperThreshold( bbGetInputUpper() ); filter->Update(); filter->GetOutput()->Register(); if (mOutput) mOutput->UnRegister(); mOutput = filter->GetOutput(); this->bbSetOutputOut( filter->GetOutput() ); bbtkDebugDecTab("Core",9); } //=================================================== } // EO namespace bbmySamplePackage #endif // __bbmySamplePackagemySampleBoxWithITK_h_INCLUDED__