1 /*=========================================================================
3 Module: $RCSfile: bbitkBinaryThresholdImageFilter.h,v $
5 Date: $Date: 2009/05/18 10:45:43 $
6 Version: $Revision: 1.13 $
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"
42 //===================================================
44 class /*BBTK_EXPORT*/ BinaryThresholdImageFilter
46 public bbtk::AtomicBlackBox,
47 public itk::BinaryThresholdImageFilter<T,T>
49 BBTK_TEMPLATE_BLACK_BOX_INTERFACE(BinaryThresholdImageFilter,
50 bbtk::AtomicBlackBox,T);
51 typedef itk::BinaryThresholdImageFilter<T,T> itkParent;
52 BBTK_DECLARE_ITK_INPUT(In,const T*);
53 BBTK_DECLARE_ITK_PARAM(LowerThreshold,typename T::PixelType);
54 BBTK_DECLARE_ITK_PARAM(UpperThreshold,typename T::PixelType);
55 BBTK_DECLARE_ITK_PARAM(InsideValue,typename T::PixelType);
56 BBTK_DECLARE_ITK_PARAM(OutsideValue,typename T::PixelType);
57 BBTK_DECLARE_ITK_OUTPUT(Out,T*);
62 //===================================================
64 //===================================================
65 BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter,
66 bbtk::AtomicBlackBox);
67 BBTK_NAME("BinaryThresholdImageFilter<"+bbtk::TypeName<T>()+">");
68 BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
69 BBTK_DESCRIPTION("Binarizes an image by thresholding (bbification of itk::BinaryThresholdImageFilter)");
70 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,In,"Input image",const T*);
71 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,LowerThreshold,
72 "Lower threshold",typename T::PixelType);
73 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,UpperThreshold,
74 "Upper threshold",typename T::PixelType);
75 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,InsideValue,
76 "Output value for pixels inside thresholds",
77 typename T::PixelType);
78 BBTK_TEMPLATE_INPUT(BinaryThresholdImageFilter,OutsideValue,
79 "Output value for pixels outside thresholds",
80 typename T::PixelType);
81 BBTK_TEMPLATE_OUTPUT(BinaryThresholdImageFilter,Out,"Output image",T*);
82 BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter);
83 //===================================================
86 //===================================================
89 void BinaryThresholdImageFilter<T>::bbUserSetDefaultValues()
91 bbSetInputLowerThreshold(0);
92 bbSetInputUpperThreshold(100);
93 bbSetInputInsideValue(255);
94 bbSetInputOutsideValue(0);
97 void BinaryThresholdImageFilter<T>::bbUserInitializeProcessing()
101 void BinaryThresholdImageFilter<T>::bbUserFinalizeProcessing()
105 //===================================================
117 //===================================================
118 // Generic "untemplatized" filter
119 //===================================================
120 class /*BBTK_EXPORT*/ BinaryThresholdImageFilterGeneric
122 public bbtk::AtomicBlackBox
124 BBTK_BLACK_BOX_INTERFACE(BinaryThresholdImageFilterGeneric,
125 bbtk::AtomicBlackBox);
126 BBTK_DECLARE_INPUT(In,anyImagePointer);
127 BBTK_DECLARE_INPUT(LowerThreshold,double);
128 BBTK_DECLARE_INPUT(UpperThreshold,double);
129 BBTK_DECLARE_INPUT(InsideValue,double);
130 BBTK_DECLARE_INPUT(OutsideValue,double);
131 BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
132 BBTK_PROCESS(ProcessSwitch);
134 inline void ProcessSwitch();
135 template <class T> void Process();
137 //===================================================
140 //===================================================
142 BBTK_BEGIN_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric,
143 bbtk::AtomicBlackBox);
144 BBTK_NAME("BinaryThresholdImageFilter");
145 BBTK_AUTHOR("laurent.guigues at creatis.insa-lyon.fr");
146 BBTK_CATEGORY("filter;image");
147 BBTK_DESCRIPTION("Binarizes an image by thresholding (generic bbification of itk::BinaryThresholdImageFilter)");
148 BBTK_INPUT(BinaryThresholdImageFilterGeneric,In,
149 "Input image. Can be any itk::Image<T,D>*",anyImagePointer,"");
150 BBTK_INPUT(BinaryThresholdImageFilterGeneric,LowerThreshold,
151 "Lower threshold",double,"");
152 BBTK_INPUT(BinaryThresholdImageFilterGeneric,UpperThreshold,
153 "Upper threshold",double,"");
154 BBTK_INPUT(BinaryThresholdImageFilterGeneric,InsideValue,
155 "Output value for pixels inside thresholds",double,"");
156 BBTK_INPUT(BinaryThresholdImageFilterGeneric,OutsideValue,
157 "Output value for pixels outside thresholds",double,"");
158 BBTK_OUTPUT(BinaryThresholdImageFilterGeneric,Out,
159 "Output image. Of the same type and dimension than the input image",
161 BBTK_END_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric);
162 //===================================================
167 //===================================================
169 void BinaryThresholdImageFilterGeneric::ProcessSwitch()
171 BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process);
173 //===================================================
176 //===================================================
179 void BinaryThresholdImageFilterGeneric::Process()
181 bbtkDebugMessageInc("Core",9,
182 "bbitk::BinaryThresholdImageFilterGeneric::Process<"
183 <<bbtk::TypeName<T>()<<">()"<<std::endl);
185 typedef BinaryThresholdImageFilter<T> FilterType;
186 typename FilterType::Pointer f = FilterType::New("Temp");
188 f->bbSetInputIn( this->bbGetInputIn().get < TPointer > () );
189 f->bbSetInputLowerThreshold ( (typename T::PixelType)
190 this->bbGetInputLowerThreshold() );
191 f->bbSetInputUpperThreshold ( (typename T::PixelType)
192 this->bbGetInputUpperThreshold() );
193 f->bbSetInputInsideValue ( (typename T::PixelType)
194 this->bbGetInputInsideValue() );
195 f->bbSetInputOutsideValue ( (typename T::PixelType)
196 this->bbGetInputOutsideValue() );
198 f->bbGetOutputOut()->Register();
199 this->bbSetOutputOut( f->bbGetOutputOut() );
201 bbtkDebugDecTab("Core",9);
204 //===================================================