ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkAreaOpeningImageFilter.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 __itkAreaOpeningImageFilter_h
19 #define __itkAreaOpeningImageFilter_h
20 
22 
23 namespace itk
24 {
59 template< class TInputImage, class TOutputImage, class TAttribute = typename TInputImage::SpacingType::ValueType >
60 class ITK_EXPORT AreaOpeningImageFilter:
61  public AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute,
62  std::greater< typename TInputImage::PixelType > >
63 
64 {
65 public:
67  typedef AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute,
68  std::greater< typename TInputImage::PixelType > >
70 
73 
78  typedef typename TOutputImage::PixelType OutputPixelType;
79  typedef typename TOutputImage::InternalPixelType OutputInternalPixelType;
80  typedef typename TInputImage::PixelType InputPixelType;
81  typedef typename TInputImage::InternalPixelType InputInternalPixelType;
82  typedef typename TInputImage::IndexType IndexType;
83  typedef typename TInputImage::OffsetType OffsetType;
84  typedef typename TInputImage::SizeType SizeType;
85  typedef TAttribute AttributeType;
86 
87  itkStaticConstMacro(ImageDimension, unsigned int,
88  TOutputImage::ImageDimension);
89 
91  itkNewMacro(Self);
92 
94  itkTypeMacro(AreaOpeningImageFilter,
96 
100  itkSetMacro(UseImageSpacing, bool);
101  itkGetConstReferenceMacro(UseImageSpacing, bool);
102  itkBooleanMacro(UseImageSpacing);
103 protected:
105  {
106  m_UseImageSpacing = true;
107  }
109 
111 
112  void GenerateData()
113  {
114  this->m_AttributeValuePerPixel = 1;
115  if ( m_UseImageSpacing )
116  {
117  // compute pixel size
118  double psize = 1.0;
119  for ( unsigned i = 0; i < ImageDimension; i++ )
120  {
121  psize *= this->GetInput()->GetSpacing()[i];
122  }
123  this->m_AttributeValuePerPixel = static_cast< AttributeType >( psize );
124  // std::cout << "m_AttributeValuePerPixel: " <<
125  // this->m_AttributeValuePerPixel << std::endl;
126  // and call superclass implementation of GenerateData()
127  }
128  Superclass::GenerateData();
129  }
130 
131  void PrintSelf(std::ostream & os, Indent indent) const
132  {
133  Superclass::PrintSelf(os, indent);
134  os << indent << "UseImageSpacing: " << m_UseImageSpacing << std::endl;
135  }
136 
137 private:
138 
139  AreaOpeningImageFilter(const Self &); //purposely not implemented
140  void operator=(const Self &); //purposely not implemented
141 
143 };
144 } // namespace itk
145 #endif
146