1 #ifndef MITK_MINMAXLABELIMAGEFILTERWITHINDEX_H
2 #define MITK_MINMAXLABELIMAGEFILTERWITHINDEX_H
7 #include <itkImageToImageFilter.h>
8 #include <itkImageRegionConstIteratorWithIndex.h>
9 #include "itksys/hash_map.hxx"
14 template <
typename TInputImage,
typename TLabelImage>
20 typedef ImageToImageFilter< TInputImage, TInputImage >
Superclass;
30 typedef typename TInputImage::RegionType
RegionType;
31 typedef typename TInputImage::SizeType
SizeType;
34 typedef typename NumericTraits< PixelType >::RealType
RealType;
51 m_Min(
std::numeric_limits<PixelType>::
max()),
52 m_Max(
std::numeric_limits<PixelType>::
min())
56 typedef typename itksys::hash_map<LabelPixelType, LabelExtrema>
ExtremaMapType;
61 PixelType
GetMin(LabelPixelType label)
const
63 ExtremaMapTypeConstIterator it = m_LabelExtrema.find(label);
64 if (it == m_LabelExtrema.end())
69 return (*it).second.m_Min;
72 PixelType
GetMax(LabelPixelType label)
const
74 ExtremaMapTypeConstIterator it = m_LabelExtrema.find(label);
75 if (it == m_LabelExtrema.end())
80 return (*it).second.m_Max;
88 std::vector<LabelPixelType> labels;
89 for (
auto&& it:m_LabelExtrema)
91 labels.push_back(it.first);
98 ExtremaMapTypeConstIterator it = m_LabelExtrema.find(label);
99 if (it == m_LabelExtrema.end())
104 return (*it).second.m_MinIndex;
110 ExtremaMapTypeConstIterator it = m_LabelExtrema.find(label);
111 if (it == m_LabelExtrema.end())
116 return (*it).second.m_MaxIndex;
132 return m_GlobalMinIndex;
137 return m_GlobalMaxIndex;
144 this->SetNthInput( 1, const_cast< TLabelImage * >( input ) );
150 return itkDynamicCastInDebugMode< TLabelImage * >(
const_cast< DataObject *
>( this->ProcessObject::GetInput(1) ) );
157 outputRegionForThread,
158 ThreadIdType threadId);
165 std::vector<ExtremaMapType> m_ThreadExtrema;
167 ExtremaMapType m_LabelExtrema;
168 PixelType m_GlobalMin;
169 PixelType m_GlobalMax;
170 IndexType m_GlobalMinIndex, m_GlobalMaxIndex;
174 #include "mitkMinMaxLabelmageFilterWithIndex.hxx"
TLabelImage::PixelType LabelPixelType
itksys::hash_map< LabelPixelType, LabelExtrema > ExtremaMapType
NumericTraits< PixelType >::RealType RealType
PixelType GetMax(LabelPixelType label) const
TLabelImage::IndexType LabelIndexType
ExtremaMapType::value_type MapValueType
TInputImage::SizeType SizeType
TInputImage::PixelType PixelType
IndexType GetGlobalMinIndex() const
ExtremaMapType::iterator ExtremaMapTypeIterator
PixelType GetGlobalMin() const
TLabelImage::RegionType LabelRegionType
SmartPointer< Self > Pointer
void AfterThreadedGenerateData()
IndexType GetMaxIndex(LabelPixelType label) const
IndexType GetMinIndex(LabelPixelType label) const
void SetLabelInput(const TLabelImage *input)
void BeforeThreadedGenerateData()
PixelType GetMin(LabelPixelType label) const
TLabelImage::SizeType LabelSizeType
MinMaxLabelImageFilterWithIndex Self
IndexType GetGlobalMaxIndex() const
SmartPointer< const Self > ConstPointer
TInputImage::IndexType IndexType
TInputImage::RegionType RegionType
The LabelExtrema class is just a container for global min/max values and their indices as well as all...
void ThreadedGenerateData(const RegionType &outputRegionForThread, ThreadIdType threadId)
ImageToImageFilter< TInputImage, TInputImage > Superclass
PixelType GetGlobalMax() const
std::vector< LabelPixelType > GetRelevantLabels() const
Returns a std::vector containing all labels for which min and max values (and indices) have been comp...
const TLabelImage * GetLabelInput() const
ExtremaMapType::const_iterator ExtremaMapTypeConstIterator