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