28 m_ScalarMax.resize(1, itk::NumericTraits<ScalarType>::NonpositiveMin());
30 m_Scalar2ndMax.resize(1, itk::NumericTraits<ScalarType>::NonpositiveMin());
43 m_HistogramGeneratorObject =
nullptr;
52 if (timeSelector !=
nullptr)
55 timeSelector->UpdateLargestPossibleRegion();
68 return m_Image->IsValidTimeStep(t);
79 timeSelector->SetInput(m_Image);
87 if (!m_Image->IsValidTimeStep(timeSteps - 1))
91 m_Image->Expand(timeSteps);
93 if (timeSteps > m_ScalarMin.size())
96 m_ScalarMax.resize(timeSteps, itk::NumericTraits<ScalarType>::NonpositiveMin());
98 m_Scalar2ndMax.resize(timeSteps, itk::NumericTraits<ScalarType>::NonpositiveMin());
99 m_CountOfMinValuedVoxels.resize(timeSteps, 0);
100 m_CountOfMaxValuedVoxels.resize(timeSteps, 0);
107 m_ScalarMax.assign(1, itk::NumericTraits<ScalarType>::NonpositiveMin());
109 m_Scalar2ndMax.assign(1, itk::NumericTraits<ScalarType>::NonpositiveMin());
110 m_CountOfMinValuedVoxels.assign(1, 0);
111 m_CountOfMaxValuedVoxels.assign(1, 0);
118 template <
typename ItkImageType>
121 typename ItkImageType::RegionType region;
122 region = itkImage->GetBufferedRegion();
123 if (region.Crop(itkImage->GetRequestedRegion()) ==
false)
125 if (region != itkImage->GetRequestedRegion())
128 itk::ImageRegionConstIterator<ItkImageType> it(itkImage, region);
132 if (statisticsHolder ==
nullptr || !statisticsHolder->
IsValidTimeStep(t))
134 statisticsHolder->
Expand(t + 1);
140 itk::NumericTraits<ScalarType>::NonpositiveMin();
142 while (!it.IsAtEnd())
155 #ifdef BOUNDINGOBJECT_IGNORE
160 if (value < statisticsHolder->m_ScalarMin[t])
166 else if (value == statisticsHolder->
m_ScalarMin[t])
170 else if (value < statisticsHolder->m_Scalar2ndMin[t])
182 else if (value == statisticsHolder->
m_ScalarMax[t])
190 #ifdef BOUNDINGOBJECT_IGNORE
208 template <
typename ItkImageType>
209 void mitk::_ComputeExtremaInItkVectorImage(
const ItkImageType *itkImage,
212 unsigned int component)
214 typename ItkImageType::RegionType region;
215 region = itkImage->GetBufferedRegion();
216 if (region.Crop(itkImage->GetRequestedRegion()) ==
false)
218 if (region != itkImage->GetRequestedRegion())
221 itk::ImageRegionConstIterator<ItkImageType> it(itkImage, region);
223 if (statisticsHolder ==
nullptr || !statisticsHolder->
IsValidTimeStep(t))
225 statisticsHolder->
Expand(t + 1);
231 itk::NumericTraits<ScalarType>::NonpositiveMin();
233 while (!it.IsAtEnd())
235 double value = it.Get()[component];
246 #ifdef BOUNDINGOBJECT_IGNORE
251 if (value < statisticsHolder->m_ScalarMin[t])
257 else if (value == statisticsHolder->
m_ScalarMin[t])
261 else if (value < statisticsHolder->m_Scalar2ndMin[t])
273 else if (value == statisticsHolder->
m_ScalarMax[t])
281 #ifdef BOUNDINGOBJECT_IGNORE
302 if (!m_Image->IsValidTimeStep(t))
306 if (this->m_Image->GetMTime() > m_LastRecomputeTimeStamp.GetMTime())
307 this->ResetImageStatistics();
325 if (timeSelector.IsNotNull())
327 timeSelector->SetTimeNr(t);
328 timeSelector->UpdateLargestPossibleRegion();
329 const mitk::Image *image = timeSelector->GetOutput();
333 else if (pType.
GetPixelType() == itk::ImageIOBase::VECTOR &&
338 if (timeSelector.IsNotNull())
340 timeSelector->SetTimeNr(t);
341 timeSelector->UpdateLargestPossibleRegion();
342 const mitk::Image *image = timeSelector->GetOutput();
349 m_ScalarMax[t] = 255;
350 m_Scalar2ndMin[t] = 0;
351 m_Scalar2ndMax[t] = 255;
357 ComputeImageStatistics(t, component);
358 return m_ScalarMin[t];
363 ComputeImageStatistics(t, component);
364 return m_ScalarMax[t];
369 ComputeImageStatistics(t, component);
370 return m_Scalar2ndMin[t];
375 ComputeImageStatistics(t, component);
376 return m_Scalar2ndMax[t];
381 ComputeImageStatistics(t, component);
382 return m_CountOfMinValuedVoxels[t];
387 ComputeImageStatistics(t, component);
388 return m_CountOfMaxValuedVoxels[t];
virtual ScalarType GetScalarValue2ndMin(int t=0, unsigned int component=0)
Get the second smallest value for scalar images. Recomputation performed only when necessary...
virtual void ResetImageStatistics()
virtual ScalarType GetScalarValue2ndMax(int t=0, unsigned int component=0)
Get the second largest value for scalar images.
itk::Object::Pointer m_HistogramGeneratorObject
std::vector< unsigned int > m_CountOfMaxValuedVoxels
std::vector< unsigned int > m_CountOfMinValuedVoxels
bool IsValidTimeStep(int t) const
virtual void ComputeImageStatistics(int t=0, unsigned int component=0)
itk::ImageIOBase::IOPixelType GetPixelType() const
virtual void Expand(unsigned int timeSteps)
itk::TimeStamp m_LastRecomputeTimeStamp
virtual ScalarType GetScalarValueMin(int t=0, unsigned int component=0)
Get the minimum for scalar images. Recomputation performed only when necessary.
virtual void SetTimeNr(int _arg)
ImageStatisticsHolder(mitk::Image *image)
#define AccessVectorPixelTypeByItk_n(mitkImage, itkImageTypeFunction, va_tuple)
Access a vector mitk::Image by an ITK vector image with one or more parameters.
virtual ScalarType GetScalarValueMax(int t=0, unsigned int component=0)
Get the maximum for scalar images. Recomputation performed only when necessary.
Image class for storing images.
Provides access to a volume at a specific time of the input image.
virtual void SetImage(mitk::Image::ConstPointer _arg)
Class holding the statistics informations about a single mitk::Image.
ImageTimeSelector::Pointer GetTimeSelector()
virtual ~ImageStatisticsHolder()
vcl_size_t GetNumberOfComponents() const
Get the number of components of which each element consists.
std::vector< ScalarType > m_ScalarMax
OutputType * GetOutput()
Get the output data of this image source object.
#define AccessByItk_2(mitkImage, itkImageTypeFunction, arg1, arg2)
itk::Statistics::Histogram< double > HistogramType
Provides an easy way to calculate an itk::Histogram for a mitk::Image.
std::vector< ScalarType > m_Scalar2ndMin
mitk::ScalarType GetCountOfMinValuedVoxels(int t=0, unsigned int component=0)
Get the count of voxels with the smallest scalar value in the dataset.
virtual const HistogramType * GetHistogram()
mitk::ScalarType GetCountOfMaxValuedVoxels(int t=0, unsigned int component=0)
Get the count of voxels with the largest scalar value in the dataset.
std::vector< ScalarType > m_Scalar2ndMax
Class for defining the data type of pixels.
std::vector< ScalarType > m_ScalarMin
virtual T GetValue() const
virtual const HistogramType * GetScalarHistogram(int t=0, unsigned int=0)