diff --git a/Utilities/InsightJournal/itkLabelObjectUtils.h b/Utilities/InsightJournal/itkLabelObjectUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..6be33ba3a1666bf1ed07e0e42afe70ac5d528982 --- /dev/null +++ b/Utilities/InsightJournal/itkLabelObjectUtils.h @@ -0,0 +1,89 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile: itkLabelObject.h,v $ + Language: C++ + Date: $Date: 2005/01/21 20:13:31 $ + Version: $Revision: 1.6 $ + + Copyright (c) Insight Software Consortium. All rights reserved. + See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#ifndef __itkLabelObjectUtils_h +#define __itkLabelObjectUtils_h + +#include <deque> +#include <itkLightObject.h> +#include "itkLabelMap.h" +#include "itkLabelObjectLine.h" + +namespace itk +{ + + +namespace Functor { + +template< class TLabelObject > +class ITK_EXPORT LabelLabelObjectAccessor +{ +public: + typedef TLabelObject LabelObjectType; + typedef typename LabelObjectType::LabelType AttributeValueType; + + inline const AttributeValueType operator()( const LabelObjectType * labelObject ) + { + return labelObject->GetLabel(); + } +}; + +template< class TLabelObject > +class ITK_EXPORT NumberOfLinesLabelObjectAccessor +{ +public: + typedef TLabelObject LabelObjectType; + typedef int AttributeValueType; + + inline const AttributeValueType operator()( const LabelObjectType * labelObject ) + { + return labelObject->GetNumberOfLines(); + } +}; + +template< class TLabelObject, class TAttributeAccessor > +class LabelObjectComparator +{ +public: + typedef TLabelObject LabelObjectType; + typedef TAttributeAccessor AttributeAccessorType; + bool operator()( const LabelObjectType * a, const LabelObjectType * b ) + { + return accessor( a ) > accessor( b ); + } +private: + AttributeAccessorType accessor; +}; + +template< class TLabelObject, class TAttributeAccessor > +class LabelObjectReverseComparator +{ +public: + typedef TLabelObject LabelObjectType; + typedef TAttributeAccessor AttributeAccessorType; + bool operator()( const LabelObjectType * a, const LabelObjectType * b ) + { + return accessor( a ) < accessor( b ); + } +private: + AttributeAccessorType accessor; +}; + +} + +} // end namespace itk + +#endif diff --git a/Utilities/InsightJournal/itkShapeKeepNObjectsLabelMapFilter.txx b/Utilities/InsightJournal/itkShapeKeepNObjectsLabelMapFilter.txx index c49b0e020a7ac4a30b42c44e89909e411edb0aee..b6216bb6071b09d7845b085d5b59bec726208690 100644 --- a/Utilities/InsightJournal/itkShapeKeepNObjectsLabelMapFilter.txx +++ b/Utilities/InsightJournal/itkShapeKeepNObjectsLabelMapFilter.txx @@ -19,6 +19,7 @@ #include "itkShapeKeepNObjectsLabelMapFilter.h" #include "itkProgressReporter.h" +#include "itkLabelObjectUtils.h" namespace itk { diff --git a/Utilities/InsightJournal/itkStatisticsKeepNObjectsLabelMapFilter.txx b/Utilities/InsightJournal/itkStatisticsKeepNObjectsLabelMapFilter.txx index 2e25f5f1d587787a6012aca9a4675e999545c291..435ba468bceabd866fafa5215ad368f7be71e5f8 100644 --- a/Utilities/InsightJournal/itkStatisticsKeepNObjectsLabelMapFilter.txx +++ b/Utilities/InsightJournal/itkStatisticsKeepNObjectsLabelMapFilter.txx @@ -19,6 +19,7 @@ #include "itkStatisticsKeepNObjectsLabelMapFilter.h" #include "itkProgressReporter.h" +#include "itkLabelObjectUtils.h" namespace itk {