2 #ifndef __bbmySamplePackagemySampleBoxWithITK_h_INCLUDED__
3 #define __bbmySamplePackagemySampleBoxWithITK_h_INCLUDED__
6 #define BBTK_ITK_IMAGE_DIM_2
7 #define BBTK_ITK_IMAGE_DIM_3
8 #define BBTK_ITK_IMAGE_DIM_4
9 #define BBTK_ITK_IMAGE_TYPE_int8_t
10 #define BBTK_ITK_IMAGE_TYPE_uint8_t
11 #define BBTK_ITK_IMAGE_TYPE_int16_t
12 #define BBTK_ITK_IMAGE_TYPE_uint16_t
13 #define BBTK_ITK_IMAGE_TYPE_int32_t
14 #define BBTK_ITK_IMAGE_TYPE_uint32_t
15 #define BBTK_ITK_IMAGE_TYPE_float
16 #define BBTK_ITK_IMAGE_TYPE_double
20 #include "bbmySamplePackage_EXPORT.h"
21 #include "bbtkAtomicBlackBox.h"
24 #include "bbitkImage.h"
26 #include <itkBinaryThresholdImageFilter.h>
28 #include "itkResampleImageFilter.h"
29 #include "itkNearestNeighborInterpolateImageFunction.h"
31 namespace bbmySamplePackage
34 class bbmySamplePackage_EXPORT mySampleBoxWithITK
36 public bbtk::AtomicBlackBox
38 BBTK_BLACK_BOX_INTERFACE(mySampleBoxWithITK,bbtk::AtomicBlackBox);
40 BBTK_DECLARE_INPUT(In,bbitk::anyImagePointer);
41 BBTK_DECLARE_INPUT(Lower,double);
42 BBTK_DECLARE_INPUT(Upper,double);
43 BBTK_DECLARE_OUTPUT(Out,bbitk::anyImagePointer);
45 BBTK_PROCESS(Process);
47 inline void Process();
48 template <class T> void ProcessTemplated();
52 BBTK_BEGIN_DESCRIBE_BLACK_BOX(mySampleBoxWithITK,bbtk::AtomicBlackBox);
53 BBTK_NAME("mySampleBoxWithITK");
54 BBTK_AUTHOR("Info-Dev");
55 BBTK_DESCRIPTION("Example ITK box - CreaNewProject");
56 BBTK_CATEGORY("filter");
57 BBTK_INPUT(mySampleBoxWithITK,In,"Input image. Can be any itk::Image<T,D>*",bbitk::anyImagePointer,"");
58 BBTK_INPUT(mySampleBoxWithITK,Lower,"(200 default) Lower value for the threshold*",double,"");
59 BBTK_INPUT(mySampleBoxWithITK,Upper,"(1200 default) Upper value for the threshold*",double,"");
60 BBTK_OUTPUT(mySampleBoxWithITK,Out,"Output Image",bbitk::anyImagePointer,"");
61 BBTK_END_DESCRIBE_BLACK_BOX(mySampleBoxWithITK);
65 //===================================================
66 void mySampleBoxWithITK::Process()
68 bbtk::TypeInfo t = bbGetInputIn().type();
69 BBTK_TEMPLATE_ITK_IMAGE_SWITCH(t, this->ProcessTemplated);
71 //===================================================
74 //===================================================
75 template <class ImageType>
76 void mySampleBoxWithITK::ProcessTemplated()
78 bbtkDebugMessageInc("Core",9,"bbitk::BinaryThresholdImageFilter::Process<"<<bbtk::TypeName<ImageType>()<<">()"<<std::endl);
80 typedef itk::BinaryThresholdImageFilter<ImageType,ImageType> FilterType;
81 typename FilterType::Pointer filter = FilterType::New();
84 ImageType* in = this->bbGetInputIn().get<ImageType*>();
85 filter->SetInput( in );
86 filter->SetInsideValue (255);
87 filter->SetOutsideValue (0);
88 filter->SetLowerThreshold( bbGetInputLower() );
89 filter->SetUpperThreshold( bbGetInputUpper() );
92 filter->GetOutput()->Register();
93 if (mOutput) mOutput->UnRegister();
94 mOutput = filter->GetOutput();
95 this->bbSetOutputOut( filter->GetOutput() );
97 bbtkDebugDecTab("Core",9);
99 //===================================================
102 // EO namespace bbmySamplePackage
104 #endif // __bbmySamplePackagemySampleBoxWithITK_h_INCLUDED__