]> Creatis software - bbtk.git/blob - packages/itk/src/bbitkBinaryThresholdImageFilter.h
#2975 BBTK Bug New Normal - Clean comments
[bbtk.git] / packages / itk / src / bbitkBinaryThresholdImageFilter.h
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
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
9  #
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.
16  #
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
21  #  liability.
22  #
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  # ------------------------------------------------------------------------ */
26
27 /*=========================================================================
28   Program:   bbtk
29   Module:    $RCSfile: bbitkBinaryThresholdImageFilter.h,v $
30   Language:  C++
31   Date:      $Date: 2012/11/16 08:50:39 $
32   Version:   $Revision: 1.14 $
33 =========================================================================*/
34
35 /* ---------------------------------------------------------------------
36
37 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
38 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
39 *
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.
46 *
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
51 *  liability. 
52 *
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 * ------------------------------------------------------------------------ */                                                                         
56
57
58 #ifdef _USE_ITK_
59
60 #include "bbtkAtomicBlackBox.h"
61 #include "itkBinaryThresholdImageFilter.h"
62 #include "bbtkItkBlackBoxMacros.h"
63 #include "bbitkImage.h"
64
65 namespace bbitk
66 {
67
68   //===================================================
69   template <class T>
70   class /*BBTK_EXPORT*/ BinaryThresholdImageFilter
71     : 
72     public bbtk::AtomicBlackBox,
73     public itk::BinaryThresholdImageFilter<T,T>
74   {
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*);
84     BBTK_ITK_PROCESS();
85     BBTK_ITK_DELETE();
86
87   };
88   //===================================================
89   
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   //===================================================
110
111
112   //===================================================
113   //--
114   template <class T>
115   void BinaryThresholdImageFilter<T>::bbUserSetDefaultValues()
116   {
117     bbSetInputLowerThreshold(0);
118     bbSetInputUpperThreshold(100);
119     bbSetInputInsideValue(255);
120     bbSetInputOutsideValue(0);
121   }
122   template <class T>
123   void BinaryThresholdImageFilter<T>::bbUserInitializeProcessing()
124   {
125   }     
126   template <class T>
127   void BinaryThresholdImageFilter<T>::bbUserFinalizeProcessing()
128   {
129   }
130   
131   //===================================================
132
133
134
135
136
137
138
139
140
141
142   
143   //===================================================
144   // Generic "untemplatized" filter
145   //===================================================
146   class /*BBTK_EXPORT*/ BinaryThresholdImageFilterGeneric
147     : 
148     public bbtk::AtomicBlackBox
149   {
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);
159   private :
160     inline void ProcessSwitch();
161     template <class T> void Process();
162   };
163   //===================================================
164
165   
166   //===================================================
167
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",
186               anyImagePointer,"");
187   BBTK_END_DESCRIBE_BLACK_BOX(BinaryThresholdImageFilterGeneric);
188   //===================================================
189
190
191
192
193   //===================================================
194
195   void BinaryThresholdImageFilterGeneric::ProcessSwitch()
196   {
197     BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(), this->Process);
198   }
199   //===================================================
200
201
202   //===================================================
203
204   template <class T> 
205   void BinaryThresholdImageFilterGeneric::Process()
206   {
207     bbtkDebugMessageInc("Core",9,
208                         "bbitk::BinaryThresholdImageFilterGeneric::Process<"
209                         <<bbtk::TypeName<T>()<<">()"<<std::endl);
210  
211     typedef BinaryThresholdImageFilter<T> FilterType;
212     typename FilterType::Pointer f = FilterType::New("Temp");
213           typedef T* TPointer; 
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() );
223     f->bbExecute();
224     f->bbGetOutputOut()->Register();
225     this->bbSetOutputOut( f->bbGetOutputOut() );
226
227     bbtkDebugDecTab("Core",9);
228   }
229
230   //===================================================
231
232         
233
234
235         
236
237         
238         
239 }
240 // EO namespace bbtk
241
242 #endif