ITK  4.4.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< class TImage, class TLabelImage =
52  Image< typename TImage::PixelType, TImage ::ImageDimension > >
53 class ITK_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;
75  typedef typename LabelObjectType::VectorType VectorType;
76 
77  typedef TLabelImage LabelImageType;
81 
83  itkStaticConstMacro(ImageDimension, unsigned int, TImage::ImageDimension);
84 
86  itkNewMacro(Self);
87 
90 
91 #ifdef ITK_USE_CONCEPT_CHECKING
92 
93 /* itkConceptMacro(InputEqualityComparableCheck,
94  (Concept::EqualityComparable<InputImagePixelType>));
95  itkConceptMacro(IntConvertibleToInputCheck,
96  (Concept::Convertible<int, InputImagePixelType>));
97  itkConceptMacro(InputOStreamWritableCheck,
98  (Concept::OStreamWritable<InputImagePixelType>));*/
99 
101 #endif
102 
107  itkSetMacro(ComputeFeretDiameter, bool);
108  itkGetConstReferenceMacro(ComputeFeretDiameter, bool);
109  itkBooleanMacro(ComputeFeretDiameter);
111 
116  itkSetMacro(ComputePerimeter, bool);
117  itkGetConstReferenceMacro(ComputePerimeter, bool);
118  itkBooleanMacro(ComputePerimeter);
120 
122  void SetLabelImage(const TLabelImage *input)
123  {
124  m_LabelImage = input;
125  }
126 
127 protected:
130 
131  virtual void ThreadedProcessLabelObject(LabelObjectType *labelObject);
132 
133  virtual void BeforeThreadedGenerateData();
134 
135  virtual void AfterThreadedGenerateData();
136 
137  void PrintSelf(std::ostream & os, Indent indent) const;
138 
139 private:
140  ShapeLabelMapFilter(const Self &); //purposely not implemented
141  void operator=(const Self &); //purposely not implemented
142 
146 
147  void ComputeFeretDiameter(LabelObjectType *labelObject);
148  void ComputePerimeter(LabelObjectType *labelObject);
149 
154  typedef std::map<Offset2Type, SizeValueType, Offset2Type::LexicographicCompare> MapIntercept2Type;
155  typedef std::map<Offset3Type, SizeValueType, Offset3Type::LexicographicCompare> MapIntercept3Type;
156 
157  // it seems impossible to specialize a method without specializing the whole class, but we
158  // can use simple overloading
159  template<class TMapIntercept, class TSpacing> double PerimeterFromInterceptCount( TMapIntercept & intercepts, const TSpacing & spacing );
160 #if ! defined(ITK_DO_NOT_USE_PERIMETER_SPECIALIZATION)
161  double PerimeterFromInterceptCount( MapIntercept2Type & intercepts, const Spacing2Type spacing );
162  double PerimeterFromInterceptCount( MapIntercept3Type & intercepts, const Spacing3Type spacing );
163 #endif
164 };
165 
166 
167 } // end namespace itk
168 
169 #ifndef ITK_MANUAL_INSTANTIATION
170 #include "itkShapeLabelMapFilter.hxx"
171 #endif
172 
173 #endif
174