ITK  5.3.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 {
48 template <typename TInputImage,
49  typename TOutputImage,
50  typename TAttribute = typename TInputImage::SpacingType::ValueType>
52  : public AttributeMorphologyBaseImageFilter<TInputImage,
53  TOutputImage,
54  TAttribute,
55  std::greater<typename TInputImage::PixelType>>
56 
57 {
58 public:
59  ITK_DISALLOW_COPY_AND_MOVE(AreaOpeningImageFilter);
60 
63  TOutputImage,
64  TAttribute,
65  std::greater<typename TInputImage::PixelType>>;
66 
69 
74  using OutputPixelType = typename TOutputImage::PixelType;
75  using OutputInternalPixelType = typename TOutputImage::InternalPixelType;
76  using InputPixelType = typename TInputImage::PixelType;
77  using InputInternalPixelType = typename TInputImage::InternalPixelType;
79  using OffsetType = typename TInputImage::OffsetType;
80  using SizeType = typename TInputImage::SizeType;
81  using AttributeType = TAttribute;
82 
83  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
84 
86  itkNewMacro(Self);
87 
90 
94  itkSetMacro(UseImageSpacing, bool);
95  itkGetConstReferenceMacro(UseImageSpacing, bool);
96  itkBooleanMacro(UseImageSpacing);
99 protected:
101 
102  ~AreaOpeningImageFilter() override = default;
103 
104  void
105  GenerateData() override
106  {
107  this->m_AttributeValuePerPixel = 1;
108  if (m_UseImageSpacing)
109  {
110  // compute pixel size
111  double psize = 1.0;
112  for (unsigned int i = 0; i < ImageDimension; ++i)
113  {
114  psize *= this->GetInput()->GetSpacing()[i];
115  }
116  this->m_AttributeValuePerPixel = static_cast<AttributeType>(psize);
117  // std::cout << "m_AttributeValuePerPixel: " <<
118  // this->m_AttributeValuePerPixel << std::endl;
119  // and call superclass implementation of GenerateData()
120  }
122  }
123 
124  void
125  PrintSelf(std::ostream & os, Indent indent) const override
126  {
127  Superclass::PrintSelf(os, indent);
128  os << indent << "UseImageSpacing: " << m_UseImageSpacing << std::endl;
129  }
130 
131 private:
133 };
134 } // namespace itk
135 #endif
itk::AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute, std::greater< TInputImage::PixelType > >::m_AttributeValuePerPixel
AttributeType m_AttributeValuePerPixel
Definition: itkAttributeMorphologyBaseImageFilter.h:162
itk::AreaOpeningImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkAreaOpeningImageFilter.h:74
itk::AreaOpeningImageFilter::AreaOpeningImageFilter
AreaOpeningImageFilter()
Definition: itkAreaOpeningImageFilter.h:100
itk::AreaOpeningImageFilter
Morphological opening by attributes.
Definition: itkAreaOpeningImageFilter.h:51
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:132
itk::AreaOpeningImageFilter::SizeType
typename TInputImage::SizeType SizeType
Definition: itkAreaOpeningImageFilter.h:80
itk::AttributeMorphologyBaseImageFilter
Morphological opening by attributes.
Definition: itkAttributeMorphologyBaseImageFilter.h:55
itk::AreaOpeningImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkAreaOpeningImageFilter.h:125
itk::ImageToImageFilter::GetInput
const InputImageType * GetInput() const
itk::AreaOpeningImageFilter::OffsetType
typename TInputImage::OffsetType OffsetType
Definition: itkAreaOpeningImageFilter.h:79
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:75
itk::AreaOpeningImageFilter::IndexType
typename TInputImage::IndexType IndexType
Definition: itkAreaOpeningImageFilter.h:78
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:81
itkAttributeMorphologyBaseImageFilter.h
itk::AttributeMorphologyBaseImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::AreaOpeningImageFilter::InputInternalPixelType
typename TInputImage::InternalPixelType InputInternalPixelType
Definition: itkAreaOpeningImageFilter.h:77
itk::AreaOpeningImageFilter::GenerateData
void GenerateData() override
Definition: itkAreaOpeningImageFilter.h:105
itk::AreaOpeningImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkAreaOpeningImageFilter.h:76
itk::AreaOpeningImageFilter::ImageDimension
static constexpr unsigned int ImageDimension
Definition: itkAreaOpeningImageFilter.h:83