2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
27 /*=========================================================================
29 Module: $RCSfile: bbitkBinaryThresholdImageFilter.h,v $
31 Date: $Date: 2012/11/16 08:50:39 $
32 Version: $Revision: 1.14 $
33 =========================================================================*/
35 /* ---------------------------------------------------------------------
37 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
38 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
40 * This software is governed by the CeCILL-B license under French law and
41 * abiding by the rules of distribution of free software. You can use,
42 * modify and/ or redistribute the software under the terms of the CeCILL-B
43 * license as circulated by CEA, CNRS and INRIA at the following URL
44 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
45 * or in the file LICENSE.txt.
47 * As a counterpart to the access to the source code and rights to copy,
48 * modify and redistribute granted by the license, users are provided only
49 * with a limited warranty and the software's author, the holder of the
50 * economic rights, and the successive licensors have only limited
53 * The fact that you are presently reading this means that you have had
54 * knowledge of the CeCILL-B license and that you accept its terms.
55 * ------------------------------------------------------------------------ */
60 #include "bbtkAtomicBlackBox.h"
61 #include "itkBinaryThresholdImageFilter.h"
62 #include "bbtkItkBlackBoxMacros.h"
63 #include "bbitkImage.h"
68 //===================================================
70 class /*BBTK_EXPORT*/ BinaryThresholdImageFilter
72 public bbtk::AtomicBlackBox,
73 public itk::BinaryThresholdImageFilter<T,T>
75 BBTK_TEMPLATE_BLACK_BOX_INTERFACE(BinaryThresholdImageFilter,
76 bbtk::AtomicBlackBox,T);
77 typedef itk::BinaryThresholdImageFilter<T,T> itkParent;
78 BBTK_DECLARE_ITK_INPUT(In,const T*);
79 BBTK_DECLARE_ITK_PARAM(LowerThreshold,typename T::PixelType);
80 BBTK_DECLARE_ITK_PARAM(UpperThreshold,typename T::PixelType);
81 BBTK_DECLARE_ITK_PARAM(InsideValue,typename T::PixelType);
82 BBTK_DECLARE_ITK_PARAM(OutsideValue,typename T::PixelType);
83 BBTK_DECLARE_ITK_OUTPUT(Out,T*);
88 //===================================================
90 //===================================================
91 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter,
92 bbtk::AtomicBlackBox);
93 BBTK_NAME("BinaryThresholdImageFilter<"+bbtk::TypeName<T>()+">");
94 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
95 BBTK_DESCRIPTION("Binarizes an image by thresholding (bbification of itk::BinaryThresholdImageFilter)");
96 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,In,"Input image",const T*);
97 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,LowerThreshold,
98 "Lower threshold",typename T::PixelType);
99 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,UpperThreshold,
100 "Upper threshold",typename T::PixelType);
101 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,InsideValue,
102 "Output value for pixels inside thresholds",
103 typename T::PixelType);
104 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,OutsideValue,
105 "Output value for pixels outside thresholds",
106 typename T::PixelType);
107 BBTK_TEMPLATE_OUTPUT(BinaryThresholdImageFilter,Out,"Output image",T*);
108 BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter);
109 //===================================================
112 //===================================================
115 void BinaryThresholdImageFilter<T>::bbUserSetDefaultValues()
117 bbSetInputLowerThreshold(0);
118 bbSetInputUpperThreshold(100);
119 bbSetInputInsideValue(255);
120 bbSetInputOutsideValue(0);
123 void BinaryThresholdImageFilter<T>::bbUserInitializeProcessing()
127 void BinaryThresholdImageFilter<T>::bbUserFinalizeProcessing()
131 //===================================================
143 //===================================================
144 // Generic "untemplatized" filter
145 //===================================================
146 class /*BBTK_EXPORT*/ BinaryThresholdImageFilterGeneric
148 public bbtk::AtomicBlackBox
150 BBTK_BLACK_BOX_INTERFACE(BinaryThresholdImageFilterGeneric,
151 bbtk::AtomicBlackBox);
152 BBTK_DECLARE_INPUT(In,anyImagePointer);
153 BBTK_DECLARE_INPUT(LowerThreshold,double);
154 BBTK_DECLARE_INPUT(UpperThreshold,double);
155 BBTK_DECLARE_INPUT(InsideValue,double);
156 BBTK_DECLARE_INPUT(OutsideValue,double);
157 BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
158 BBTK_PROCESS(ProcessSwitch);
160 inline void ProcessSwitch();
161 template <class T> void Process();
163 //===================================================
166 //===================================================
168 BBTK_BEGIN_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric,
169 bbtk::AtomicBlackBox);
170 BBTK_NAME("BinaryThresholdImageFilter");
171 BBTK_AUTHOR("laurent.guigues at creatis.insa-lyon.fr");
172 BBTK_CATEGORY("filter;image");
173 BBTK_DESCRIPTION("Binarizes an image by thresholding (generic bbification of itk::BinaryThresholdImageFilter)");
174 BBTK_INPUT(BinaryThresholdImageFilterGeneric,In,
175 "Input image. Can be any itk::Image<T,D>*",anyImagePointer,"");
176 BBTK_INPUT(BinaryThresholdImageFilterGeneric,LowerThreshold,
177 "Lower threshold",double,"");
178 BBTK_INPUT(BinaryThresholdImageFilterGeneric,UpperThreshold,
179 "Upper threshold",double,"");
180 BBTK_INPUT(BinaryThresholdImageFilterGeneric,InsideValue,
181 "Output value for pixels inside thresholds",double,"");
182 BBTK_INPUT(BinaryThresholdImageFilterGeneric,OutsideValue,
183 "Output value for pixels outside thresholds",double,"");
184 BBTK_OUTPUT(BinaryThresholdImageFilterGeneric,Out,
185 "Output image. Of the same type and dimension than the input image",
187 BBTK_END_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric);
188 //===================================================
193 //===================================================
195 void BinaryThresholdImageFilterGeneric::ProcessSwitch()
197 BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process);
199 //===================================================
202 //===================================================
205 void BinaryThresholdImageFilterGeneric::Process()
207 bbtkDebugMessageInc("Core",9,
208 "bbitk::BinaryThresholdImageFilterGeneric::Process<"
209 <<bbtk::TypeName<T>()<<">()"<<std::endl);
211 typedef BinaryThresholdImageFilter<T> FilterType;
212 typename FilterType::Pointer f = FilterType::New("Temp");
214 f->bbSetInputIn( this->bbGetInputIn().get < TPointer > () );
215 f->bbSetInputLowerThreshold ( (typename T::PixelType)
216 this->bbGetInputLowerThreshold() );
217 f->bbSetInputUpperThreshold ( (typename T::PixelType)
218 this->bbGetInputUpperThreshold() );
219 f->bbSetInputInsideValue ( (typename T::PixelType)
220 this->bbGetInputInsideValue() );
221 f->bbSetInputOutsideValue ( (typename T::PixelType)
222 this->bbGetInputOutsideValue() );
224 f->bbGetOutputOut()->Register();
225 this->bbSetOutputOut( f->bbGetOutputOut() );
227 bbtkDebugDecTab("Core",9);
230 //===================================================