ITK  5.2.0
Insight Toolkit
itkRecursiveSeparableImageFilter.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 itkRecursiveSeparableImageFilter_h
19 #define itkRecursiveSeparableImageFilter_h
20 
21 #include "itkInPlaceImageFilter.h"
22 #include "itkNumericTraits.h"
24 
25 namespace itk
26 {
51 template <typename TInputImage, typename TOutputImage = TInputImage>
52 class ITK_TEMPLATE_EXPORT RecursiveSeparableImageFilter : public InPlaceImageFilter<TInputImage, TOutputImage>
53 {
54 public:
55  ITK_DISALLOW_COPY_AND_MOVE(RecursiveSeparableImageFilter);
56 
62 
65 
67  using InputImagePointer = typename TInputImage::Pointer;
68  using InputImageConstPointer = typename TInputImage::ConstPointer;
69 
75  using InputPixelType = typename TInputImage::PixelType;
78 
80 
82  using InputImageType = TInputImage;
83 
85  using OutputImageType = TOutputImage;
86 
88  itkGetConstMacro(Direction, unsigned int);
89 
91  itkSetMacro(Direction, unsigned int);
92 
94  void
95  SetInputImage(const TInputImage *);
96 
98  const TInputImage *
99  GetInputImage();
100 
101 protected:
103  ~RecursiveSeparableImageFilter() override = default;
104  void
105  PrintSelf(std::ostream & os, Indent indent) const override;
106 
107  void
108  BeforeThreadedGenerateData() override;
109 
110  void
111  GenerateData() override;
112 
113  void
114  DynamicThreadedGenerateData(const OutputImageRegionType &) override;
115 
124  void
125  EnlargeOutputRequestedRegion(DataObject * output) override;
126 
131  virtual void
132  SetUp(ScalarRealType spacing) = 0;
133 
140  void
141  FilterDataArray(RealType * outs, const RealType * data, RealType * scratch, SizeValueType ln) const;
142 
143 protected:
149 
157 
163 
170 
175 
176 
177  template <typename T1, typename T2>
178  static inline void
179  MathEMAMAMAM(T1 & out,
180  const T1 & a1,
181  const T2 & b1,
182  const T1 & a2,
183  const T2 & b2,
184  const T1 & a3,
185  const T2 & b3,
186  const T1 & a4,
187  const T2 & b4)
188  {
189  out = a1 * b1 + a2 * b2 + a3 * b3 + a4 * b4;
190  }
191 
192 
193  template <typename T1, typename T2>
194  static inline void
196  const VariableLengthVector<T1> & a1,
197  const T2 & b1,
198  const VariableLengthVector<T1> & a2,
199  const T2 & b2,
200  const VariableLengthVector<T1> & a3,
201  const T2 & b3,
202  const VariableLengthVector<T1> & a4,
203  const T2 & b4)
204  {
205  const unsigned int sz = a1.GetSize();
206  if (sz != out.GetSize())
207  {
208  out.SetSize(sz);
209  }
210  for (unsigned int i = 0; i < sz; ++i)
211  {
212  out[i] = a1[i] * b1 + a2[i] * b2 + a3[i] * b3 + a4[i] * b4;
213  }
214  }
215 
216  template <typename T1, typename T2>
217  static inline void
218  MathSMAMAMAM(T1 & out,
219  const T1 & a1,
220  const T2 & b1,
221  const T1 & a2,
222  const T2 & b2,
223  const T1 & a3,
224  const T2 & b3,
225  const T1 & a4,
226  const T2 & b4)
227  {
228  out -= a1 * b1 + a2 * b2 + a3 * b3 + a4 * b4;
229  }
230 
231  template <typename T1, typename T2>
232  static inline void
234  const VariableLengthVector<T1> & a1,
235  const T2 & b1,
236  const VariableLengthVector<T1> & a2,
237  const T2 & b2,
238  const VariableLengthVector<T1> & a3,
239  const T2 & b3,
240  const VariableLengthVector<T1> & a4,
241  const T2 & b4)
242  {
243  const unsigned int sz = a1.GetSize();
244  if (sz != out.GetSize())
245  {
246  out.SetSize(sz);
247  }
248  for (unsigned int i = 0; i < sz; ++i)
249  {
250  out[i] -= a1[i] * b1 + a2[i] * b2 + a3[i] * b3 + a4[i] * b4;
251  }
252  }
253 
254 private:
257  unsigned int m_Direction{ 0 };
258 };
259 } // end namespace itk
260 
261 #ifndef ITK_MANUAL_INSTANTIATION
262 # include "itkRecursiveSeparableImageFilter.hxx"
263 #endif
264 
265 #endif
itk::RecursiveSeparableImageFilter::ScalarRealType
typename NumericTraits< InputPixelType >::ScalarRealType ScalarRealType
Definition: itkRecursiveSeparableImageFilter.h:77
itk::RecursiveSeparableImageFilter::m_BN2
ScalarRealType m_BN2
Definition: itkRecursiveSeparableImageFilter.h:167
itk::RecursiveSeparableImageFilter::m_N3
ScalarRealType m_N3
Definition: itkRecursiveSeparableImageFilter.h:148
itk::RecursiveSeparableImageFilter::m_BM2
ScalarRealType m_BM2
Definition: itkRecursiveSeparableImageFilter.h:172
itk::RecursiveSeparableImageFilter::MathEMAMAMAM
static void MathEMAMAMAM(VariableLengthVector< T1 > &out, const VariableLengthVector< T1 > &a1, const T2 &b1, const VariableLengthVector< T1 > &a2, const T2 &b2, const VariableLengthVector< T1 > &a3, const T2 &b3, const VariableLengthVector< T1 > &a4, const T2 &b4)
Definition: itkRecursiveSeparableImageFilter.h:195
itk::RecursiveSeparableImageFilter::m_N1
ScalarRealType m_N1
Definition: itkRecursiveSeparableImageFilter.h:146
itk::RecursiveSeparableImageFilter::m_BN4
ScalarRealType m_BN4
Definition: itkRecursiveSeparableImageFilter.h:169
itk::RecursiveSeparableImageFilter::m_D4
ScalarRealType m_D4
Definition: itkRecursiveSeparableImageFilter.h:156
itk::RecursiveSeparableImageFilter::m_N0
ScalarRealType m_N0
Definition: itkRecursiveSeparableImageFilter.h:145
itk::InPlaceImageFilter
Base class for filters that take an image as input and overwrite that image as the output.
Definition: itkInPlaceImageFilter.h:77
itkVariableLengthVector.h
itk::VariableLengthVector::SetSize
void SetSize(unsigned int sz, TReallocatePolicy reallocatePolicy, TKeepValuesPolicy keepValues)
itk::VariableLengthVector::GetSize
unsigned int GetSize() const
Definition: itkVariableLengthVector.h:597
itk::RecursiveSeparableImageFilter::m_M3
ScalarRealType m_M3
Definition: itkRecursiveSeparableImageFilter.h:161
itk::SmartPointer< Self >
itk::RecursiveSeparableImageFilter
Base class for recursive convolution with a kernel.
Definition: itkRecursiveSeparableImageFilter.h:52
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::RecursiveSeparableImageFilter::m_D2
ScalarRealType m_D2
Definition: itkRecursiveSeparableImageFilter.h:154
itk::RecursiveSeparableImageFilter::m_M2
ScalarRealType m_M2
Definition: itkRecursiveSeparableImageFilter.h:160
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::ImageToImageFilter::InputImagePointer
typename InputImageType::Pointer InputImagePointer
Definition: itkImageToImageFilter.h:130
itk::RecursiveSeparableImageFilter::m_BM3
ScalarRealType m_BM3
Definition: itkRecursiveSeparableImageFilter.h:173
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::VariableLengthVector
Represents an array whose length can be defined at run-time.
Definition: itkConstantBoundaryCondition.h:28
itk::NumericTraits
Define additional traits for native types such as int or float.
Definition: itkNumericTraits.h:58
itk::RecursiveSeparableImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkRecursiveSeparableImageFilter.h:75
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::RecursiveSeparableImageFilter::m_BN3
ScalarRealType m_BN3
Definition: itkRecursiveSeparableImageFilter.h:168
itk::RecursiveSeparableImageFilter::m_M1
ScalarRealType m_M1
Definition: itkRecursiveSeparableImageFilter.h:159
itk::RecursiveSeparableImageFilter::m_D3
ScalarRealType m_D3
Definition: itkRecursiveSeparableImageFilter.h:155
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::RecursiveSeparableImageFilter::MathSMAMAMAM
static void MathSMAMAMAM(VariableLengthVector< T1 > &out, const VariableLengthVector< T1 > &a1, const T2 &b1, const VariableLengthVector< T1 > &a2, const T2 &b2, const VariableLengthVector< T1 > &a3, const T2 &b3, const VariableLengthVector< T1 > &a4, const T2 &b4)
Definition: itkRecursiveSeparableImageFilter.h:233
itkInPlaceImageFilter.h
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::RecursiveSeparableImageFilter::m_BM1
ScalarRealType m_BM1
Definition: itkRecursiveSeparableImageFilter.h:171
itk::RecursiveSeparableImageFilter::m_BM4
ScalarRealType m_BM4
Definition: itkRecursiveSeparableImageFilter.h:174
itk::RecursiveSeparableImageFilter::m_D1
ScalarRealType m_D1
Definition: itkRecursiveSeparableImageFilter.h:153
itk::RecursiveSeparableImageFilter::MathSMAMAMAM
static void MathSMAMAMAM(T1 &out, const T1 &a1, const T2 &b1, const T1 &a2, const T2 &b2, const T1 &a3, const T2 &b3, const T1 &a4, const T2 &b4)
Definition: itkRecursiveSeparableImageFilter.h:218
itkNumericTraits.h
itk::RecursiveSeparableImageFilter::m_M4
ScalarRealType m_M4
Definition: itkRecursiveSeparableImageFilter.h:162
itk::RecursiveSeparableImageFilter::m_BN1
ScalarRealType m_BN1
Definition: itkRecursiveSeparableImageFilter.h:166
itk::RecursiveSeparableImageFilter::MathEMAMAMAM
static void MathEMAMAMAM(T1 &out, const T1 &a1, const T2 &b1, const T1 &a2, const T2 &b2, const T1 &a3, const T2 &b3, const T1 &a4, const T2 &b4)
Definition: itkRecursiveSeparableImageFilter.h:179
itk::ImageToImageFilter::InputImageConstPointer
typename InputImageType::ConstPointer InputImageConstPointer
Definition: itkImageToImageFilter.h:131
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::RecursiveSeparableImageFilter::RealType
typename NumericTraits< InputPixelType >::RealType RealType
Definition: itkRecursiveSeparableImageFilter.h:76
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::DataObject
Base class for all data objects in ITK.
Definition: itkDataObject.h:293
itk::RecursiveSeparableImageFilter::m_N2
ScalarRealType m_N2
Definition: itkRecursiveSeparableImageFilter.h:147