ITK  5.0.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:
67  ITK_DISALLOW_COPY_AND_ASSIGN(AreaOpeningImageFilter);
68 
70  using Superclass = AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute,
71  std::greater< typename TInputImage::PixelType > >;
72 
75 
80  using OutputPixelType = typename TOutputImage::PixelType;
81  using OutputInternalPixelType = typename TOutputImage::InternalPixelType;
82  using InputPixelType = typename TInputImage::PixelType;
83  using InputInternalPixelType = typename TInputImage::InternalPixelType;
85  using OffsetType = typename TInputImage::OffsetType;
86  using SizeType = typename TInputImage::SizeType;
87  using AttributeType = TAttribute;
88 
89  static constexpr unsigned int ImageDimension = 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() 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 override
134  {
135  Superclass::PrintSelf(os, indent);
136  os << indent << "UseImageSpacing: " << m_UseImageSpacing << std::endl;
137  }
138 
139 private:
140 
142 };
143 } // namespace itk
144 #endif
typename TOutputImage::PixelType OutputPixelType
void PrintSelf(std::ostream &os, Indent indent) const override
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
typename TInputImage::InternalPixelType InputInternalPixelType
static constexpr unsigned int ImageDimension
typename TOutputImage::InternalPixelType OutputInternalPixelType
const InputImageType * GetInput() const
void PrintSelf(std::ostream &os, Indent indent) const override
Morphological opening by attributes.
typename TInputImage::OffsetType OffsetType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename TInputImage::PixelType InputPixelType
typename TInputImage::SizeType SizeType
typename TInputImage::IndexType IndexType