ITK  4.9.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 >
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:
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  RecursiveSeparableImageFilter(const Self &) ITK_DELETE_FUNCTION;
229  void operator=(const Self &) ITK_DELETE_FUNCTION;
230 
233  unsigned int m_Direction;
234 
236 };
237 } // end namespace itk
238 
239 #ifndef ITK_MANUAL_INSTANTIATION
240 #include "itkRecursiveSeparableImageFilter.hxx"
241 #endif
242 
243 #endif
Base class for recursive convolution with a kernel.
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId) override
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
void EnlargeOutputRequestedRegion(DataObject *output) override
void FilterDataArray(RealType *outs, const RealType *data, RealType *scratch, SizeValueType ln)
NumericTraits< InputPixelType >::ScalarRealType ScalarRealType
void BeforeThreadedGenerateData() override
void SetInputImage(const TInputImage *)
unsigned long SizeValueType
Definition: itkIntTypes.h:143
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.
virtual void SetUp(ScalarRealType spacing)=0
Divide an image region into several pieces.
InPlaceImageFilter< TInputImage, TOutputImage > Superclass
unsigned int ThreadIdType
Definition: itkIntTypes.h:159
ImageRegionSplitterDirection::Pointer m_ImageRegionSplitter
void PrintSelf(std::ostream &os, Indent indent) const override
const TInputImage * GetInputImage()
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.
unsigned int GetSize(void) const noexcept
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)
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...
virtual const ImageRegionSplitterBase * GetImageRegionSplitter(void) const override
Get the image splitter to split the image for multi-threading.
Base class for all data objects in ITK.