ITK  4.13.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 
22 
23 namespace itk
24 {
51 template< typename TImage, typename TLabelImage =
52  Image< typename TImage::PixelType, TImage ::ImageDimension > >
53 class ITK_TEMPLATE_EXPORT ShapeLabelMapFilter:
54  public
55  InPlaceLabelMapFilter< TImage >
56 {
57 public:
63 
65  typedef TImage ImageType;
66  typedef typename ImageType::Pointer ImagePointer;
67  typedef typename ImageType::ConstPointer ImageConstPointer;
68  typedef typename ImageType::PixelType PixelType;
69  typedef typename ImageType::IndexType IndexType;
70  typedef typename ImageType::SizeType SizeType;
71  typedef typename ImageType::RegionType RegionType;
72  typedef typename ImageType::OffsetType OffsetType;
73  typedef typename ImageType::LabelObjectType LabelObjectType;
74  typedef typename LabelObjectType::MatrixType MatrixType;
76 
77  typedef TLabelImage LabelImageType;
79  typedef typename LabelImageType::ConstPointer LabelImageConstPointer;
81 
83  itkStaticConstMacro(ImageDimension, unsigned int, 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 SetLabelImage(const TLabelImage *input)
132  {
133  m_LabelImage = input;
134  }
135 
136 protected:
138  ~ShapeLabelMapFilter() ITK_OVERRIDE {}
139 
140  virtual void ThreadedProcessLabelObject(LabelObjectType *labelObject) ITK_OVERRIDE;
141 
142  virtual void BeforeThreadedGenerateData() ITK_OVERRIDE;
143 
144  virtual void AfterThreadedGenerateData() ITK_OVERRIDE;
145 
146  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
147 
148 private:
149  ITK_DISALLOW_COPY_AND_ASSIGN(ShapeLabelMapFilter);
150 
151  bool m_ComputeFeretDiameter;
152  bool m_ComputePerimeter;
153  bool m_ComputeOrientedBoundingBox;
155 
156  void ComputeFeretDiameter(LabelObjectType *labelObject);
157  void ComputePerimeter(LabelObjectType *labelObject);
158  void ComputeOrientedBoundingBox(LabelObjectType *labelObject);
159 
160  typedef itk::Offset<2> Offset2Type;
161  typedef itk::Offset<3> Offset3Type;
162  typedef itk::Vector<double, 2> Spacing2Type;
163  typedef itk::Vector<double, 3> Spacing3Type;
164  typedef std::map<Offset2Type, SizeValueType, Offset2Type::LexicographicCompare> MapIntercept2Type;
165  typedef std::map<Offset3Type, SizeValueType, Offset3Type::LexicographicCompare> MapIntercept3Type;
166 
167  // it seems impossible to specialize a method without specializing the whole class, but we
168  // can use simple overloading
169  template<typename TMapIntercept, typename TSpacing> double PerimeterFromInterceptCount( TMapIntercept & intercepts, const TSpacing & spacing );
170 #if ! defined(ITK_DO_NOT_USE_PERIMETER_SPECIALIZATION)
171  double PerimeterFromInterceptCount( MapIntercept2Type & intercepts, const Spacing2Type spacing );
172  double PerimeterFromInterceptCount( MapIntercept3Type & intercepts, const Spacing3Type spacing );
173 #endif
174 };
175 
176 
177 } // end namespace itk
178 
179 #ifndef ITK_MANUAL_INSTANTIATION
180 #include "itkShapeLabelMapFilter.hxx"
181 #endif
182 
183 #endif
void SetLabelImage(const TLabelImage *input)
Light weight base class for most itk classes.
Represent the offset between two n-dimensional indexes in a n-dimensional image.
Definition: itkOffset.h:56
SmartPointer< const Self > ConstPointer
InputImageType::LabelObjectType LabelObjectType
ImageType::OffsetType OffsetType
unsigned long SizeValueType
Definition: itkIntTypes.h:143
TPixel PixelType
Definition: itkImage.h:89
ImageType::IndexType IndexType
SmartPointer< Self > Pointer
ImageType::LabelObjectType LabelObjectType
ImageType::ConstPointer ImageConstPointer
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
LabelImageType::Pointer LabelImagePointer
Base class for filters that takes an image as input and overwrites that image as the output...
ImageType::PixelType PixelType
LabelImageType::PixelType LabelPixelType
LabelObjectType::VectorType VectorType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
std::map< Offset2Type, SizeValueType, Offset2Type::LexicographicCompare > MapIntercept2Type
LabelImageType::ConstPointer LabelImageConstPointer
ImageType::RegionType RegionType
LabelObjectType::MatrixType MatrixType
The valuator class for the ShapeLabelObject.
InPlaceLabelMapFilter< TImage > Superclass
std::map< Offset3Type, SizeValueType, Offset3Type::LexicographicCompare > MapIntercept3Type