13 #ifndef mitkMinMaxLabelmageFilterWithIndex_h
14 #define mitkMinMaxLabelmageFilterWithIndex_h
19 #include <itkImageToImageFilter.h>
20 #include <itkImageRegionConstIteratorWithIndex.h>
21 #include <unordered_map>
39 template <
typename TInputImage,
typename TLabelImage>
45 typedef ImageToImageFilter< TInputImage, TInputImage >
Superclass;
56 typedef typename TInputImage::SizeType
SizeType;
59 typedef typename NumericTraits< PixelType >::RealType
RealType;
81 typedef typename std::unordered_map<LabelPixelType, LabelExtrema>
ExtremaMapType;
94 if (it == m_LabelExtrema.end())
99 return (*it).second.m_Min;
110 if (it == m_LabelExtrema.end())
115 return (*it).second.m_Max;
124 std::vector<LabelPixelType> labels;
125 for (
auto&& it:m_LabelExtrema)
127 labels.push_back(it.first);
140 if (it == m_LabelExtrema.end())
145 return (*it).second.m_MinIndex;
157 if (it == m_LabelExtrema.end())
162 return (*it).second.m_MaxIndex;
190 return m_GlobalMinIndex;
199 return m_GlobalMaxIndex;
209 this->SetNthInput( 1,
const_cast< TLabelImage *
>( input ) );
218 return itkDynamicCastInDebugMode< TLabelImage * >(
const_cast< DataObject *
>( this->ProcessObject::GetInput(1) ) );
224 this->DynamicMultiThreadingOff();
230 outputRegionForThread,
231 ThreadIdType threadId)
override;
238 std::vector<ExtremaMapType> m_ThreadExtrema;
243 IndexType m_GlobalMinIndex, m_GlobalMaxIndex;
247 #include <mitkMinMaxLabelmageFilterWithIndex.tpp>
Container holding minimum/maximum values and their indices for a single label.
Computes per-label and global minimum/maximum pixel values with their indices.
ExtremaMapType::const_iterator ExtremaMapTypeConstIterator
TInputImage::PixelType PixelType
IndexType GetGlobalMinIndex() const
Get the index of the global minimum pixel value.
PixelType GetMax(LabelPixelType label) const
Get the maximum pixel value for the given label.
void AfterThreadedGenerateData() override
TLabelImage::IndexType LabelIndexType
MinMaxLabelImageFilterWithIndex Self
ExtremaMapType::iterator ExtremaMapTypeIterator
void AllocateOutputs() override
std::vector< LabelPixelType > GetRelevantLabels() const
Get all labels for which extrema have been computed.
ExtremaMapType::value_type MapValueType
std::unordered_map< LabelPixelType, LabelExtrema > ExtremaMapType
SmartPointer< const Self > ConstPointer
TInputImage::RegionType RegionType
IndexType GetMinIndex(LabelPixelType label) const
Get the index of the minimum pixel value for the given label.
TInputImage::IndexType IndexType
TLabelImage::SizeType LabelSizeType
TInputImage::SizeType SizeType
PixelType GetGlobalMin() const
Get the global minimum pixel value across all labels.
const TLabelImage * GetLabelInput() const
Get the label image.
PixelType GetGlobalMax() const
Get the global maximum pixel value across all labels.
TLabelImage::PixelType LabelPixelType
SmartPointer< Self > Pointer
IndexType GetGlobalMaxIndex() const
Get the index of the global maximum pixel value.
PixelType GetMin(LabelPixelType label) const
Get the minimum pixel value for the given label.
ImageToImageFilter< TInputImage, TInputImage > Superclass
MinMaxLabelImageFilterWithIndex()
TLabelImage::RegionType LabelRegionType
NumericTraits< PixelType >::RealType RealType
void BeforeThreadedGenerateData() override
IndexType GetMaxIndex(LabelPixelType label) const
Get the index of the maximum pixel value for the given label.
void SetLabelInput(const TLabelImage *input)
Set the label image defining label regions.
void ThreadedGenerateData(const RegionType &outputRegionForThread, ThreadIdType threadId) override
#define MITK_ERROR
Log an error message.