16 #ifndef _MITK_IMAGESTATISTICSCALCULATOR_H
17 #define _MITK_IMAGESTATISTICSCALCULATOR_H
19 #include <itkObject.h>
22 #include <itkTimeStamp.h>
26 #ifndef __itkHistogram_h
27 #include <itkHistogram.h>
30 #include <itkImageRegionIteratorWithIndex.h>
33 #include <vtkSmartPointer.h>
37 #define mitkSetGetConstMacro(name, type) \
38 virtual type Get##name() const \
43 virtual void Set##name(const type _arg) \
45 if ( this->name != _arg ) \
166 MASKING_MODE_NONE = 0,
167 MASKING_MODE_IMAGE = 1,
168 MASKING_MODE_PLANARFIGURE = 2
179 Statistics(
bool withHotspotStatistics =
true);
186 const Statistics& GetHotspotStatistics()
const;
188 bool HasHotspotStatistics()
const;
189 void SetHasHotspotStatistics(
bool hasHotspotStatistics);
191 void Reset(
unsigned int dimension = 2);
200 double GetVariance() const;
210 void SetVariance( const
double );
212 double GetSigma() const;
223 void SetSigma( const
double );
247 vnl_vector<
int> MinIndex;
248 vnl_vector<
int> MaxIndex;
250 bool m_SkewnessAndKurtosisSuccesfulCalculated;
251 bool m_ImageStatisticsSuccesfulCalculated;
263 bool m_HasHotspotStatistics;
264 vnl_vector<
int> HotspotIndex;
271 itkFactorylessNewMacro(
Self)
275 void SetUseDefaultBinSize(
bool useDefault);
278 void SetImage( const
mitk::
Image *image );
281 void SetImageMask( const
mitk::
Image *imageMask );
288 void SetMaskingMode(
unsigned int mode );
291 itkGetMacro( MaskingMode,
unsigned int );
294 void SetMaskingModeToNone();
297 void SetMaskingModeToImage();
300 void SetMaskingModeToPlanarFigure();
303 void SetIgnorePixelValue(
double value);
306 double GetIgnorePixelValue();
309 void SetDoIgnorePixelValue(
bool doit);
312 bool GetDoIgnorePixelValue();
315 void SetHistogramBinSize(
double size);
318 double GetHistogramBinSize();
321 void SetHotspotRadiusInMM (
double hotspotRadiusInMM);
324 double GetHotspotRadiusInMM();
327 void SetCalculateHotspot(
bool calculateHotspot);
330 bool IsHotspotCalculated();
337 void SetHotspotMustBeCompletlyInsideImage(
bool hotspotIsCompletlyInsideImage,
bool warn = true);
340 bool GetHotspotMustBeCompletlyInsideImage() const;
347 virtual
bool ComputeStatistics(
unsigned int timeStep = 0 );
354 const HistogramType *GetHistogram(
unsigned int timeStep = 0,
unsigned int label = 0 ) const;
357 const HistogramContainer &GetHistogramVector(
unsigned int timeStep = 0 ) const;
362 BinFrequencyType GetBinsAndFreuqencyForHistograms(
unsigned int timeStep = 0,
unsigned int label = 0) const;
369 const
Statistics &GetStatistics(
unsigned int timeStep = 0,
unsigned int label = 0 ) const;
372 const StatisticsContainer &GetStatisticsVector(
unsigned int timeStep = 0 ) const;
387 ImageStatisticsCalculator();
389 virtual ~ImageStatisticsCalculator();
399 void ExtractImageAndMask(
unsigned int timeStep = 0 );
402 template < typename TPixel,
unsigned int VImageDimension >
403 void GetMinAndMaxValue(
double &minimum,
double &maximum,
int &counter,
double &sigma, const
itk::
Image< TPixel, VImageDimension > *InputImage,
410 unsigned int &axis );
412 template < typename TPixel,
unsigned int VImageDimension >
413 void InternalCalculateStatisticsUnmasked(
414 const
itk::
Image< TPixel, VImageDimension > *image,
415 StatisticsContainer* statisticsContainer,
416 HistogramContainer *histogramContainer );
418 template < typename TPixel,
unsigned int VImageDimension >
419 void InternalCalculateStatisticsMasked(
420 const
itk::
Image< TPixel, VImageDimension > *image,
421 itk::
Image<
unsigned short, VImageDimension > *maskImage,
422 StatisticsContainer* statisticsContainer,
423 HistogramContainer* histogramContainer );
425 template < typename TPixel,
unsigned int VImageDimension >
426 void InternalCalculateMaskFromPlanarFigure(
427 const
itk::
Image< TPixel, VImageDimension > *image,
unsigned int axis );
429 template < typename TPixel,
unsigned int VImageDimension >
430 void InternalMaskIgnoredPixels(
431 const
itk::
Image< TPixel, VImageDimension > *image,
432 itk::
Image<
unsigned short, VImageDimension > *maskImage );
445 ,Max(
itk::NumericTraits<double>::
min())
446 ,Min(
itk::NumericTraits<double>::
max())
455 template <
typename TPixel,
unsigned int VImageDimension >
456 ImageExtrema CalculateExtremaWorld(
457 const itk::Image<TPixel, VImageDimension> *inputImage,
458 itk::Image<unsigned short, VImageDimension> *maskImage,
459 double neccessaryDistanceToImageBorderInMM,
466 template <
typename TPixel,
unsigned int VImageDimension>
467 Statistics CalculateHotspotStatistics(
468 const itk::Image<TPixel, VImageDimension> *inputImage,
469 itk::Image<unsigned short, VImageDimension> *maskImage,
471 bool& isHotspotDefined,
475 template <
typename ITK_Exporter,
typename VTK_Importer>
478 importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
480 importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
481 importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
482 importer->SetSpacingCallback(exporter->GetSpacingCallback());
483 importer->SetOriginCallback(exporter->GetOriginCallback());
484 importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
486 importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
488 importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
489 importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
490 importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
491 importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
492 importer->SetCallbackUserData(exporter->GetCallbackUserData());
496 template <
typename VTK_Exporter,
typename ITK_Importer>
499 importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
501 importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
502 importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
503 importer->SetSpacingCallback(exporter->GetSpacingCallback());
504 importer->SetOriginCallback(exporter->GetOriginCallback());
505 importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
507 importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
509 importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
510 importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
511 importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
512 importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
513 importer->SetCallbackUserData(exporter->GetCallbackUserData());
517 void UnmaskedStatisticsProgressUpdate();
519 void MaskedStatisticsProgressUpdate();
522 template <
unsigned int VImageDimension>
523 itk::Size<VImageDimension>
524 CalculateConvolutionKernelSize(
double spacing[VImageDimension],
double radiusInMM);
527 template <
unsigned int VImageDimension>
529 GenerateHotspotSearchConvolutionKernel(
double spacing[VImageDimension],
double radiusInMM);
532 template <
typename TPixel,
unsigned int VImageDimension>
534 GenerateConvolutionImage(
const itk::Image<TPixel, VImageDimension>* inputImage );
537 template <
typename TPixel,
unsigned int VImageDimension>
539 FillHotspotMaskPixels( itk::Image<TPixel, VImageDimension>* maskImage,
540 itk::Point<double, VImageDimension> sphereCenter,
541 double sphereRadiusInMM);
double m_HistogramBinSize
mitk::Image::ConstPointer m_InternalImage
StatisticsVector m_ImageStatisticsVector
itk::Image< unsigned short, 3 > MaskImage3DType
bool m_UseBinSizeBasedOnVOIRegion
double m_HotspotRadiusInMM
double m_IgnorePixelValue
itk::SmartPointer< Self > Pointer
Statistics m_EmptyStatistics
mitk::Image::ConstPointer m_Image
vnl_vector< int > MaxIndex
HistogramVector m_ImageHistogramVector
HistogramVector m_PlanarFigureHistogramVector
DataCollection - Class to facilitate loading/accessing structured data.
A data structure describing a label.
bool m_UseDefaultBinSize
Bin size for histogram resoluion.
HistogramType::Pointer m_EmptyHistogram
Class for common statistics, includig hotspot properties.
unsigned int m_MaskingMode
bool m_MaskingModeChanged
StatisticsVector m_MaskedImageStatisticsVector
#define MITKIMAGESTATISTICS_EXPORT
itk::Statistics::Histogram< double > HistogramType
std::vector< StatisticsContainer > StatisticsVector
TimeStampVectorType m_PlanarFigureStatisticsTimeStampVector
Class for calculating statistics and histogram for an (optionally masked) image.
HistogramVector m_MaskedImageHistogramVector
TimeStampVectorType m_ImageStatisticsTimeStampVector
std::vector< HistogramType::ConstPointer > HistogramContainer
void ConnectPipelines(vtkSmartPointer< VTK_Exporter > exporter, ITK_Importer importer)
bool m_DoIgnorePixelValue
StatisticsVector m_PlanarFigureStatisticsVector
Container class for storing the computed image statistics.
StatisticsVector m_MaskedImageHotspotStatisticsVector
#define mitkClassMacroItkParent(className, SuperClassName)
Image class for storing images.
itk::Image< unsigned char, 3 > MaskImageType
BoolVectorType m_ImageStatisticsCalculationTriggerVector
bool m_HotspotRadiusInMMChanged
unsigned int m_PlanarFigureSlice
MaskImage3DType::Pointer m_InternalImageMask3D
void ConnectPipelines(ITK_Exporter exporter, vtkSmartPointer< VTK_Importer > importer)
mitk::Image::ConstPointer m_ImageMask
vnl_vector< int > MinIndex
unsigned int m_PlanarFigureAxis
BoolVectorType m_MaskedImageStatisticsCalculationTriggerVector
BoolVectorType m_PlanarFigureStatisticsCalculationTriggerVector
TimeStampVectorType m_MaskedImageStatisticsTimeStampVector
bool m_HotspotMustBeCompletelyInsideImage
itk::Image< unsigned short, 2 > MaskImage2DType
#define mitkSetGetConstMacro(name, type)
bool m_IgnorePixelValueChanged
MaskImage2DType::Pointer m_InternalImageMask2D
std::vector< itk::TimeStamp > TimeStampVectorType
mitk::PlanarFigure::Pointer m_PlanarFigure
std::vector< bool > BoolVectorType
int m_PlanarFigureCoordinate0
StatisticsContainer m_EmptyStatisticsContainer
HistogramContainer m_EmptyHistogramContainer
std::vector< HistogramContainer > HistogramVector
itk::SmartPointer< Self > Pointer
int m_PlanarFigureCoordinate1
HistogramType::ConstIterator HistogramConstIteratorType
BaseGeometry Describes the geometry of a data object.
std::map< int, double > BinFrequencyType