ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkKernelImageFilter.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 itkKernelImageFilter_h
19 #define itkKernelImageFilter_h
20 
21 #include "itkBoxImageFilter.h"
22 
23 namespace itk
24 {
25 
26 template< unsigned int VDimension > class FlatStructuringElement;
38 template< typename TInputImage, typename TOutputImage, typename TKernel /*=Neighborhood<bool,
39  TInputImage::ImageDimension>*/ >
41  public BoxImageFilter< TInputImage, TOutputImage >
42 {
43 public:
49 
51  itkNewMacro(Self);
52 
54  itkTypeMacro(KernelImageFilter,
56 
58  typedef TInputImage InputImageType;
59  typedef typename TInputImage::RegionType RegionType;
60  typedef typename TInputImage::SizeType SizeType;
61  typedef typename TInputImage::IndexType IndexType;
62  typedef typename TInputImage::OffsetType OffsetType;
63 
64  typedef typename TInputImage::PixelType InputPixelType;
65 
66  typedef TOutputImage OutputImageType;
67  typedef typename TOutputImage::PixelType OutputPixelType;
68 
69  typedef TKernel KernelType;
70 
72  itkStaticConstMacro(ImageDimension, unsigned int,
73  TInputImage::ImageDimension);
74 
78 
80  typedef typename TInputImage::SizeType RadiusType;
81 
83  virtual void SetKernel(const KernelType & kernel);
84 
85  itkGetConstReferenceMacro(Kernel, KernelType);
86 
88  virtual void SetRadius(const RadiusType & radius) ITK_OVERRIDE;
89 
90  virtual void SetRadius(const SizeValueType & radius) ITK_OVERRIDE
91  {
92  // needed because of the overloading of the method
93  Superclass::SetRadius(radius);
94  }
95 
96 protected:
99 
100  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
101 
104 
105 private:
106  KernelImageFilter(const Self &) ITK_DELETE_FUNCTION;
107  void operator=(const Self &) ITK_DELETE_FUNCTION;
108 
109  template<typename T> void MakeKernel( const RadiusType & radius, T & kernel )
110  {
111  kernel.SetRadius( radius );
112  for( typename T::Iterator kit=kernel.Begin(); kit != kernel.End(); kit++ )
113  {
114  *kit = 1;
115  }
116  }
117 
118  void MakeKernel( const RadiusType & radius, FlatKernelType & kernel )
119  {
120  // set up a decomposable box structuring element which is
121  // much efficient with van Herk / Gil Werman filters
122  kernel = FlatKernelType::Box( radius );
123  assert( kernel.GetDecomposable() );
124  }
125 };
126 }
127 
128 #ifndef ITK_MANUAL_INSTANTIATION
129 #include "itkKernelImageFilter.hxx"
130 #endif
131 
132 #endif
SmartPointer< Self > Pointer
SmartPointer< const Self > ConstPointer
void MakeKernel(const RadiusType &radius, FlatKernelType &kernel)
TInputImage::PixelType InputPixelType
void MakeKernel(const RadiusType &radius, T &kernel)
BoxImageFilter< TInputImage, TOutputImage > Superclass
FlatStructuringElement< itkGetStaticConstMacro(ImageDimension) > FlatKernelType
TInputImage::SizeType RadiusType
Base class for all process objects that output image data.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
virtual void SetRadius(const SizeValueType &radius) override
TOutputImage::PixelType OutputPixelType
virtual void SetKernel(const KernelType &kernel)
TInputImage::OffsetType OffsetType
TInputImage::IndexType IndexType
virtual void SetRadius(const RadiusType &radius)
A base class for all the filters working on an arbitrary shaped neighborhood.
A base class for all the filters working on a box neighborhood.
A class to support a variety of flat structuring elements, including versions created by decompositio...
static Self Box(RadiusType radius)
TInputImage::SizeType RadiusType
TInputImage::SizeType SizeType
void PrintSelf(std::ostream &os, Indent indent) const override
Control indentation during Print() invocation.
Definition: itkIndent.h:49
static const unsigned int ImageDimension
TInputImage::RegionType RegionType
virtual void SetRadius(const RadiusType &radius) override