ITK  5.4.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  * https://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 {
47 template <typename TInputImage,
48  typename TOutputImage,
49  typename TAttribute = typename TInputImage::SpacingType::ValueType>
51  : public AttributeMorphologyBaseImageFilter<TInputImage,
52  TOutputImage,
53  TAttribute,
54  std::greater<typename TInputImage::PixelType>>
55 
56 {
57 public:
58  ITK_DISALLOW_COPY_AND_MOVE(AreaOpeningImageFilter);
59 
62  TOutputImage,
63  TAttribute,
64  std::greater<typename TInputImage::PixelType>>;
65 
68 
73  using OutputPixelType = typename TOutputImage::PixelType;
74  using OutputInternalPixelType = typename TOutputImage::InternalPixelType;
75  using InputPixelType = typename TInputImage::PixelType;
76  using InputInternalPixelType = typename TInputImage::InternalPixelType;
78  using OffsetType = typename TInputImage::OffsetType;
79  using SizeType = typename TInputImage::SizeType;
80  using AttributeType = TAttribute;
81 
82  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
83 
85  itkNewMacro(Self);
86 
88  itkOverrideGetNameOfClassMacro(AreaOpeningImageFilter);
89 
93  itkSetMacro(UseImageSpacing, bool);
94  itkGetConstReferenceMacro(UseImageSpacing, bool);
95  itkBooleanMacro(UseImageSpacing);
98 protected:
100 
101  ~AreaOpeningImageFilter() override = default;
102 
103  void
104  GenerateData() override
105  {
106  this->m_AttributeValuePerPixel = 1;
107  if (m_UseImageSpacing)
108  {
109  const auto & spacing = this->GetInput()->GetSpacing();
110 
111  // compute pixel size
112  double psize = 1.0;
113  for (unsigned int i = 0; i < ImageDimension; ++i)
114  {
115  psize *= spacing[i];
116  }
117  this->m_AttributeValuePerPixel = static_cast<AttributeType>(psize);
118  // std::cout << "m_AttributeValuePerPixel: " <<
119  // this->m_AttributeValuePerPixel << std::endl;
120  // and call superclass implementation of GenerateData()
121  }
123  }
124 
125  void
126  PrintSelf(std::ostream & os, Indent indent) const override
127  {
128  Superclass::PrintSelf(os, indent);
129  os << indent << "UseImageSpacing: " << (m_UseImageSpacing ? "On" : "Off") << std::endl;
130  }
131 
132 private:
134 };
135 } // namespace itk
136 #endif
itk::AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute, std::greater< TInputImage::PixelType > >::m_AttributeValuePerPixel
AttributeType m_AttributeValuePerPixel
Definition: itkAttributeMorphologyBaseImageFilter.h:161
itk::AreaOpeningImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkAreaOpeningImageFilter.h:73
itk::AreaOpeningImageFilter::AreaOpeningImageFilter
AreaOpeningImageFilter()
Definition: itkAreaOpeningImageFilter.h:99
itk::AreaOpeningImageFilter
Morphological opening by attributes.
Definition: itkAreaOpeningImageFilter.h:50
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:133
itk::AreaOpeningImageFilter::SizeType
typename TInputImage::SizeType SizeType
Definition: itkAreaOpeningImageFilter.h:79
itk::AttributeMorphologyBaseImageFilter
Morphological opening by attributes.
Definition: itkAttributeMorphologyBaseImageFilter.h:54
itk::AreaOpeningImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkAreaOpeningImageFilter.h:126
itk::ImageToImageFilter::GetInput
const InputImageType * GetInput() const
itk::AreaOpeningImageFilter::OffsetType
typename TInputImage::OffsetType OffsetType
Definition: itkAreaOpeningImageFilter.h:78
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:74
itk::AreaOpeningImageFilter::IndexType
typename TInputImage::IndexType IndexType
Definition: itkAreaOpeningImageFilter.h:77
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::AreaOpeningImageFilter::~AreaOpeningImageFilter
~AreaOpeningImageFilter() override=default
itk::AreaOpeningImageFilter::AttributeType
TAttribute AttributeType
Definition: itkAreaOpeningImageFilter.h:80
itkAttributeMorphologyBaseImageFilter.h
itk::AttributeMorphologyBaseImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::AreaOpeningImageFilter::InputInternalPixelType
typename TInputImage::InternalPixelType InputInternalPixelType
Definition: itkAreaOpeningImageFilter.h:76
itk::AreaOpeningImageFilter::GenerateData
void GenerateData() override
Definition: itkAreaOpeningImageFilter.h:104
itk::AreaOpeningImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkAreaOpeningImageFilter.h:75
itk::AreaOpeningImageFilter::ImageDimension
static constexpr unsigned int ImageDimension
Definition: itkAreaOpeningImageFilter.h:82