ITK  5.2.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  * 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 itkAreaClosingImageFilter_h
19 #define itkAreaClosingImageFilter_h
20 
22 
23 namespace itk
24 {
58 template <typename TInputImage,
59  typename TOutputImage,
60  typename TAttribute = typename TInputImage::SpacingType::ValueType>
62  : public AttributeMorphologyBaseImageFilter<TInputImage,
63  TOutputImage,
64  TAttribute,
65  std::less<typename TInputImage::PixelType>>
66 
67 {
68 public:
69  ITK_DISALLOW_COPY_AND_MOVE(AreaClosingImageFilter);
70 
73  TOutputImage,
74  TAttribute,
75  std::less<typename TInputImage::PixelType>>;
76 
79 
84  using OutputPixelType = typename TOutputImage::PixelType;
85  using OutputInternalPixelType = typename TOutputImage::InternalPixelType;
86  using InputPixelType = typename TInputImage::PixelType;
87  using InputInternalPixelType = typename TInputImage::InternalPixelType;
89  using OffsetType = typename TInputImage::OffsetType;
90  using SizeType = typename TInputImage::SizeType;
91  using AttributeType = TAttribute;
92 
93  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
94 
96  itkNewMacro(Self);
97 
100 
104  itkSetMacro(UseImageSpacing, bool);
105  itkGetConstReferenceMacro(UseImageSpacing, bool);
106  itkBooleanMacro(UseImageSpacing);
108 
109 protected:
111 
112  ~AreaClosingImageFilter() override = default;
113 
114  void
115  GenerateData() override
116  {
117  this->m_AttributeValuePerPixel = 1;
118  if (m_UseImageSpacing)
119  {
120  // compute pixel size
121  double psize = 1.0;
122  for (unsigned i = 0; i < ImageDimension; i++)
123  {
124  psize *= this->GetInput()->GetSpacing()[i];
125  }
126  this->m_AttributeValuePerPixel = static_cast<AttributeType>(psize);
127  // std::cout << "m_AttributeValuePerPixel: " <<
128  // this->m_AttributeValuePerPixel << std::endl;
129  // and call superclass implementation of GenerateData()
130  }
132  }
133 
134  void
135  PrintSelf(std::ostream & os, Indent indent) const override
136  {
137  Superclass::PrintSelf(os, indent);
138  os << indent << "UseImageSpacing: " << m_UseImageSpacing << std::endl;
139  }
140 
141 private:
143 };
144 } // namespace itk
145 #endif
itk::AreaClosingImageFilter::OffsetType
typename TInputImage::OffsetType OffsetType
Definition: itkAreaClosingImageFilter.h:89
itk::AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute, std::less< TInputImage::PixelType > >::m_AttributeValuePerPixel
AttributeType m_AttributeValuePerPixel
Definition: itkAttributeMorphologyBaseImageFilter.h:170
itk::AreaClosingImageFilter::AttributeType
TAttribute AttributeType
Definition: itkAreaClosingImageFilter.h:91
itk::AreaClosingImageFilter::InputInternalPixelType
typename TInputImage::InternalPixelType InputInternalPixelType
Definition: itkAreaClosingImageFilter.h:87
itk::AreaClosingImageFilter::IndexType
typename TInputImage::IndexType IndexType
Definition: itkAreaClosingImageFilter.h:88
itk::AreaClosingImageFilter::SizeType
typename TInputImage::SizeType SizeType
Definition: itkAreaClosingImageFilter.h:90
itk::AttributeMorphologyBaseImageFilter::GenerateData
void GenerateData() override
itk::AreaClosingImageFilter::OutputPixelType
typename TOutputImage::PixelType OutputPixelType
Definition: itkAreaClosingImageFilter.h:84
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:85
itk::AreaClosingImageFilter::InputPixelType
typename TInputImage::PixelType InputPixelType
Definition: itkAreaClosingImageFilter.h:86
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:110
itk::AttributeMorphologyBaseImageFilter
Morphological opening by attributes.
Definition: itkAttributeMorphologyBaseImageFilter.h:63
itk::ImageToImageFilter::GetInput
const InputImageType * GetInput() const
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::AreaClosingImageFilter::GenerateData
void GenerateData() override
Definition: itkAreaClosingImageFilter.h:115
itk::AreaClosingImageFilter
Morphological closing by attributes.
Definition: itkAreaClosingImageFilter.h:61
itk::AreaClosingImageFilter::ImageDimension
static constexpr unsigned int ImageDimension
Definition: itkAreaClosingImageFilter.h:93
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:142
itk::AreaClosingImageFilter::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkAreaClosingImageFilter.h:135