ITK  4.4.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);
103 
104 protected:
106  {
107  m_UseImageSpacing = true;
108  }
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  AreaClosingImageFilter(const Self &); //purposely not implemented
140  void operator=(const Self &); //purposely not implemented
141 
143 };
144 } // namespace itk
145 #endif
146