ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkBinaryThresholdImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkBinaryThresholdImageFilter_h
19 #define __itkBinaryThresholdImageFilter_h
20 
22 #include "itkConceptChecking.h"
24 
25 namespace itk
26 {
63 namespace Functor
64 {
65 template< typename TInput, typename TOutput >
67 {
68 public:
70  {
75  }
76 
78 
79  void SetLowerThreshold(const TInput & thresh)
80  { m_LowerThreshold = thresh; }
81  void SetUpperThreshold(const TInput & thresh)
82  { m_UpperThreshold = thresh; }
83  void SetInsideValue(const TOutput & value)
84  { m_InsideValue = value; }
85  void SetOutsideValue(const TOutput & value)
86  { m_OutsideValue = value; }
87 
88  bool operator!=(const BinaryThreshold & other) const
89  {
92  || m_InsideValue != other.m_InsideValue
93  || m_OutsideValue != other.m_OutsideValue )
94  {
95  return true;
96  }
97  return false;
98  }
99 
100  bool operator==(const BinaryThreshold & other) const
101  {
102  return !( *this != other );
103  }
104 
105  inline TOutput operator()(const TInput & A) const
106  {
107  if ( m_LowerThreshold <= A && A <= m_UpperThreshold )
108  {
109  return m_InsideValue;
110  }
111  return m_OutsideValue;
112  }
113 
114 private:
117  TOutput m_InsideValue;
118  TOutput m_OutsideValue;
119 };
120 }
121 
122 template< typename TInputImage, typename TOutputImage >
124  public
125  UnaryFunctorImageFilter< TInputImage, TOutputImage,
126  Functor::BinaryThreshold<
127  typename TInputImage::PixelType,
128  typename TOutputImage::PixelType > >
129 {
130 public:
133  typedef UnaryFunctorImageFilter< TInputImage, TOutputImage,
135  typename TInputImage::PixelType,
136  typename TOutputImage::PixelType >
140 
142  itkNewMacro(Self);
143 
146 
148  typedef typename TInputImage::PixelType InputPixelType;
149  typedef typename TOutputImage::PixelType OutputPixelType;
150 
153 
156  itkSetMacro(OutsideValue, OutputPixelType);
157 
159  itkGetConstReferenceMacro(OutsideValue, OutputPixelType);
160 
163  itkSetMacro(InsideValue, OutputPixelType);
164 
166  itkGetConstReferenceMacro(InsideValue, OutputPixelType);
167 
172  virtual void SetUpperThreshold(const InputPixelType threshold);
173 
174  virtual void SetUpperThresholdInput(const InputPixelObjectType *);
175 
176  virtual void SetLowerThreshold(const InputPixelType threshold);
177 
178  virtual void SetLowerThresholdInput(const InputPixelObjectType *);
179 
181  virtual InputPixelType GetUpperThreshold() const;
182 
184 
185  virtual const InputPixelObjectType * GetUpperThresholdInput() const;
186 
187  virtual InputPixelType GetLowerThreshold() const;
188 
190 
191  virtual const InputPixelObjectType * GetLowerThresholdInput() const;
192 
193 #ifdef ITK_USE_CONCEPT_CHECKING
194  // Begin concept checking
195  itkConceptMacro( OutputEqualityComparableCheck,
197  itkConceptMacro( InputPixelTypeComparable,
199  itkConceptMacro( InputOStreamWritableCheck,
201  itkConceptMacro( OutputOStreamWritableCheck,
203  // End concept checking
204 #endif
205 
206 protected:
209  void PrintSelf(std::ostream & os, Indent indent) const;
210 
213  virtual void BeforeThreadedGenerateData();
214 
215 private:
216  BinaryThresholdImageFilter(const Self &); //purposely not implemented
217  void operator=(const Self &); //purposely not implemented
218 
221 };
222 } // end namespace itk
223 
224 #ifndef ITK_MANUAL_INSTANTIATION
225 #include "itkBinaryThresholdImageFilter.hxx"
226 #endif
227 
228 #endif
void SetUpperThreshold(const TInput &thresh)
virtual void SetLowerThresholdInput(const InputPixelObjectType *)
virtual void SetUpperThresholdInput(const InputPixelObjectType *)
TOutput operator()(const TInput &A) const
virtual void BeforeThreadedGenerateData()
void operator=(const Self &)
virtual void SetUpperThreshold(const InputPixelType threshold)
virtual InputPixelType GetUpperThreshold() const
Base class for all process objects that output image data.
bool operator==(const BinaryThreshold &other) const
virtual InputPixelObjectType * GetUpperThresholdInput()
Binarize an input image by thresholding.
Decorates any &quot;simple&quot; data type (data types without smart pointers) with a DataObject API...
void SetInsideValue(const TOutput &value)
void PrintSelf(std::ostream &os, Indent indent) const
virtual void SetLowerThreshold(const InputPixelType threshold)
static T max(const T &)
UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::BinaryThreshold< typename TInputImage::PixelType, typename TOutputImage::PixelType > > Superclass
Implements pixel-wise generic operation on one image.
virtual InputPixelObjectType * GetLowerThresholdInput()
void SetOutsideValue(const TOutput &value)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Define additional traits for native types such as int or float.
void SetLowerThreshold(const TInput &thresh)
SimpleDataObjectDecorator< InputPixelType > InputPixelObjectType
#define itkConceptMacro(name, concept)
bool operator!=(const BinaryThreshold &other) const
virtual InputPixelType GetLowerThreshold() const