ITK  5.4.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 * https://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
22#include "itkNumericTraits.h"
24
25namespace itk
26{
51template <typename TInputImage, typename TOutputImage = TInputImage>
52class ITK_TEMPLATE_EXPORT RecursiveSeparableImageFilter : public InPlaceImageFilter<TInputImage, TOutputImage>
53{
54public:
55 ITK_DISALLOW_COPY_AND_MOVE(RecursiveSeparableImageFilter);
56
62
64 itkOverrideGetNameOfClassMacro(RecursiveSeparableImageFilter);
65
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 *
100
101protected:
103 ~RecursiveSeparableImageFilter() override = default;
104 void
105 PrintSelf(std::ostream & os, Indent indent) const override;
106
107 void
109
110 void
111 GenerateData() override;
112
113 void
115
124 void
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
143protected:
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
254private:
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
Base class for all data objects in ITK.
Base class for filters that take an image as input and overwrite that image as the output.
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
Define additional traits for native types such as int or float.
Base class for recursive convolution with a kernel.
typename NumericTraits< InputPixelType >::ScalarRealType ScalarRealType
typename TInputImage::ConstPointer InputImageConstPointer
void EnlargeOutputRequestedRegion(DataObject *output) override
void BeforeThreadedGenerateData() override
void DynamicThreadedGenerateData(const OutputImageRegionType &) override
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)
void SetInputImage(const TInputImage *)
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)
virtual void SetUp(ScalarRealType spacing)=0
typename NumericTraits< InputPixelType >::RealType RealType
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)
void FilterDataArray(RealType *outs, const RealType *data, RealType *scratch, SizeValueType ln) const
typename TOutputImage::RegionType OutputImageRegionType
void PrintSelf(std::ostream &os, Indent indent) const override
~RecursiveSeparableImageFilter() override=default
const TInputImage * GetInputImage()
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)
typename TInputImage::PixelType InputPixelType
SmartPointer< const Self > ConstPointer
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:83