ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkAreaClosingImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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, typename TOutputImage, typename TAttribute = typename TInputImage::SpacingType::ValueType >
60  public AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute,
61  std::less< typename TInputImage::PixelType > >
62 
63 {
64 public:
65  ITK_DISALLOW_COPY_AND_ASSIGN(AreaClosingImageFilter);
66 
68  using Superclass = AttributeMorphologyBaseImageFilter< TInputImage, TOutputImage, TAttribute,
69  std::less< typename TInputImage::PixelType > >;
70 
73 
78  using OutputPixelType = typename TOutputImage::PixelType;
79  using OutputInternalPixelType = typename TOutputImage::InternalPixelType;
80  using InputPixelType = typename TInputImage::PixelType;
81  using InputInternalPixelType = typename TInputImage::InternalPixelType;
83  using OffsetType = typename TInputImage::OffsetType;
84  using SizeType = typename TInputImage::SizeType;
85  using AttributeType = TAttribute;
86 
87  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
88 
90  itkNewMacro(Self);
91 
93  itkTypeMacro(AreaClosingImageFilter,
95 
99  itkSetMacro(UseImageSpacing, bool);
100  itkGetConstReferenceMacro(UseImageSpacing, bool);
101  itkBooleanMacro(UseImageSpacing);
103 
104 protected:
106  {
107  m_UseImageSpacing = true;
108  }
109 
111 
112  void GenerateData() override
113  {
114  this->m_AttributeValuePerPixel = 1;
115  if ( m_UseImageSpacing )
116  {
117  // compute pixel size
118  double psize = 1.0;
119  for ( unsigned i = 0; i < ImageDimension; i++ )
120  {
121  psize *= this->GetInput()->GetSpacing()[i];
122  }
123  this->m_AttributeValuePerPixel = static_cast< AttributeType >( psize );
124  // std::cout << "m_AttributeValuePerPixel: " <<
125  // this->m_AttributeValuePerPixel << std::endl;
126  // and call superclass implementation of GenerateData()
127  }
129  }
130 
131  void PrintSelf(std::ostream & os, Indent indent) const override
132  {
133  Superclass::PrintSelf(os, indent);
134  os << indent << "UseImageSpacing: " << m_UseImageSpacing << std::endl;
135  }
136 
137 private:
138 
140 };
141 } // namespace itk
142 #endif
typename TInputImage::IndexType IndexType
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
typename TInputImage::PixelType InputPixelType
Base class for all process objects that output image data.
typename TInputImage::OffsetType OffsetType
static constexpr unsigned int ImageDimension
Morphological closing by attributes.
typename TInputImage::InternalPixelType InputInternalPixelType
void PrintSelf(std::ostream &os, Indent indent) const override
const InputImageType * GetInput() const
void PrintSelf(std::ostream &os, Indent indent) const override
typename TOutputImage::PixelType OutputPixelType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename TOutputImage::InternalPixelType OutputInternalPixelType
typename TInputImage::SizeType SizeType