ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkInvertIntensityImageFilter.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 __itkInvertIntensityImageFilter_h
19 #define __itkInvertIntensityImageFilter_h
20 
22 
23 namespace itk
24 {
25 namespace Functor
26 {
32 template< typename TInput, typename TOutput >
34 {
35 public:
40 
41  void SetMaximum(TOutput max) { m_Maximum = max; }
42 
43  bool operator!=(const InvertIntensityTransform & other) const
44  {
45  if ( m_Maximum != other.m_Maximum )
46  {
47  return true;
48  }
49  return false;
50  }
51 
52  bool operator==(const InvertIntensityTransform & other) const
53  {
54  return !( *this != other );
55  }
56 
57  inline TOutput operator()(const TInput & x) const
58  {
59  TOutput result = static_cast< TOutput >( m_Maximum - x );
60 
61  return result;
62  }
63 
64 private:
65  TInput m_Maximum;
66 };
67 } // end namespace functor
68 
89 template< typename TInputImage, typename TOutputImage = TInputImage >
90 class ITK_EXPORT InvertIntensityImageFilter:
91  public
92  UnaryFunctorImageFilter< TInputImage, TOutputImage,
93  Functor::InvertIntensityTransform<
94  typename TInputImage::PixelType,
95  typename TOutputImage::PixelType > >
96 {
97 public:
100  typedef UnaryFunctorImageFilter< TInputImage, TOutputImage,
102  typename TInputImage::PixelType,
103  typename TOutputImage::PixelType > > Superclass;
106 
107  typedef typename TOutputImage::PixelType OutputPixelType;
108  typedef typename TInputImage::PixelType InputPixelType;
110 
112  itkNewMacro(Self);
113 
115  itkTypeMacro(InvertIntensityImageFilter,
117 
118  itkSetMacro(Maximum, InputPixelType);
119  itkGetConstReferenceMacro(Maximum, InputPixelType);
120 
122  void PrintSelf(std::ostream & os, Indent indent) const;
123 
125  void BeforeThreadedGenerateData(void);
126 
127 #ifdef ITK_USE_CONCEPT_CHECKING
128 
129  itkConceptMacro( InputHasNumericTraitsCheck,
131 
133 #endif
134 
135 protected:
138 
139 private:
140  InvertIntensityImageFilter(const Self &); //purposely not implemented
141  void operator=(const Self &); //purposely not implemented
142 
144 };
145 } // end namespace itk
146 
147 #ifndef ITK_MANUAL_INSTANTIATION
148 #include "itkInvertIntensityImageFilter.hxx"
149 #endif
150 
151 #endif
152