ITK  5.2.0
Insight Toolkit
itkUnaryFrequencyDomainFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 {
60 template <typename TImageType, typename TFrequencyIterator = FrequencyFFTLayoutImageRegionIteratorWithIndex<TImageType>>
61 class UnaryFrequencyDomainFilter : public InPlaceImageFilter<TImageType, TImageType>
62 {
63 public:
64  ITK_DISALLOW_COPY_AND_ASSIGN(UnaryFrequencyDomainFilter);
65 
71 
73  itkNewMacro(Self);
74 
77 
79  using ImageType = TImageType;
80  using ImagePointer = typename ImageType::Pointer;
81  using ImageConstPointer = typename ImageType::ConstPointer;
82  using IndexType = typename TImageType::IndexType;
83  using PixelType = typename TImageType::PixelType;
84 
87 
88  static constexpr unsigned int ImageDimension = TImageType::ImageDimension;
89 
90 #ifdef ITK_USE_CONCEPT_CHECKING
92 #endif
93 
95  using FrequencyIteratorType = TFrequencyIterator;
96  using FrequencyValueType = typename FrequencyIteratorType::FrequencyValueType;
97 
103  itkSetMacro(ActualXDimensionIsOdd, bool);
104  itkGetConstReferenceMacro(ActualXDimensionIsOdd, bool);
105  itkBooleanMacro(ActualXDimensionIsOdd);
107 
110 
113 
114 #if !defined(ITK_WRAPPING_PARSER)
115 
116  void
117  SetFunctor(const std::function<ConstRefFunctionType> & f)
118  {
119  auto inPlaceFunctor = [f](FrequencyIteratorType & freq) { freq.Value() *= f(freq); };
120 
121  m_DynamicThreadedGenerateDataFunction = [this, inPlaceFunctor](const ImageRegionType & outputRegionForThread) {
122  return this->DynamicThreadedGenerateDataWithFunctor(inPlaceFunctor, outputRegionForThread);
123  };
124 
125  this->Modified();
126  }
127 
129  void
130  SetFunctor(const std::function<ValueFunctionType> & f)
131  {
132  m_DynamicThreadedGenerateDataFunction = [this, f](const ImageRegionType & outputRegionForThread) {
133  return this->DynamicThreadedGenerateDataWithFunctor(f, outputRegionForThread);
134  };
136 
137  this->Modified();
138  }
139 
140 
142  void
144  {
145  auto inPlaceFunctor = [f](FrequencyIteratorType & freq) { freq.Value() *= f(freq); };
146 
147  m_DynamicThreadedGenerateDataFunction = [this, inPlaceFunctor](const ImageRegionType & outputRegionForThread) {
148  return this->DynamicThreadedGenerateDataWithFunctor(inPlaceFunctor, outputRegionForThread);
149  };
150 
151  this->Modified();
152  }
153 
155  void
157  {
158  m_DynamicThreadedGenerateDataFunction = [this, funcPointer](const ImageRegionType & outputRegionForThread) {
159  return this->DynamicThreadedGenerateDataWithFunctor(funcPointer, outputRegionForThread);
160  };
162 
163  this->Modified();
164  }
165 
166 
174  template <typename TFunctor>
175  void
176  SetFunctor(const TFunctor & functor)
177  {
178  m_DynamicThreadedGenerateDataFunction = [this, functor](const ImageRegionType & outputRegionForThread) {
179  return this->DynamicThreadedGenerateDataWithFunctor(functor, outputRegionForThread);
180  };
182 
183  this->Modified();
184  }
185 #endif // !defined( ITK_WRAPPING_PARSER )
186 
187 protected:
189  void
190  PrintSelf(std::ostream & os, Indent indent) const override;
191 
201  template <typename TFunctor>
202  void
203  DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const ImageRegionType & outputRegionForThread);
204  void
205  DynamicThreadedGenerateData(const ImageRegionType & outputRegionForThread) override;
207 
208 private:
210 
211  bool m_ActualXDimensionIsOdd{ false };
212 };
213 } // end namespace itk
214 
215 #ifndef ITK_MANUAL_INSTANTIATION
216 # include "itkUnaryFrequencyDomainFilter.hxx"
217 #endif
218 
219 #endif // itkUnaryFrequencyDomainFilter_h
itk::Concept::HasNumericTraits
Definition: itkConceptChecking.h:712
itk::UnaryFrequencyDomainFilter::SetFunctor
void SetFunctor(ConstRefFunctionType *f)
Definition: itkUnaryFrequencyDomainFilter.h:143
itk::InPlaceImageFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkInPlaceImageFilter.h:77
itkFrequencyFFTLayoutImageRegionIteratorWithIndex.h
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::UnaryFrequencyDomainFilter::IndexType
typename TImageType::IndexType IndexType
Definition: itkUnaryFrequencyDomainFilter.h:82
itk::UnaryFrequencyDomainFilter::UnaryFrequencyDomainFilter
UnaryFrequencyDomainFilter()
itk::UnaryFrequencyDomainFilter::ImagePointer
typename ImageType::Pointer ImagePointer
Definition: itkUnaryFrequencyDomainFilter.h:80
itk::UnaryFrequencyDomainFilter::DynamicThreadedGenerateData
void DynamicThreadedGenerateData(const ImageRegionType &outputRegionForThread) override
itk::UnaryFrequencyDomainFilter::DynamicThreadedGenerateDataWithFunctor
void DynamicThreadedGenerateDataWithFunctor(const TFunctor &, const ImageRegionType &outputRegionForThread)
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::UnaryFrequencyDomainFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::UnaryFrequencyDomainFilter::ValueFunctionType
void(FrequencyIteratorType &) ValueFunctionType
Definition: itkUnaryFrequencyDomainFilter.h:112
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::UnaryFrequencyDomainFilter::FrequencyIteratorType
TFrequencyIterator FrequencyIteratorType
Definition: itkUnaryFrequencyDomainFilter.h:95
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::UnaryFrequencyDomainFilter::FrequencyValueType
typename FrequencyIteratorType::FrequencyValueType FrequencyValueType
Definition: itkUnaryFrequencyDomainFilter.h:96
itk::UnaryFrequencyDomainFilter
Performs a unary operation on a frequency domain image.
Definition: itkUnaryFrequencyDomainFilter.h:61
itk::UnaryFrequencyDomainFilter::SetFunctor
void SetFunctor(ValueFunctionType *funcPointer)
Definition: itkUnaryFrequencyDomainFilter.h:156
itk::UnaryFrequencyDomainFilter::ImageDimension
static constexpr unsigned int ImageDimension
Definition: itkUnaryFrequencyDomainFilter.h:88
itk::UnaryFrequencyDomainFilter::ImageConstPointer
typename ImageType::ConstPointer ImageConstPointer
Definition: itkUnaryFrequencyDomainFilter.h:81
itkConceptMacro
#define itkConceptMacro(name, concept)
Definition: itkConceptChecking.h:64
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::UnaryFrequencyDomainFilter::ConstRefFunctionType
double(const FrequencyIteratorType &) ConstRefFunctionType
Definition: itkUnaryFrequencyDomainFilter.h:109
itk::UnaryFrequencyDomainFilter::SetFunctor
void SetFunctor(const TFunctor &functor)
Definition: itkUnaryFrequencyDomainFilter.h:176
itkInPlaceImageFilter.h
itk::UnaryFrequencyDomainFilter::ImageRegionType
typename TImageType::RegionType ImageRegionType
Definition: itkUnaryFrequencyDomainFilter.h:86
itk::UnaryFrequencyDomainFilter::m_ActualXDimensionIsOdd
bool m_ActualXDimensionIsOdd
Definition: itkUnaryFrequencyDomainFilter.h:211
itk::UnaryFrequencyDomainFilter::m_DynamicThreadedGenerateDataFunction
std::function< void(const ImageRegionType &)> m_DynamicThreadedGenerateDataFunction
Definition: itkUnaryFrequencyDomainFilter.h:209
itk::Object::Modified
virtual void Modified() const
itk::UnaryFrequencyDomainFilter::ImageType
TImageType ImageType
Definition: itkUnaryFrequencyDomainFilter.h:79
itk::UnaryFrequencyDomainFilter::SetFunctor
void SetFunctor(const std::function< ConstRefFunctionType > &f)
Definition: itkUnaryFrequencyDomainFilter.h:117
itk::UnaryFrequencyDomainFilter::PixelType
typename TImageType::PixelType PixelType
Definition: itkUnaryFrequencyDomainFilter.h:83
itk::UnaryFrequencyDomainFilter::SetFunctor
void SetFunctor(const std::function< ValueFunctionType > &f)
Definition: itkUnaryFrequencyDomainFilter.h:130