ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkShapeLabelMapFilter.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 itkShapeLabelMapFilter_h
19 #define itkShapeLabelMapFilter_h
20 
23 
24 namespace itk
25 {
52 template< typename TImage, typename TLabelImage =
53  Image< typename TImage::PixelType, TImage ::ImageDimension > >
54 class ITK_TEMPLATE_EXPORT ShapeLabelMapFilter:
55  public
56  InPlaceLabelMapFilter< TImage >
57 {
58 public:
59  ITK_DISALLOW_COPY_AND_ASSIGN(ShapeLabelMapFilter);
60 
66 
68  using ImageType = TImage;
69  using ImagePointer = typename ImageType::Pointer;
70  using ImageConstPointer = typename ImageType::ConstPointer;
71  using PixelType = typename ImageType::PixelType;
72  using IndexType = typename ImageType::IndexType;
73  using SizeType = typename ImageType::SizeType;
75  using OffsetType = typename ImageType::OffsetType;
76  using LabelObjectType = typename ImageType::LabelObjectType;
77  using MatrixType = typename LabelObjectType::MatrixType;
79 
80  using LabelImageType = TLabelImage;
84 
86  static constexpr unsigned int ImageDimension = TImage::ImageDimension;
87 
89  itkNewMacro(Self);
90 
93 
94 #ifdef ITK_USE_CONCEPT_CHECKING
95  // Begin concept checking
96 /* itkConceptMacro(InputEqualityComparableCheck,
97  (Concept::EqualityComparable<InputImagePixelType>));
98  itkConceptMacro(IntConvertibleToInputCheck,
99  (Concept::Convertible<int, InputImagePixelType>));
100  itkConceptMacro(InputOStreamWritableCheck,
101  (Concept::OStreamWritable<InputImagePixelType>));*/
102 // End concept checking
103 #endif
104 
109  itkSetMacro(ComputeFeretDiameter, bool);
110  itkGetConstReferenceMacro(ComputeFeretDiameter, bool);
111  itkBooleanMacro(ComputeFeretDiameter);
113 
118  itkSetMacro(ComputePerimeter, bool);
119  itkGetConstReferenceMacro(ComputePerimeter, bool);
120  itkBooleanMacro(ComputePerimeter);
122 
128  itkSetMacro(ComputeOrientedBoundingBox, bool);
129  itkGetConstReferenceMacro(ComputeOrientedBoundingBox, bool);
130  itkBooleanMacro(ComputeOrientedBoundingBox);
132 
134  void SetLabelImage(const TLabelImage *input)
135  {
136  m_LabelImage = input;
137  }
138 
139 protected:
141  ~ShapeLabelMapFilter() override = default;
142 
143  void ThreadedProcessLabelObject(LabelObjectType *labelObject) override;
144 
145  void BeforeThreadedGenerateData() override;
146 
147  void AfterThreadedGenerateData() override;
148 
149  void PrintSelf(std::ostream & os, Indent indent) const override;
150 
151 private:
156 
157  void ComputeFeretDiameter(LabelObjectType *labelObject);
158  void ComputePerimeter(LabelObjectType *labelObject);
159  void ComputeOrientedBoundingBox(LabelObjectType *labelObject);
160 
165  using MapIntercept2Type = std::map<Offset2Type, SizeValueType, Functor::LexicographicCompare>;
166  using MapIntercept3Type = std::map<Offset3Type, SizeValueType, Functor::LexicographicCompare>;
167 
168  // it seems impossible to specialize a method without specializing the whole class, but we
169  // can use simple overloading
170  template<typename TMapIntercept, typename TSpacing> double PerimeterFromInterceptCount( TMapIntercept & intercepts, const TSpacing & spacing );
171 #if ! defined(ITK_DO_NOT_USE_PERIMETER_SPECIALIZATION)
172  double PerimeterFromInterceptCount( MapIntercept2Type & intercepts, const Spacing2Type spacing );
173  double PerimeterFromInterceptCount( MapIntercept3Type & intercepts, const Spacing3Type spacing );
174 #endif
175 };
176 
177 
178 } // end namespace itk
179 
180 #ifndef ITK_MANUAL_INSTANTIATION
181 #include "itkShapeLabelMapFilter.hxx"
182 #endif
183 
184 #endif
void SetLabelImage(const TLabelImage *input)
TPixel PixelType
Definition: itkImage.h:95
Light weight base class for most itk classes.
std::map< Offset3Type, SizeValueType, Functor::LexicographicCompare > MapIntercept3Type
typename InputImageType::IndexType IndexType
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
Base class for filters that takes an image as input and overwrites that image as the output...
typename InputImageType::PixelType PixelType
Represent a n-dimensional offset between two n-dimensional indexes of n-dimensional image...
Definition: itkOffset.h:67
std::map< Offset2Type, SizeValueType, Functor::LexicographicCompare > MapIntercept2Type
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename InputImageType::LabelObjectType LabelObjectType
The valuator class for the ShapeLabelObject.
typename InputImageType::RegionType RegionType
Templated n-dimensional image class.
Definition: itkImage.h:75
LabelImageConstPointer m_LabelImage