ITK  4.9.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 #include <functional>
23 
24 namespace itk
25 {
60 template< typename TInputImage, typename TOutputImage, typename TAttribute = typename TInputImage::SpacingType::ValueType >
62  public AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute,
63  std::greater< typename TInputImage::PixelType > >
64 
65 {
66 public:
68  typedef AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute,
69  std::greater< typename TInputImage::PixelType > >
71 
74 
79  typedef typename TOutputImage::PixelType OutputPixelType;
80  typedef typename TOutputImage::InternalPixelType OutputInternalPixelType;
81  typedef typename TInputImage::PixelType InputPixelType;
82  typedef typename TInputImage::InternalPixelType InputInternalPixelType;
83  typedef typename TInputImage::IndexType IndexType;
84  typedef typename TInputImage::OffsetType OffsetType;
85  typedef typename TInputImage::SizeType SizeType;
86  typedef TAttribute AttributeType;
87 
88  itkStaticConstMacro(ImageDimension, unsigned int,
89  TOutputImage::ImageDimension);
90 
92  itkNewMacro(Self);
93 
95  itkTypeMacro(AreaOpeningImageFilter,
97 
101  itkSetMacro(UseImageSpacing, bool);
102  itkGetConstReferenceMacro(UseImageSpacing, bool);
103  itkBooleanMacro(UseImageSpacing);
105 
106 protected:
108  {
109  m_UseImageSpacing = true;
110  }
111 
113 
114  void GenerateData() ITK_OVERRIDE
115  {
116  this->m_AttributeValuePerPixel = 1;
117  if ( m_UseImageSpacing )
118  {
119  // compute pixel size
120  double psize = 1.0;
121  for ( unsigned i = 0; i < ImageDimension; i++ )
122  {
123  psize *= this->GetInput()->GetSpacing()[i];
124  }
125  this->m_AttributeValuePerPixel = static_cast< AttributeType >( psize );
126  // std::cout << "m_AttributeValuePerPixel: " <<
127  // this->m_AttributeValuePerPixel << std::endl;
128  // and call superclass implementation of GenerateData()
129  }
131  }
132 
133  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE
134  {
135  Superclass::PrintSelf(os, indent);
136  os << indent << "UseImageSpacing: " << m_UseImageSpacing << std::endl;
137  }
138 
139 private:
140 
141  AreaOpeningImageFilter(const Self &) ITK_DELETE_FUNCTION;
142  void operator=(const Self &) ITK_DELETE_FUNCTION;
143 
145 };
146 } // namespace itk
147 #endif
AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute, std::greater< typename TInputImage::PixelType > > Superclass
void PrintSelf(std::ostream &os, Indent indent) const override
static const unsigned int ImageDimension
TInputImage::PixelType InputPixelType
Base class for all process objects that output image data.
TOutputImage::PixelType OutputPixelType
TOutputImage::InternalPixelType OutputInternalPixelType
TInputImage::OffsetType OffsetType
TInputImage::InternalPixelType InputInternalPixelType
const InputImageType * GetInput() const
void PrintSelf(std::ostream &os, Indent indent) const override
Morphological opening by attributes.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
SmartPointer< const Self > ConstPointer