Orfeo Toolbox  3.16
itkRelabelComponentImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkRelabelComponentImageFilter.h,v $
5  Language: C++
6  Date: $Date: 2009-04-27 22:58:48 $
7  Version: $Revision: 1.17 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkRelabelComponentImageFilter_h
18 #define __itkRelabelComponentImageFilter_h
19 
20 #include "itkInPlaceImageFilter.h"
21 #include "itkImage.h"
22 #include <vector>
23 
24 namespace itk
25 {
26 
73 template <class TInputImage, class TOutputImage>
75  public InPlaceImageFilter< TInputImage, TOutputImage >
76 {
77 public:
83 
88 
93  typedef typename TOutputImage::PixelType OutputPixelType;
94  typedef typename TOutputImage::InternalPixelType OutputInternalPixelType;
95  typedef typename TInputImage::PixelType InputPixelType;
96  typedef typename TInputImage::InternalPixelType InputInternalPixelType;
97  itkStaticConstMacro(ImageDimension, unsigned int,
98  TOutputImage::ImageDimension);
99  itkStaticConstMacro(InputImageDimension, unsigned int,
100  TInputImage::ImageDimension);
101 
105  typedef TInputImage InputImageType;
106  typedef TOutputImage OutputImageType;
107  typedef typename TInputImage::IndexType IndexType;
108  typedef typename TInputImage::SizeType SizeType;
109  typedef typename TOutputImage::RegionType RegionType;
110 
116 
121 
125  itkNewMacro(Self);
126 
128  typedef unsigned long int LabelType;
129 
131  typedef unsigned long int ObjectSizeType;
132 
135  itkGetConstMacro(NumberOfObjects, LabelType);
136 
142  itkGetConstMacro(OriginalNumberOfObjects, LabelType);
143 
146  itkSetMacro(NumberOfObjectsToPrint, LabelType);
147  itkGetConstReferenceMacro(NumberOfObjectsToPrint, LabelType);
148 
155  itkSetMacro(MinimumObjectSize, ObjectSizeType);
156 
162  itkGetConstMacro(MinimumObjectSize, ObjectSizeType);
163 
169  const std::vector<ObjectSizeType>& GetSizeOfObjectsInPixels() const
170  { return m_SizeOfObjectsInPixels; }
171 
177  const std::vector<float>& GetSizeOfObjectsInPhysicalUnits() const
178  { return m_SizeOfObjectsInPhysicalUnits; }
179 
183  ObjectSizeType GetSizeOfObjectInPixels( LabelType obj ) const
184  {
185  if (obj > 0 && obj <= m_NumberOfObjects)
186  {
187  return m_SizeOfObjectsInPixels[obj-1];
188  }
189  else
190  {
191  return 0;
192  }
193  }
194 
198  float GetSizeOfObjectInPhysicalUnits( LabelType obj ) const
199  {
200  if (obj > 0 && obj <= m_NumberOfObjects)
201  {
202  return m_SizeOfObjectsInPhysicalUnits[obj-1];
203  }
204  else
205  {
206  return 0;
207  }
208  }
209 
210 #ifdef ITK_USE_CONCEPT_CHECKING
211 
212  itkConceptMacro(InputEqualityComparableCheck,
214  itkConceptMacro(UnsignedLongConvertibleToInputCheck,
216  itkConceptMacro(OutputLongConvertibleToUnsignedLongCheck,
218  itkConceptMacro(InputConvertibleToOutputCheck,
220  itkConceptMacro(SameDimensionCheck,
223 #endif
224 
225 protected:
226 
228  : m_NumberOfObjects(0), m_NumberOfObjectsToPrint(10),
229  m_OriginalNumberOfObjects(0), m_MinimumObjectSize(0)
230  { this->InPlaceOff(); }
233 
237  void GenerateData();
238 
242  void GenerateInputRequestedRegion();
243 
245  void PrintSelf(std::ostream& os, Indent indent) const;
246 
248  {
252  };
253 
254  // put the function objects here for sorting in descending order
256  {
257  public:
258  bool operator()(const RelabelComponentObjectType&a,
260  {
261  if (a.m_SizeInPixels > b.m_SizeInPixels)
262  {
263  return true;
264  }
265  else if (a.m_SizeInPixels < b.m_SizeInPixels)
266  {
267  return false;
268  }
269  // size in pixels and physical units are the same, sort based on
270  // original object number
271  else if (a.m_ObjectNumber < b.m_ObjectNumber)
272  {
273  return true;
274  }
275  else
276  {
277  return false;
278  }
279  }
280  };
281 
282 
283 private:
284 
289 
290  std::vector<ObjectSizeType> m_SizeOfObjectsInPixels;
291  std::vector<float> m_SizeOfObjectsInPhysicalUnits;
292 
293 };
294 
295 } // end namespace itk
296 
297 #ifndef ITK_MANUAL_INSTANTIATION
299 #endif
300 
301 #endif

Generated at Sun Feb 3 2013 00:03:21 for Orfeo Toolbox with doxygen 1.8.1.1