]> Creatis software - crea.git/commitdiff
no message
authorEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Tue, 3 May 2011 10:50:29 +0000 (10:50 +0000)
committerEduardo Davila <Eduardo.Davila@creatis.insa-lyon.fr>
Tue, 3 May 2011 10:50:29 +0000 (10:50 +0000)
appli/creaNewProject/NewProject/bbtk_mySamplePackage_PKG/CMakeLists.txt
appli/creaNewProject/NewProject/bbtk_mySamplePackage_PKG/src/bbmySamplePackagemySampleBoxWithITK.cxx
appli/creaNewProject/NewProject/bbtk_mySamplePackage_PKG/src/bbmySamplePackagemySampleBoxWithITK.h

index 1eaeb785aacd61bc21f57877a814e09893cd581c..ff7a8b083730936272988c67da85977106d53f15 100644 (file)
@@ -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
   )
index 1e2d1827233a83f154f4d30fa5504558c060aec0..fc9cd4873265d9761e4f96f7e8ea232727d5fa88 100644 (file)
@@ -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 = " <<bbGetOutputOut() << std::endl; 
-}
-
+//
+// The method     void mySampleBoxWithITK::Process()
+// have a Template mechanisme and is implemented in the .h file
+//
+       
+       
 void mySampleBoxWithITK::bbUserSetDefaultValues()
 {
 
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
 //    Here we initialize the input 'In' to 0
-   bbSetInputIn(0);
+       
+       mOutput = 0;
+       bbSetInputLower(200);
+       bbSetInputUpper(1200);
 }
 
 void mySampleBoxWithITK::bbUserInitializeProcessing()
index 18789b6a266e3391ce89e28887883c7996458fe8..60503049215f2909f1685c56bd95471ecf21dbd7 100644 (file)
@@ -1,10 +1,33 @@
 
 #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 <itkBinaryThresholdImageFilter.h>
+
+#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 <class T> 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<T,D>*",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 <class ImageType> 
+void mySampleBoxWithITK::ProcessTemplated()
+{
+       bbtkDebugMessageInc("Core",9,"bbitk::BinaryThresholdImageFilter::Process<"<<bbtk::TypeName<ImageType>()<<">()"<<std::endl);
+
+       typedef itk::BinaryThresholdImageFilter<ImageType,ImageType> FilterType;
+       typename FilterType::Pointer filter = FilterType::New();
+       
+       // Input
+       ImageType* in = this->bbGetInputIn().get<ImageType*>();
+       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