ITK  4.6.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"
23 
24 namespace itk
25 {
37 template< typename TInputImage, typename TOutputImage, typename TKernel /*=Neighborhood<bool,
38  TInputImage::ImageDimension>*/ >
40  public BoxImageFilter< TInputImage, TOutputImage >
41 {
42 public:
48 
50  itkNewMacro(Self);
51 
53  itkTypeMacro(KernelImageFilter,
55 
57  typedef TInputImage InputImageType;
58  typedef typename TInputImage::RegionType RegionType;
59  typedef typename TInputImage::SizeType SizeType;
60  typedef typename TInputImage::IndexType IndexType;
61  typedef typename TInputImage::OffsetType OffsetType;
62 
63  typedef typename TInputImage::PixelType InputPixelType;
64 
65  typedef TOutputImage OutputImageType;
66  typedef typename TOutputImage::PixelType OutputPixelType;
67 
68  typedef TKernel KernelType;
69 
71  itkStaticConstMacro(ImageDimension, unsigned int,
72  TInputImage::ImageDimension);
73 
77 
79  typedef typename TInputImage::SizeType RadiusType;
80 
82  virtual void SetKernel(const KernelType & kernel);
83 
84  itkGetConstReferenceMacro(Kernel, KernelType);
85 
87  virtual void SetRadius(const RadiusType & radius);
88 
89  virtual void SetRadius(const SizeValueType & radius)
90  {
91  // needed because of the overloading of the method
92  Superclass::SetRadius(radius);
93  }
94 
95 protected:
98 
99  void PrintSelf(std::ostream & os, Indent indent) const;
100 
103 
104 private:
105  KernelImageFilter(const Self &); //purposely not implemented
106  void operator=(const Self &); //purposely not implemented
107 
108  template<typename T> void MakeKernel( const RadiusType & radius, T & kernel )
109  {
110  kernel.SetRadius( radius );
111  for( typename T::Iterator kit=kernel.Begin(); kit != kernel.End(); kit++ )
112  {
113  *kit = 1;
114  }
115  }
116 
117  void MakeKernel( const RadiusType & radius, FlatKernelType & kernel )
118  {
119  // set up a decomposable box structuring element which is
120  // much efficient with van Herk / Gil Werman filters
121  kernel = FlatKernelType::Box( radius );
122  assert( kernel.GetDecomposable() );
123  }
124 };
125 }
126 
127 #ifndef ITK_MANUAL_INSTANTIATION
128 #include "itkKernelImageFilter.hxx"
129 #endif
130 
131 #endif
SmartPointer< Self > Pointer
SmartPointer< const Self > ConstPointer
virtual void SetRadius(const SizeValueType &radius)
void operator=(const Self &)
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
TOutputImage::PixelType OutputPixelType
virtual void SetKernel(const KernelType &kernel)
TInputImage::OffsetType OffsetType
TInputImage::IndexType IndexType
virtual void SetRadius(const RadiusType &radius)
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
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void PrintSelf(std::ostream &os, Indent indent) const
static const unsigned int ImageDimension
TInputImage::RegionType RegionType