ITK  6.0.0
Insight Toolkit
itkAreaClosingImageFilter.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 itkAreaClosingImageFilter_h
19 #define itkAreaClosingImageFilter_h
20 
22 
23 namespace itk
24 {
45 template <typename TInputImage,
46  typename TOutputImage,
47  typename TAttribute = typename TInputImage::SpacingType::ValueType>
49  : public AttributeMorphologyBaseImageFilter<TInputImage,
50  TOutputImage,
51  TAttribute,
52  std::less<typename TInputImage::PixelType>>
53 
54 {
55 public:
56  ITK_DISALLOW_COPY_AND_MOVE(AreaClosingImageFilter);
57 
60  TOutputImage,
61  TAttribute,
62  std::less<typename TInputImage::PixelType>>;
63 
66 
71  using OutputPixelType = typename TOutputImage::PixelType;
72  using OutputInternalPixelType = typename TOutputImage::InternalPixelType;
73  using InputPixelType = typename TInputImage::PixelType;
74  using InputInternalPixelType = typename TInputImage::InternalPixelType;
76  using OffsetType = typename TInputImage::OffsetType;
77  using SizeType = typename TInputImage::SizeType;
78  using AttributeType = TAttribute;
79 
80  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
81 
83  itkNewMacro(Self);
84 
86  itkOverrideGetNameOfClassMacro(AreaClosingImageFilter);
87 
91  itkSetMacro(UseImageSpacing, bool);
92  itkGetConstReferenceMacro(UseImageSpacing, bool);
93  itkBooleanMacro(UseImageSpacing);
96 protected:
98 
99  ~AreaClosingImageFilter() override = default;
100 
101  void
102  GenerateData() override
103  {
104  this->m_AttributeValuePerPixel = 1;
105  if (m_UseImageSpacing)
106  {
107  const auto & spacing = this->GetInput()->GetSpacing();
108 
109  // compute pixel size
110  double psize = 1.0;
111  for (unsigned int i = 0; i < ImageDimension; ++i)
112  {
113  psize *= spacing[i];
114  }
115  this->m_AttributeValuePerPixel = static_cast<AttributeType>(psize);
116  // std::cout << "m_AttributeValuePerPixel: " <<
117  // this->m_AttributeValuePerPixel << std::endl;
118  // and call superclass implementation of GenerateData()
119  }
121  }
122 
123  void
124  PrintSelf(std::ostream & os, Indent indent) const override
125  {
126  Superclass::PrintSelf(os, indent);
127  itkPrintSelfBooleanMacro(UseImageSpacing);
128  }
129 
130 private:
132 };
133 } // namespace itk
134 #endif
itk::AreaClosingImageFilter::OffsetType
typename TInputImage::OffsetType OffsetType
Definition: itkAreaClosingImageFilter.h:76
itk::AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute, std::less< TInputImage::PixelType > >::m_AttributeValuePerPixel
AttributeType m_AttributeValuePerPixel
Definition: itkAttributeMorphologyBaseImageFilter.h:161
itk::AreaClosingImageFilter::AttributeType
TAttribute AttributeType
Definition: itkAreaClosingImageFilter.h:78
itk::AreaClosingImageFilter::InputInternalPixelType
typename TInputImage::InternalPixelType InputInternalPixelType
Definition: itkAreaClosingImageFilter.h:74
itk::AreaClosingImageFilter::IndexType
typename TInputImage::IndexType IndexType
Definition: itkAreaClosingImageFilter.h:75
itk::AreaClosingImageFilter::SizeType
typename TInputImage::SizeType SizeType
Definition: itkAreaClosingImageFilter.h:77
itk::AttributeMorphologyBaseImageFilter::GenerateData
void GenerateData() override
itk::AreaClosingImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkAreaClosingImageFilter.h:71
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::AreaClosingImageFilter::OutputInternalPixelType
typename TOutputImage::InternalPixelType OutputInternalPixelType
Definition: itkAreaClosingImageFilter.h:72
itk::AreaClosingImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkAreaClosingImageFilter.h:73
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::AreaClosingImageFilter::AreaClosingImageFilter
AreaClosingImageFilter()
Definition: itkAreaClosingImageFilter.h:97
itk::AttributeMorphologyBaseImageFilter
Morphological opening by attributes.
Definition: itkAttributeMorphologyBaseImageFilter.h:54
itk::ImageToImageFilter::GetInput
const InputImageType * GetInput() const
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::AreaClosingImageFilter::GenerateData
void GenerateData() override
Definition: itkAreaClosingImageFilter.h:102
itk::AreaClosingImageFilter
Morphological closing by attributes.
Definition: itkAreaClosingImageFilter.h:48
itk::AreaClosingImageFilter::ImageDimension
static constexpr unsigned int ImageDimension
Definition: itkAreaClosingImageFilter.h:80
itkAttributeMorphologyBaseImageFilter.h
itk::AttributeMorphologyBaseImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::AreaClosingImageFilter::~AreaClosingImageFilter
~AreaClosingImageFilter() override=default
itk::AreaClosingImageFilter::m_UseImageSpacing
bool m_UseImageSpacing
Definition: itkAreaClosingImageFilter.h:131
itk::AreaClosingImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkAreaClosingImageFilter.h:124