ITK  5.3.0
Insight Toolkit
itkShapeLabelMapFilter.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 itkShapeLabelMapFilter_h
19 #define itkShapeLabelMapFilter_h
20 
23 
24 namespace itk
25 {
52 template <typename TImage, typename TLabelImage = Image<typename TImage::PixelType, TImage::ImageDimension>>
53 class ITK_TEMPLATE_EXPORT ShapeLabelMapFilter : public InPlaceLabelMapFilter<TImage>
54 {
55 public:
56  ITK_DISALLOW_COPY_AND_MOVE(ShapeLabelMapFilter);
57 
63 
65  using ImageType = TImage;
66  using ImagePointer = typename ImageType::Pointer;
67  using ImageConstPointer = typename ImageType::ConstPointer;
68  using PixelType = typename ImageType::PixelType;
69  using IndexType = typename ImageType::IndexType;
70  using SizeType = typename ImageType::SizeType;
72  using OffsetType = typename ImageType::OffsetType;
73  using LabelObjectType = typename ImageType::LabelObjectType;
74  using MatrixType = typename LabelObjectType::MatrixType;
76 
77  using LabelImageType = TLabelImage;
81 
83  static constexpr unsigned int ImageDimension = TImage::ImageDimension;
84 
86  itkNewMacro(Self);
87 
90 
91 #ifdef ITK_USE_CONCEPT_CHECKING
92  // Begin concept checking
93 /* itkConceptMacro(InputEqualityComparableCheck,
94  (Concept::EqualityComparable<InputImagePixelType>));
95  itkConceptMacro(IntConvertibleToInputCheck,
96  (Concept::Convertible<int, InputImagePixelType>));
97  itkConceptMacro(InputOStreamWritableCheck,
98  (Concept::OStreamWritable<InputImagePixelType>));*/
99 // End concept checking
100 #endif
101 
106  itkSetMacro(ComputeFeretDiameter, bool);
107  itkGetConstReferenceMacro(ComputeFeretDiameter, bool);
108  itkBooleanMacro(ComputeFeretDiameter);
110 
115  itkSetMacro(ComputePerimeter, bool);
116  itkGetConstReferenceMacro(ComputePerimeter, bool);
117  itkBooleanMacro(ComputePerimeter);
119 
125  itkSetMacro(ComputeOrientedBoundingBox, bool);
126  itkGetConstReferenceMacro(ComputeOrientedBoundingBox, bool);
127  itkBooleanMacro(ComputeOrientedBoundingBox);
129 
131  void
132  SetLabelImage(const TLabelImage * input)
133  {
134  m_LabelImage = input;
135  }
136 
137 protected:
139  ~ShapeLabelMapFilter() override = default;
140 
141  void
142  ThreadedProcessLabelObject(LabelObjectType * labelObject) override;
143 
144  void
145  BeforeThreadedGenerateData() override;
146 
147  void
148  AfterThreadedGenerateData() override;
149 
150  void
151  PrintSelf(std::ostream & os, Indent indent) const override;
152 
153 private:
158 
159  void
160  ComputeFeretDiameter(LabelObjectType * labelObject);
161  void
162  ComputePerimeter(LabelObjectType * labelObject);
163  void
164  ComputeOrientedBoundingBox(LabelObjectType * labelObject);
165 
170  using MapIntercept2Type = std::map<Offset2Type, SizeValueType, Functor::LexicographicCompare>;
171  using MapIntercept3Type = std::map<Offset3Type, SizeValueType, Functor::LexicographicCompare>;
172 
173  // it seems impossible to specialize a method without specializing the whole class, but we
174  // can use simple overloading
175  template <typename TMapIntercept, typename TSpacing>
176  double
177  PerimeterFromInterceptCount(TMapIntercept & intercepts, const TSpacing & spacing);
178 #if !defined(ITK_DO_NOT_USE_PERIMETER_SPECIALIZATION)
179  double
180  PerimeterFromInterceptCount(MapIntercept2Type & intercepts, const Spacing2Type spacing);
181  double
182  PerimeterFromInterceptCount(MapIntercept3Type & intercepts, const Spacing3Type spacing);
183 #endif
184 };
185 
186 
187 } // end namespace itk
188 
189 #ifndef ITK_MANUAL_INSTANTIATION
190 # include "itkShapeLabelMapFilter.hxx"
191 #endif
192 
193 #endif
itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >::ImageType
TImage ImageType
Definition: itkShapeLabelMapFilter.h:65
itk::ShapeLabelMapFilter::m_ComputePerimeter
bool m_ComputePerimeter
Definition: itkShapeLabelMapFilter.h:155
itk::ShapeLabelMapFilter::m_ComputeFeretDiameter
bool m_ComputeFeretDiameter
Definition: itkShapeLabelMapFilter.h:154
itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >::MapIntercept3Type
std::map< Offset3Type, SizeValueType, Functor::LexicographicCompare > MapIntercept3Type
Definition: itkShapeLabelMapFilter.h:171
itk::InPlaceLabelMapFilter
Base class for filters that takes an image as input and overwrites that image as the output.
Definition: itkInPlaceLabelMapFilter.h:83
itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >::MapIntercept2Type
std::map< Offset2Type, SizeValueType, Functor::LexicographicCompare > MapIntercept2Type
Definition: itkShapeLabelMapFilter.h:170
itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >::LabelImagePointer
typename LabelImageType::Pointer LabelImagePointer
Definition: itkShapeLabelMapFilter.h:78
itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >::SizeType
typename ImageType::SizeType SizeType
Definition: itkShapeLabelMapFilter.h:70
itk::GTest::TypedefsAndConstructors::Dimension2::VectorType
ImageBaseType::SpacingType VectorType
Definition: itkGTestTypedefsAndConstructors.h:53
itk::Vector
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
itk::InPlaceLabelMapFilter< TImage >::LabelObjectType
typename InputImageType::LabelObjectType LabelObjectType
Definition: itkInPlaceLabelMapFilter.h:112
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itkLexicographicCompare.h
itk::SmartPointer< Self >
itk::ShapeLabelMapFilter::m_LabelImage
LabelImageConstPointer m_LabelImage
Definition: itkShapeLabelMapFilter.h:157
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ShapeLabelMapFilter
The valuator class for the ShapeLabelObject.
Definition: itkShapeLabelMapFilter.h:53
itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >::ImagePointer
typename ImageType::Pointer ImagePointer
Definition: itkShapeLabelMapFilter.h:66
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >::LabelPixelType
typename LabelImageType::PixelType LabelPixelType
Definition: itkShapeLabelMapFilter.h:80
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ShapeLabelMapFilter::SetLabelImage
void SetLabelImage(const TLabelImage *input)
Definition: itkShapeLabelMapFilter.h:132
itkInPlaceLabelMapFilter.h
itk::InPlaceLabelMapFilter< TImage >::RegionType
typename InputImageType::RegionType RegionType
Definition: itkInPlaceLabelMapFilter.h:116
itk::ShapeLabelMapFilter::m_ComputeOrientedBoundingBox
bool m_ComputeOrientedBoundingBox
Definition: itkShapeLabelMapFilter.h:156
itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >::LabelImageConstPointer
typename LabelImageType::ConstPointer LabelImageConstPointer
Definition: itkShapeLabelMapFilter.h:79
itk::Image::PixelType
TPixel PixelType
Definition: itkImage.h:106
itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >::ImageConstPointer
typename ImageType::ConstPointer ImageConstPointer
Definition: itkShapeLabelMapFilter.h:67
itk::Offset
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image.
Definition: itkOffset.h:67
itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >::MatrixType
typename LabelObjectType::MatrixType MatrixType
Definition: itkShapeLabelMapFilter.h:74
itk::InPlaceLabelMapFilter< TImage >::PixelType
typename InputImageType::PixelType PixelType
Definition: itkInPlaceLabelMapFilter.h:114
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >::OffsetType
typename ImageType::OffsetType OffsetType
Definition: itkShapeLabelMapFilter.h:72
itk::ShapeLabelMapFilter< TImage, Image< TImage::PixelType, TImage::ImageDimension > >::VectorType
typename LabelObjectType::VectorType VectorType
Definition: itkShapeLabelMapFilter.h:75
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itk::InPlaceLabelMapFilter< TImage >::IndexType
typename InputImageType::IndexType IndexType
Definition: itkInPlaceLabelMapFilter.h:115