ITK  5.2.0
Insight Toolkit
itkAreaOpeningImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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,
61  typename TOutputImage,
62  typename TAttribute = typename TInputImage::SpacingType::ValueType>
64  : public AttributeMorphologyBaseImageFilter<TInputImage,
65  TOutputImage,
66  TAttribute,
67  std::greater<typename TInputImage::PixelType>>
68 
69 {
70 public:
71  ITK_DISALLOW_COPY_AND_MOVE(AreaOpeningImageFilter);
72 
75  TOutputImage,
76  TAttribute,
77  std::greater<typename TInputImage::PixelType>>;
78 
81 
86  using OutputPixelType = typename TOutputImage::PixelType;
87  using OutputInternalPixelType = typename TOutputImage::InternalPixelType;
88  using InputPixelType = typename TInputImage::PixelType;
89  using InputInternalPixelType = typename TInputImage::InternalPixelType;
91  using OffsetType = typename TInputImage::OffsetType;
92  using SizeType = typename TInputImage::SizeType;
93  using AttributeType = TAttribute;
94 
95  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
96 
98  itkNewMacro(Self);
99 
102 
106  itkSetMacro(UseImageSpacing, bool);
107  itkGetConstReferenceMacro(UseImageSpacing, bool);
108  itkBooleanMacro(UseImageSpacing);
110 
111 protected:
113 
114  ~AreaOpeningImageFilter() override = default;
115 
116  void
117  GenerateData() override
118  {
119  this->m_AttributeValuePerPixel = 1;
120  if (m_UseImageSpacing)
121  {
122  // compute pixel size
123  double psize = 1.0;
124  for (unsigned i = 0; i < ImageDimension; i++)
125  {
126  psize *= this->GetInput()->GetSpacing()[i];
127  }
128  this->m_AttributeValuePerPixel = static_cast<AttributeType>(psize);
129  // std::cout << "m_AttributeValuePerPixel: " <<
130  // this->m_AttributeValuePerPixel << std::endl;
131  // and call superclass implementation of GenerateData()
132  }
134  }
135 
136  void
137  PrintSelf(std::ostream & os, Indent indent) const override
138  {
139  Superclass::PrintSelf(os, indent);
140  os << indent << "UseImageSpacing: " << m_UseImageSpacing << std::endl;
141  }
142 
143 private:
145 };
146 } // namespace itk
147 #endif
itk::AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute, std::greater< TInputImage::PixelType > >::m_AttributeValuePerPixel
AttributeType m_AttributeValuePerPixel
Definition: itkAttributeMorphologyBaseImageFilter.h:170
itk::AreaOpeningImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkAreaOpeningImageFilter.h:86
itk::AreaOpeningImageFilter::AreaOpeningImageFilter
AreaOpeningImageFilter()
Definition: itkAreaOpeningImageFilter.h:112
itk::AreaOpeningImageFilter
Morphological opening by attributes.
Definition: itkAreaOpeningImageFilter.h:63
itk::AttributeMorphologyBaseImageFilter::GenerateData
void GenerateData() override
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::AreaOpeningImageFilter::m_UseImageSpacing
bool m_UseImageSpacing
Definition: itkAreaOpeningImageFilter.h:144
itk::AreaOpeningImageFilter::SizeType
typename TInputImage::SizeType SizeType
Definition: itkAreaOpeningImageFilter.h:92
itk::AttributeMorphologyBaseImageFilter
Morphological opening by attributes.
Definition: itkAttributeMorphologyBaseImageFilter.h:63
itk::AreaOpeningImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkAreaOpeningImageFilter.h:137
itk::ImageToImageFilter::GetInput
const InputImageType * GetInput() const
itk::AreaOpeningImageFilter::OffsetType
typename TInputImage::OffsetType OffsetType
Definition: itkAreaOpeningImageFilter.h:91
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::AreaOpeningImageFilter::OutputInternalPixelType
typename TOutputImage::InternalPixelType OutputInternalPixelType
Definition: itkAreaOpeningImageFilter.h:87
itk::AreaOpeningImageFilter::IndexType
typename TInputImage::IndexType IndexType
Definition: itkAreaOpeningImageFilter.h:90
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::AreaOpeningImageFilter::~AreaOpeningImageFilter
~AreaOpeningImageFilter() override=default
itk::AreaOpeningImageFilter::AttributeType
TAttribute AttributeType
Definition: itkAreaOpeningImageFilter.h:93
itkAttributeMorphologyBaseImageFilter.h
itk::AttributeMorphologyBaseImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::AreaOpeningImageFilter::InputInternalPixelType
typename TInputImage::InternalPixelType InputInternalPixelType
Definition: itkAreaOpeningImageFilter.h:89
itk::AreaOpeningImageFilter::GenerateData
void GenerateData() override
Definition: itkAreaOpeningImageFilter.h:117
itk::AreaOpeningImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkAreaOpeningImageFilter.h:88
itk::AreaOpeningImageFilter::ImageDimension
static constexpr unsigned int ImageDimension
Definition: itkAreaOpeningImageFilter.h:95