ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkFastApproximateRankImageFilter.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 __itkFastApproximateRankImageFilter_h
19 #define __itkFastApproximateRankImageFilter_h
20 
22 #include "itkRankImageFilter.h"
23 
24 namespace itk
25 {
44 template< class TInputImage, class TOutputImage >
46  public MiniPipelineSeparableImageFilter< TInputImage, TOutputImage,
47  RankImageFilter< TInputImage, TInputImage,
48  FlatStructuringElement< ::itk::GetImageDimension<
49  TInputImage >::ImageDimension > > >
50 {
51 public:
54  typedef MiniPipelineSeparableImageFilter< TInputImage, TOutputImage, RankImageFilter< TInputImage, TInputImage,
57  <
58  TInputImage >::ImageDimension > > > Superclass;
59 
62 
64  itkNewMacro(Self);
65 
68 
70  typedef TInputImage InputImageType;
71  typedef typename TInputImage::RegionType RegionType;
72  typedef typename TInputImage::SizeType SizeType;
73  typedef typename TInputImage::IndexType IndexType;
74  typedef typename TInputImage::PixelType PixelType;
75  typedef typename TInputImage::OffsetType OffsetType;
76  typedef typename Superclass::FilterType FilterType;
77 
79  itkStaticConstMacro(ImageDimension, unsigned int,
80  TInputImage::ImageDimension);
81 
83  typedef typename TInputImage::SizeType RadiusType;
84 
85  void SetRank(float rank)
86  {
87  if ( m_Rank != rank )
88  {
89  m_Rank = rank;
90  for ( unsigned i = 0; i < TInputImage::ImageDimension - 1; i++ )
91  {
92  this->m_Filters[i]->SetRank(m_Rank);
93  }
94  this->Modified();
95  }
96  }
97 
98  itkGetConstMacro(Rank, float);
99 protected:
101  {
102  // to avoid valgrind warning
103  m_Rank = 0.0;
104  this->SetRank(0.5);
105  }
106 
108 
109  void PrintSelf(std::ostream & os, Indent indent) const
110  {
111  Superclass::PrintSelf(os, indent);
112  os << indent << "Rank: " << m_Rank << std::endl;
113  }
114 
115 private:
116  FastApproximateRankImageFilter(const Self &); //purposely not implemented
117  void operator=(const Self &); //purposely not implemented
118 
119  float m_Rank;
120 };
121 }
122 
123 #endif
124