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