ITK  4.6.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 > >
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  // 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 
121  void SetLabelImage(const TLabelImage *input)
122  {
123  m_LabelImage = input;
124  }
125 
126 protected:
129 
130  virtual void ThreadedProcessLabelObject(LabelObjectType *labelObject);
131 
132  virtual void BeforeThreadedGenerateData();
133 
134  virtual void AfterThreadedGenerateData();
135 
136  void PrintSelf(std::ostream & os, Indent indent) const;
137 
138 private:
139  ShapeLabelMapFilter(const Self &); //purposely not implemented
140  void operator=(const Self &); //purposely not implemented
141 
145 
146  void ComputeFeretDiameter(LabelObjectType *labelObject);
147  void ComputePerimeter(LabelObjectType *labelObject);
148 
153  typedef std::map<Offset2Type, SizeValueType, Offset2Type::LexicographicCompare> MapIntercept2Type;
154  typedef std::map<Offset3Type, SizeValueType, Offset3Type::LexicographicCompare> MapIntercept3Type;
155 
156  // it seems impossible to specialize a method without specializing the whole class, but we
157  // can use simple overloading
158  template<typename TMapIntercept, typename TSpacing> double PerimeterFromInterceptCount( TMapIntercept & intercepts, const TSpacing & spacing );
159 #if ! defined(ITK_DO_NOT_USE_PERIMETER_SPECIALIZATION)
160  double PerimeterFromInterceptCount( MapIntercept2Type & intercepts, const Spacing2Type spacing );
161  double PerimeterFromInterceptCount( MapIntercept3Type & intercepts, const Spacing3Type spacing );
162 #endif
163 };
164 
165 
166 } // end namespace itk
167 
168 #ifndef ITK_MANUAL_INSTANTIATION
169 #include "itkShapeLabelMapFilter.hxx"
170 #endif
171 
172 #endif
itk::Vector< double, 2 > Spacing2Type
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:55
virtual void AfterThreadedGenerateData()
void PrintSelf(std::ostream &os, Indent indent) const
double PerimeterFromInterceptCount(TMapIntercept &intercepts, const TSpacing &spacing)
SmartPointer< const Self > ConstPointer
InputImageType::LabelObjectType LabelObjectType
ImageType::OffsetType OffsetType
TPixel PixelType
Definition: itkImage.h:89
void operator=(const Self &)
ImageType::IndexType IndexType
SmartPointer< Self > Pointer
itk::Vector< double, 3 > Spacing3Type
ImageType::LabelObjectType LabelObjectType
virtual void ThreadedProcessLabelObject(LabelObjectType *labelObject)
ImageType::ConstPointer ImageConstPointer
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
static const unsigned int ImageDimension
LabelImageType::Pointer LabelImagePointer
Base class for filters that takes an image as input and overwrites that image as the output...
virtual void BeforeThreadedGenerateData()
ImageType::PixelType PixelType
LabelImageType::PixelType LabelPixelType
LabelObjectType::VectorType VectorType
void ComputeFeretDiameter(LabelObjectType *labelObject)
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.
LabelImageConstPointer m_LabelImage
void ComputePerimeter(LabelObjectType *labelObject)
InPlaceLabelMapFilter< TImage > Superclass
std::map< Offset3Type, SizeValueType, Offset3Type::LexicographicCompare > MapIntercept3Type