From 1d1f64574cda7427057b0ba358cfbb6e53043ab3 Mon Sep 17 00:00:00 2001 From: Eduardo Davila Date: Tue, 3 May 2011 10:50:29 +0000 Subject: [PATCH] no message --- .../bbtk_mySamplePackage_PKG/CMakeLists.txt | 4 +- .../bbmySamplePackagemySampleBoxWithITK.cxx | 29 +++--- .../src/bbmySamplePackagemySampleBoxWithITK.h | 88 ++++++++++++++++--- 3 files changed, 91 insertions(+), 30 deletions(-) diff --git a/appli/creaNewProject/NewProject/bbtk_mySamplePackage_PKG/CMakeLists.txt b/appli/creaNewProject/NewProject/bbtk_mySamplePackage_PKG/CMakeLists.txt index 1eaeb78..ff7a8b0 100644 --- a/appli/creaNewProject/NewProject/bbtk_mySamplePackage_PKG/CMakeLists.txt +++ b/appli/creaNewProject/NewProject/bbtk_mySamplePackage_PKG/CMakeLists.txt @@ -38,7 +38,7 @@ SET(USE_BOOST ON) #=========================================================================== # UNCOMMENT EACH LIBRARY NEEDED (WILL BE FOUND AND USED AUTOMATICALLY) # SET(${BBTK_PACKAGE_NAME}_USE_VTK ON) -# SET(${BBTK_PACKAGE_NAME}_USE_ITK ON) +SET(${BBTK_PACKAGE_NAME}_USE_ITK ON) # SET(${BBTK_PACKAGE_NAME}_USE_GDCM ON) # SET(${BBTK_PACKAGE_NAME}_USE_GDCM_VTK ON) # SET(${BBTK_PACKAGE_NAME}_USE_GSMIS ON) @@ -114,6 +114,8 @@ SET(${BBTK_PACKAGE_NAME}_INCLUDE_DIRS # - bbtk dirs # - automatically handled libraries or packages : wx, vtk... (see above) # - the dirs automatically set by other libraries found by FIND_PACKAGE + + ${BBTK_DIR}/../../../include/bbitk ../lib/mySampleLib ) diff --git a/appli/creaNewProject/NewProject/bbtk_mySamplePackage_PKG/src/bbmySamplePackagemySampleBoxWithITK.cxx b/appli/creaNewProject/NewProject/bbtk_mySamplePackage_PKG/src/bbmySamplePackagemySampleBoxWithITK.cxx index 1e2d182..fc9cd48 100644 --- a/appli/creaNewProject/NewProject/bbtk_mySamplePackage_PKG/src/bbmySamplePackagemySampleBoxWithITK.cxx +++ b/appli/creaNewProject/NewProject/bbtk_mySamplePackage_PKG/src/bbmySamplePackagemySampleBoxWithITK.cxx @@ -7,30 +7,21 @@ namespace bbmySamplePackage BBTK_ADD_BLACK_BOX_TO_PACKAGE(mySamplePackage,mySampleBoxWithITK) BBTK_BLACK_BOX_IMPLEMENTATION(mySampleBoxWithITK,bbtk::AtomicBlackBox); -void mySampleBoxWithITK::Process() -{ - -// THE MAIN PROCESSING METHOD BODY -// Here we simply set the input 'In' value to the output 'Out' -// And print out the output value -// INPUT/OUTPUT ACCESSORS ARE OF THE FORM : -// void bbSet{Input|Output}NAME(const TYPE&) -// const TYPE& bbGet{Input|Output}NAME() const -// Where : -// * NAME is the name of the input/output -// (the one provided in the attribute 'name' of the tag 'input') -// * TYPE is the C++ type of the input/output -// (the one provided in the attribute 'type' of the tag 'input') - bbSetOutputOut( bbGetInputIn() ); - std::cout << "Output value = " < + +#include "itkResampleImageFilter.h" +#include "itkNearestNeighborInterpolateImageFunction.h" + namespace bbmySamplePackage { @@ -14,22 +37,67 @@ class bbmySamplePackage_EXPORT mySampleBoxWithITK { BBTK_BLACK_BOX_INTERFACE(mySampleBoxWithITK,bbtk::AtomicBlackBox); - BBTK_DECLARE_INPUT(In,double); - BBTK_DECLARE_OUTPUT(Out,double); + 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); - void Process(); - +private: + inline void Process(); + template void ProcessTemplated(); + itk::Object* mOutput; }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(mySampleBoxWithITK,bbtk::AtomicBlackBox); -BBTK_NAME("mySampleBoxWithITK"); -BBTK_AUTHOR("_author_"); -BBTK_DESCRIPTION("_description_"); -BBTK_CATEGORY(""); -BBTK_INPUT(mySampleBoxWithITK,In,"First input",double,""); -BBTK_OUTPUT(mySampleBoxWithITK,Out,"First output",double,""); + 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 -- 2.47.1