1 /*=========================================================================
3 Module: $RCSfile: bbitkBinaryThresholdImageFilter.h,v $
5 Date: $Date: 2009/05/15 14:57:58 $
6 Version: $Revision: 1.12 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
34 #include "bbtkAtomicBlackBox.h"
35 #include "itkBinaryThresholdImageFilter.h"
36 #include "bbtkItkBlackBoxMacros.h"
37 #include "bbitkImage.h"
43 class /*BBTK_EXPORT*/ BinaryThresholdImageFilter
45 public bbtk::AtomicBlackBox,
46 public itk::BinaryThresholdImageFilter<T,T>
48 BBTK_TEMPLATE_BLACK_BOX_INTERFACE(BinaryThresholdImageFilter,
49 bbtk::AtomicBlackBox,T);
50 typedef itk::BinaryThresholdImageFilter<T,T> itkParent;
51 BBTK_DECLARE_ITK_INPUT(In,const T*);
52 BBTK_DECLARE_ITK_PARAM(LowerThreshold,typename T::PixelType);
53 BBTK_DECLARE_ITK_PARAM(UpperThreshold,typename T::PixelType);
54 BBTK_DECLARE_ITK_PARAM(InsideValue,typename T::PixelType);
55 BBTK_DECLARE_ITK_PARAM(OutsideValue,typename T::PixelType);
56 BBTK_DECLARE_ITK_OUTPUT(Out,T*);
63 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter,
64 bbtk::AtomicBlackBox);
65 BBTK_NAME("BinaryThresholdImageFilter<"+bbtk::TypeName<T>()+">");
66 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
67 BBTK_DESCRIPTION("Binarizes an image by thresholding (bbification of itk::BinaryThresholdImageFilter)");
68 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,In,"Input image",const T*);
69 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,LowerThreshold,
70 "Lower threshold",typename T::PixelType);
71 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,UpperThreshold,
72 "Upper threshold",typename T::PixelType);
73 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,InsideValue,
74 "Output value for pixels inside thresholds",
75 typename T::PixelType);
76 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,OutsideValue,
77 "Output value for pixels outside thresholds",
78 typename T::PixelType);
79 BBTK_TEMPLATE_OUTPUT(BinaryThresholdImageFilter,Out,"Output image",T*);
80 BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter);
82 //===================================================
83 // Generic "untemplatized" filter
84 //===================================================
85 class /*BBTK_EXPORT*/ BinaryThresholdImageFilterGeneric
87 public bbtk::AtomicBlackBox
89 BBTK_BLACK_BOX_INTERFACE(BinaryThresholdImageFilterGeneric,
90 bbtk::AtomicBlackBox);
91 BBTK_DECLARE_INPUT(In,anyImagePointer);
92 BBTK_DECLARE_INPUT(LowerThreshold,double);
93 BBTK_DECLARE_INPUT(UpperThreshold,double);
94 BBTK_DECLARE_INPUT(InsideValue,double);
95 BBTK_DECLARE_INPUT(OutsideValue,double);
96 BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
97 BBTK_PROCESS(ProcessSwitch);
99 inline void ProcessSwitch();
100 template <class T> void Process();
103 BBTK_BEGIN_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric,
104 bbtk::AtomicBlackBox);
105 BBTK_NAME("BinaryThresholdImageFilter");
106 BBTK_AUTHOR("laurent.guigues at creatis.insa-lyon.fr");
107 BBTK_CATEGORY("filter;image");
108 BBTK_DESCRIPTION("Binarizes an image by thresholding (generic bbification of itk::BinaryThresholdImageFilter)");
109 BBTK_INPUT(BinaryThresholdImageFilterGeneric,In,
110 "Input image. Can be any itk::Image<T,D>*",anyImagePointer,"");
111 BBTK_INPUT(BinaryThresholdImageFilterGeneric,LowerThreshold,
112 "Lower threshold",double,"");
113 BBTK_INPUT(BinaryThresholdImageFilterGeneric,UpperThreshold,
114 "Upper threshold",double,"");
115 BBTK_INPUT(BinaryThresholdImageFilterGeneric,InsideValue,
116 "Output value for pixels inside thresholds",double,"");
117 BBTK_INPUT(BinaryThresholdImageFilterGeneric,OutsideValue,
118 "Output value for pixels outside thresholds",double,"");
119 BBTK_OUTPUT(BinaryThresholdImageFilterGeneric,Out,
120 "Output image. Of the same type and dimension than the input image",
122 BBTK_END_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric);
126 void BinaryThresholdImageFilterGeneric::ProcessSwitch()
128 BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process);
132 void BinaryThresholdImageFilterGeneric::Process()
134 bbtkDebugMessageInc("Core",9,
135 "bbitk::BinaryThresholdImageFilterGeneric::Process<"
136 <<bbtk::TypeName<T>()<<">()"<<std::endl);
138 typedef BinaryThresholdImageFilter<T> FilterType;
139 typename FilterType::Pointer f = FilterType::New("Temp");
141 f->bbSetInputIn( this->bbGetInputIn().get < TPointer > () );
142 f->bbSetInputLowerThreshold ( (typename T::PixelType)
143 this->bbGetInputLowerThreshold() );
144 f->bbSetInputUpperThreshold ( (typename T::PixelType)
145 this->bbGetInputUpperThreshold() );
146 f->bbSetInputInsideValue ( (typename T::PixelType)
147 this->bbGetInputInsideValue() );
148 f->bbSetInputOutsideValue ( (typename T::PixelType)
149 this->bbGetInputOutsideValue() );
151 f->bbGetOutputOut()->Register();
152 this->bbSetOutputOut( f->bbGetOutputOut() );
154 bbtkDebugDecTab("Core",9);
159 // template <class T>
160 // void BinaryThresholdImageFilter<T>::bbUserSetDefaultValues()
162 // bbSetInputLowerThreshold(0);
163 // bbSetInputUpperThreshold(100);
164 // bbSetInputInsideValue(255);
165 // bbSetInputOutsideValue(0);
168 void BinaryThresholdImageFilterGeneric::bbUserSetDefaultValues()
170 bbSetInputLowerThreshold(0);
171 bbSetInputUpperThreshold(100);
172 bbSetInputInsideValue(255);
173 bbSetInputOutsideValue(0);
179 void BinaryThresholdImageFilter<T>::bbUserInitializeProcessing()
183 void BinaryThresholdImageFilterGeneric::bbUserInitializeProcessing()
192 void BinaryThresholdImageFilter<T>::bbUserFinalizeProcessing()
196 void BinaryThresholdImageFilterGeneric::bbUserFinalizeProcessing()