ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkRecursiveSeparableImageFilter.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 itkRecursiveSeparableImageFilter_h
19 #define itkRecursiveSeparableImageFilter_h
20 
21 #include "itkInPlaceImageFilter.h"
22 #include "itkNumericTraits.h"
25 
26 namespace itk
27 {
51 template< typename TInputImage, typename TOutputImage = TInputImage >
52 class ITK_TEMPLATE_EXPORT RecursiveSeparableImageFilter:
53  public InPlaceImageFilter< TInputImage, TOutputImage >
54 {
55 public:
61 
64 
66  typedef typename TInputImage::Pointer InputImagePointer;
67  typedef typename TInputImage::ConstPointer InputImageConstPointer;
68 
74  typedef typename TInputImage::PixelType InputPixelType;
77 
78  typedef typename TOutputImage::RegionType OutputImageRegionType;
79 
81  typedef TInputImage InputImageType;
82 
84  typedef TOutputImage OutputImageType;
85 
87  itkGetConstMacro(Direction, unsigned int);
88 
90  itkSetMacro(Direction, unsigned int);
91 
93  void SetInputImage(const TInputImage *);
94 
96  const TInputImage * GetInputImage();
97 
98 protected:
100  virtual ~RecursiveSeparableImageFilter() ITK_OVERRIDE {}
101  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
102 
104  void BeforeThreadedGenerateData() ITK_OVERRIDE;
105 
106  void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId) ITK_OVERRIDE;
107 
108 
109  virtual const ImageRegionSplitterBase* GetImageRegionSplitter(void) const ITK_OVERRIDE;
110 
119  void EnlargeOutputRequestedRegion(DataObject *output) ITK_OVERRIDE;
120 
125  virtual void SetUp(ScalarRealType spacing) = 0;
126 
133  void FilterDataArray(RealType *outs, const RealType *data, RealType *scratch,
134  SizeValueType ln);
135 
136 protected:
142 
150 
156 
163 
168 
169 
170  template <typename T1, typename T2>
171  inline void MathEMAMAMAM(T1 &out,
172  const T1 &a1, const T2 &b1,
173  const T1 &a2, const T2 &b2,
174  const T1 &a3, const T2 &b3,
175  const T1 &a4, const T2 &b4 )
176  {
177  out = a1*b1 + a2*b2 + a3*b3 + a4*b4;
178  }
179 
180 
181  template <typename T1, typename T2>
183  const VariableLengthVector<T1> &a1, const T2 &b1,
184  const VariableLengthVector<T1> &a2, const T2 &b2,
185  const VariableLengthVector<T1> &a3, const T2 &b3,
186  const VariableLengthVector<T1> &a4, const T2 &b4 )
187  {
188  const unsigned int sz = a1.GetSize();
189  if (sz != out.GetSize() )
190  {
191  out.SetSize(sz);
192  }
193  for ( unsigned int i = 0; i < sz; ++i)
194  {
195  out[i] = a1[i]*b1 + a2[i]*b2 + a3[i]*b3 + a4[i]*b4;
196  }
197  }
198 
199  template <typename T1, typename T2>
200  inline void MathSMAMAMAM(T1 &out,
201  const T1 &a1, const T2 &b1,
202  const T1 &a2, const T2 &b2,
203  const T1 &a3, const T2 &b3,
204  const T1 &a4, const T2 &b4 )
205  {
206  out -= a1*b1 + a2*b2 + a3*b3 + a4*b4;
207  }
208 
209  template <typename T1, typename T2>
211  const VariableLengthVector<T1> &a1, const T2 &b1,
212  const VariableLengthVector<T1> &a2, const T2 &b2,
213  const VariableLengthVector<T1> &a3, const T2 &b3,
214  const VariableLengthVector<T1> &a4, const T2 &b4 )
215  {
216  const unsigned int sz = a1.GetSize();
217  if (sz != out.GetSize() )
218  {
219  out.SetSize(sz);
220  }
221  for ( unsigned int i = 0; i < sz; ++i)
222  {
223  out[i] -= a1[i]*b1 + a2[i]*b2 + a3[i]*b3 + a4[i]*b4;
224  }
225  }
226 
227 private:
228  ITK_DISALLOW_COPY_AND_ASSIGN(RecursiveSeparableImageFilter);
229 
232  unsigned int m_Direction;
233 
235 };
236 } // end namespace itk
237 
238 #ifndef ITK_MANUAL_INSTANTIATION
239 #include "itkRecursiveSeparableImageFilter.hxx"
240 #endif
241 
242 #endif
Base class for recursive convolution with a kernel.
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)
NumericTraits< InputPixelType >::RealType RealType
NumericTraits< InputPixelType >::ScalarRealType ScalarRealType
unsigned long SizeValueType
Definition: itkIntTypes.h:143
unsigned int GetSize(void) const
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)
Represents an array whose length can be defined at run-time.
Divide an image region into several pieces.
InPlaceImageFilter< TInputImage, TOutputImage > Superclass
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
ImageRegionSplitterDirection::Pointer m_ImageRegionSplitter
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)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Define additional traits for native types such as int or float.
void SetSize(unsigned int sz, TReallocatePolicy reallocatePolicy, TKeepValuesPolicy keepValues)
Base class for filters that take an image as input and overwrite that image as the output...
Base class for all data objects in ITK.