ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkModulusImageFilter.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 __itkModulusImageFilter_h
19 #define __itkModulusImageFilter_h
20 
22 
23 namespace itk
24 {
25 namespace Functor
26 {
27 template< typename TInput, typename TOutput >
29 {
30 public:
33  void SetDividend(TOutput dividend) { m_Dividend = dividend; }
34 
35  bool operator!=(const ModulusTransform & other) const
36  {
37  if ( m_Dividend != other.m_Dividend )
38  {
39  return true;
40  }
41  return false;
42  }
43 
44  bool operator==(const ModulusTransform & other) const
45  {
46  return !( *this != other );
47  }
48 
49  inline TOutput operator()(const TInput & x) const
50  {
51  TOutput result = static_cast< TOutput >( x % m_Dividend );
52 
53  return result;
54  }
55 
56 private:
57  TInput m_Dividend;
58 };
59 } // end namespace functor
60 
72 template< typename TInputImage, typename TOutputImage = TInputImage >
73 class ITK_EXPORT ModulusImageFilter:
74  public
75  UnaryFunctorImageFilter< TInputImage, TOutputImage,
76  Functor::ModulusTransform<
77  typename TInputImage::PixelType,
78  typename TOutputImage::PixelType > >
79 {
80 public:
84  TInputImage, TOutputImage,
86  typename TInputImage::PixelType,
87  typename TOutputImage::PixelType > > Superclass;
88 
91 
92  typedef typename TOutputImage::PixelType OutputPixelType;
93  typedef typename TInputImage::PixelType InputPixelType;
95 
97  itkNewMacro(Self);
98 
100  itkTypeMacro(ModulusImageFilter,
102 
104  itkSetMacro(Dividend, InputPixelType);
105  itkGetConstReferenceMacro(Dividend, InputPixelType);
107 
109  void PrintSelf(std::ostream & os, Indent indent) const;
110 
112  void BeforeThreadedGenerateData(void);
113 
114 #ifdef ITK_USE_CONCEPT_CHECKING
115 
116  itkConceptMacro( InputHasNumericTraitsCheck,
118 
120 #endif
121 protected:
123  virtual ~ModulusImageFilter() {}
124 private:
125  ModulusImageFilter(const Self &); //purposely not implemented
126  void operator=(const Self &); //purposely not implemented
128 
130 };
131 } // end namespace itk
132 
133 #ifndef ITK_MANUAL_INSTANTIATION
134 #include "itkModulusImageFilter.hxx"
135 #endif
136 
137 #endif
138