ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkUnaryFrequencyDomainFilter.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 itkUnaryFrequencyDomainFilter_h
19 #define itkUnaryFrequencyDomainFilter_h
20 
21 #include <itkInPlaceImageFilter.h>
23 
24 namespace itk
25 {
59 template< typename TImageType,
60  typename TFrequencyIterator = FrequencyFFTLayoutImageRegionIteratorWithIndex<TImageType> >
62  public InPlaceImageFilter<TImageType, TImageType>
63 {
64 public:
65  ITK_DISALLOW_COPY_AND_ASSIGN(UnaryFrequencyDomainFilter);
66 
72 
74  itkNewMacro(Self);
75 
78 
80  using ImageType = TImageType;
81  using ImagePointer = typename ImageType::Pointer;
82  using ImageConstPointer = typename ImageType::ConstPointer;
83  using IndexType = typename TImageType::IndexType;
84  using PixelType = typename TImageType::PixelType;
85 
88 
89  static constexpr unsigned int ImageDimension = TImageType::ImageDimension;
90 
91 #ifdef ITK_USE_CONCEPT_CHECKING
92  itkConceptMacro( ImageTypeHasNumericTraitsCheck,
94 #endif
95 
97  using FrequencyIteratorType = TFrequencyIterator;
98  using FrequencyValueType = typename FrequencyIteratorType::FrequencyValueType;
99 
105  itkSetMacro( ActualXDimensionIsOdd, bool );
106  itkGetConstReferenceMacro(ActualXDimensionIsOdd, bool);
107  itkBooleanMacro( ActualXDimensionIsOdd );
109 
111  using ConstRefFunctionType = double( const FrequencyIteratorType& );
112 
115 
116 #if !defined( ITK_WRAPPING_PARSER )
117 
118  void SetFunctor( const std::function<ConstRefFunctionType> &f)
119  {
120  auto inPlaceFunctor = [f]( FrequencyIteratorType& freq ) { freq.Value() *= f( freq ); };
121 
122  m_DynamicThreadedGenerateDataFunction = [this, inPlaceFunctor]( const ImageRegionType& outputRegionForThread ) {
123  return this->DynamicThreadedGenerateDataWithFunctor( inPlaceFunctor, outputRegionForThread );
124  };
125 
126  this->Modified();
127  }
128 
130  void SetFunctor( const std::function<ValueFunctionType> &f)
131  {
132  m_DynamicThreadedGenerateDataFunction = [this, f]( const ImageRegionType& outputRegionForThread )
133  { return this->DynamicThreadedGenerateDataWithFunctor(f, outputRegionForThread); };
134 
135  this->Modified();
136  }
137 
138 
141  {
142  auto inPlaceFunctor = [f]( FrequencyIteratorType& freq ) { freq.Value() *= f( freq ); };
143 
144  m_DynamicThreadedGenerateDataFunction = [this, inPlaceFunctor]( const ImageRegionType& outputRegionForThread ) {
145  return this->DynamicThreadedGenerateDataWithFunctor( inPlaceFunctor, outputRegionForThread );
146  };
147 
148  this->Modified();
149  }
150 
152  void SetFunctor( ValueFunctionType *funcPointer)
153  {
154  m_DynamicThreadedGenerateDataFunction = [this, funcPointer]( const ImageRegionType& outputRegionForThread )
155  { return this->DynamicThreadedGenerateDataWithFunctor(funcPointer, outputRegionForThread); };
156 
157  this->Modified();
158  }
159 
160 
168  template <typename TFunctor>
169  void SetFunctor( const TFunctor & functor)
170  {
171  m_DynamicThreadedGenerateDataFunction = [this, functor]( const ImageRegionType& outputRegionForThread )
172  { return this->DynamicThreadedGenerateDataWithFunctor(functor, outputRegionForThread); };
173 
174  this->Modified();
175  }
176 #endif // !defined( ITK_WRAPPING_PARSER )
177 
178 protected:
180  void PrintSelf(std::ostream & os, Indent indent) const override;
181 
191  template <typename TFunctor>
192  void DynamicThreadedGenerateDataWithFunctor( const TFunctor &, const ImageRegionType & outputRegionForThread );
193  void DynamicThreadedGenerateData( const ImageRegionType & outputRegionForThread ) override;
195 
196 private:
197  std::function< void( const ImageRegionType& ) > m_DynamicThreadedGenerateDataFunction;
198 
200 };
201 } // end namespace itk
202 
203 #ifndef ITK_MANUAL_INSTANTIATION
204 #include "itkUnaryFrequencyDomainFilter.hxx"
205 #endif
206 
207 #endif // itkUnaryFrequencyDomainFilter_h
typename TImageType::RegionType ImageRegionType
Light weight base class for most itk classes.
void PrintSelf(std::ostream &os, Indent indent) const override
void SetFunctor(const std::function< ConstRefFunctionType > &f)
double(const FrequencyIteratorType &) ConstRefFunctionType
void SetFunctor(ValueFunctionType *funcPointer)
void(FrequencyIteratorType &) ValueFunctionType
std::function< void(const ImageRegionType &) > m_DynamicThreadedGenerateDataFunction
typename ImageType::ConstPointer ImageConstPointer
void SetFunctor(ConstRefFunctionType *f)
void SetFunctor(const TFunctor &functor)
typename TImageType::PixelType PixelType
static constexpr unsigned int ImageDimension
virtual void Modified() const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void SetFunctor(const std::function< ValueFunctionType > &f)
Performs a unary operation on a frequency domain image.
void DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const ImageRegionType &outputRegionForThread)
void DynamicThreadedGenerateData(const ImageRegionType &outputRegionForThread) override
Base class for filters that take an image as input and overwrite that image as the output...
typename TImageType::IndexType IndexType
#define itkConceptMacro(name, concept)
typename FrequencyIteratorType::FrequencyValueType FrequencyValueType