28 #include <itkScalarImageToHistogramGenerator.h>
30 #include <itkChangeInformationImageFilter.h>
31 #include <itkExtractImageFilter.h>
32 #include <itkMinimumMaximumImageCalculator.h>
33 #include <itkStatisticsImageFilter.h>
34 #include <itkLabelStatisticsImageFilter.h>
35 #include <itkMaskImageFilter.h>
36 #include <itkImageFileWriter.h>
37 #include <itkRescaleIntensityImageFilter.h>
39 #include <itkMaskImageFilter.h>
41 #include <itkImageRegionConstIterator.h>
42 #include <itkImageRegionIterator.h>
44 #include <itkCastImageFilter.h>
45 #include <itkVTKImageImport.h>
46 #include <itkVTKImageExport.h>
47 #include <itkImageDuplicator.h>
49 #include <vtkPoints.h>
50 #include <vtkImageStencil.h>
51 #include <vtkImageImport.h>
52 #include <vtkImageExport.h>
53 #include <vtkLassoStencilSource.h>
55 #include <itkFFTConvolutionImageFilter.h>
56 #include <itkConstantBoundaryCondition.h>
57 #include <itkImageDuplicator.h>
59 #include <itkContinuousIndex.h>
60 #include <itkNumericTraits.h>
70 #define _USE_MATH_DEFINES
73 #include "vtkLassoStencilSource.h"
79 : m_MaskingMode( MASKING_MODE_NONE ),
80 m_MaskingModeChanged(
false ),
81 m_IgnorePixelValue(0.0),
82 m_DoIgnorePixelValue(
false),
83 m_IgnorePixelValueChanged(
false),
84 m_PlanarFigureAxis (0),
85 m_PlanarFigureSlice (0),
86 m_PlanarFigureCoordinate0 (0),
87 m_PlanarFigureCoordinate1 (0),
88 m_HistogramBinSize(1.0),
89 m_UseDefaultBinSize(
true),
90 m_UseBinSizeBasedOnVOIRegion(
false),
91 m_HotspotRadiusInMM(6.2035049089940),
92 m_CalculateHotspot(
false),
93 m_HotspotRadiusInMMChanged(
false),
94 m_HotspotMustBeCompletelyInsideImage(
true)
97 m_EmptyHistogram->SetMeasurementVectorSize(1);
98 HistogramType::SizeType histogramSize(1);
99 histogramSize.Fill( 256 );
100 m_EmptyHistogram->Initialize( histogramSize );
102 m_EmptyStatistics.Reset();
119 :m_HotspotStatistics(withHotspotStatistics ? new
Statistics(false) : nullptr)
125 :m_HotspotStatistics( nullptr)
146 if (other.m_HotspotStatistics)
148 this->m_HotspotStatistics =
new Statistics(
false);
149 *this->m_HotspotStatistics = *other.m_HotspotStatistics;
155 return m_HotspotStatistics !=
nullptr;
160 m_HasHotspotStatistics = hasHotspotStatistics;
166 delete m_HotspotStatistics;
171 return this->Variance;
176 if( this->Variance != value )
180 this->Variance = 0.0;
184 this->Variance = value;
196 if( this->Sigma != value )
200 if( value != value || value < 0.0 )
226 SetUniformity( 0.0 );
231 vnl_vector<int> zero;
232 zero.set_size(dimension);
233 for(
unsigned int i = 0; i < dimension; ++i)
240 SetHotspotIndex(zero);
242 if (m_HotspotStatistics !=
nullptr)
244 m_HotspotStatistics->Reset(dimension);
251 if (m_HotspotStatistics)
253 return *m_HotspotStatistics;
257 throw std::logic_error(
"Object has no hostspot statistics, see HasHotspotStatistics()");
264 if (m_HotspotStatistics)
266 return *m_HotspotStatistics;
270 throw std::logic_error(
"Object has no hostspot statistics, see HasHotspotStatistics()");
281 this->SetN( other.
GetN() );
282 this->SetMin( other.
GetMin() );
283 this->SetMax( other.
GetMax() );
284 this->SetMean( other.
GetMean() );
288 this->SetRMS( other.
GetRMS() );
296 this->SetUPP( other.
GetUPP() );
297 this->SetMPP( other.
GetMPP() );
300 delete this->m_HotspotStatistics;
301 this->m_HotspotStatistics =
nullptr;
303 if (other.m_HotspotStatistics)
305 this->m_HotspotStatistics =
new Statistics(
false);
306 *this->m_HotspotStatistics = *other.m_HotspotStatistics;
315 if ( m_Image != image )
338 for (
unsigned int t = 0; t < image->
GetTimeSteps(); ++t )
349 if ( m_Image.IsNull() )
351 itkExceptionMacro( <<
"Image needs to be set first!" );
359 for (
unsigned int t = 0; t < m_Image->GetTimeSteps(); ++t )
370 if ( m_Image.IsNull() )
372 itkExceptionMacro( <<
"Image needs to be set first!" );
380 for (
unsigned int t = 0; t < m_Image->GetTimeSteps(); ++t )
514 MITK_WARN <<
"Hotspot calculation will extrapolate pixels at image borders. Be aware of the consequences for the hotspot location.";
525 template <
typename TPixel,
unsigned int VImageDimension >
527 double &
max,
int &counter,
double &sigma,
528 const itk::Image< TPixel, VImageDimension > *InputImage,
529 itk::Image< unsigned short, VImageDimension > *MaskedImage )
531 typedef itk::Image< unsigned short, VImageDimension >
MaskImageType;
532 typedef itk::Image< TPixel, VImageDimension >
ImageType;
534 typedef itk::ImageRegionConstIteratorWithIndex<ImageType> Imageie;
535 typedef itk::ImageRegionConstIteratorWithIndex<MaskImageType> Imageie2;
537 Imageie2 labelIterator2( MaskedImage, MaskedImage->GetRequestedRegion() );
538 Imageie labelIterator3( InputImage, InputImage->GetRequestedRegion() );
544 double SumOfSquares = 0;
545 double sumSquared = 0;
547 double actualPielValue = 0;
548 int counterOfPixelsInROI = 0;
551 for( labelIterator2.GoToBegin(); !labelIterator2.IsAtEnd(); ++labelIterator2, ++labelIterator3)
553 if( labelIterator2.Value()== 1.0)
557 counterOfPixelsInROI++;
558 actualPielValue = labelIterator3.Value();
560 sumSquared = sumSquared + actualPielValue;
561 SumOfSquares = SumOfSquares + std::pow(actualPielValue,2);
563 if(counterOfPixelsInROI == 1)
565 max = actualPielValue;
566 min = actualPielValue;
569 if(actualPielValue >= max)
571 max = actualPielValue;
573 else if(actualPielValue <= min)
575 min = actualPielValue;
583 sigma = ( SumOfSquares - std::pow( sumSquared, 2) / counter ) / ( counter-1 );
596 if (m_Image.IsNull() )
601 if (!m_Image->IsInitialized())
606 if ( m_Image->GetReferenceCount() == 1 )
612 if ( timeStep >= m_Image->GetTimeSteps() )
614 throw std::runtime_error(
"Error: invalid time step!" );
707 InternalCalculateStatisticsUnmasked,
710 histogramContainer );
716 InternalCalculateStatisticsMasked,
720 histogramContainer );
729 InternalCalculateStatisticsUnmasked,
732 histogramContainer );
738 InternalCalculateStatisticsMasked,
742 histogramContainer );
747 MITK_ERROR <<
"ImageStatistics: Image dimension not supported!";
768 std::map<int, double> returnedHistogramMap;
770 unsigned int size = binsAndFrequencyToCalculate->Size();
771 for(
unsigned int bin=0; bin < size; ++bin )
773 double frequency = binsAndFrequencyToCalculate->GetFrequency( bin, 0 );
776 returnedHistogramMap.insert( std::pair<int, double>(binsAndFrequencyToCalculate->GetMeasurement( bin, 0 ), binsAndFrequencyToCalculate->GetFrequency( bin, 0 ) ) );
780 return returnedHistogramMap;
786 if ( m_Image.IsNull() || (timeStep >= m_Image->GetTimeSteps()) )
813 if ( m_Image.IsNull() || (timeStep >= m_Image->GetTimeSteps()) )
841 if ( m_Image.IsNull() || (timeStep >= m_Image->GetTimeSteps()) )
867 if ( m_Image.IsNull() || (timeStep >= m_Image->GetTimeSteps()) )
894 if ( m_Image.IsNull() )
896 throw std::runtime_error(
"Error: image empty!" );
899 if ( timeStep >= m_Image->GetTimeSteps() )
901 throw std::runtime_error(
"Error: invalid time step!" );
905 imageTimeSelector->SetInput( m_Image );
906 imageTimeSelector->SetTimeNr( timeStep );
907 imageTimeSelector->UpdateLargestPossibleRegion();
908 mitk::Image *timeSliceImage = imageTimeSelector->GetOutput();
959 maskedImageTimeSelector->SetTimeNr( timeStep );
960 maskedImageTimeSelector->UpdateLargestPossibleRegion();
961 mitk::Image *timeSliceMaskedImage = maskedImageTimeSelector->GetOutput();
968 throw std::runtime_error(
"Error: image mask empty!" );
978 throw std::runtime_error(
"Error: planar figure empty!" );
982 throw std::runtime_error(
"Masking not possible for non-closed figures" );
986 if ( imageGeometry ==
nullptr )
988 throw std::runtime_error(
"Image geometry invalid!" );
992 if ( planarFigurePlaneGeometry ==
nullptr )
994 throw std::runtime_error(
"Planar-Figure not yet initialized!" );
998 dynamic_cast< const PlaneGeometry *
>( planarFigurePlaneGeometry );
999 if ( planarFigureGeometry ==
nullptr )
1001 throw std::runtime_error(
"Non-planar planar figures not supported!" );
1007 planarFigureGeometry->
GetNormal(), axis ) )
1009 throw std::runtime_error(
"Non-aligned planar figures not supported!" );
1014 MaskImage3DType::IndexType index;
1017 unsigned int slice = index[axis];
1022 unsigned int dimension = timeSliceImage->
GetDimension();
1027 imageExtractor->SetInput( timeSliceImage );
1028 imageExtractor->SetSliceDimension( axis );
1029 imageExtractor->SetSliceIndex( slice );
1030 imageExtractor->Update();
1070 unsigned int &axis )
1073 for (
unsigned int i = 0; i < 3; ++i )
1076 axisVector.Normalize();
1078 if ( fabs( fabs( axisVector * vector ) - 1.0) <
mitk::eps )
1095 template <
typename TPixel,
unsigned int VImageDimension >
1096 void ImageStatisticsCalculator::InternalCalculateStatisticsUnmasked(
1097 const itk::Image< TPixel, VImageDimension > *image,
1101 typedef itk::Image< TPixel, VImageDimension >
ImageType;
1102 typedef typename ImageType::IndexType IndexType;
1104 typedef itk::Statistics::ScalarImageToHistogramGenerator< ImageType >
1105 HistogramGeneratorType;
1107 statisticsContainer->clear();
1108 histogramContainer->clear();
1111 typedef itk::SimpleMemberCommand< ImageStatisticsCalculator > ITKCommandType;
1114 progressListener->SetCallbackFunction(
this,
1120 this->InvokeEvent( itk::StartEvent() );
1121 for (
unsigned int i = 0; i < 100; ++i )
1129 statisticsFilter->SetInput( image );
1130 statisticsFilter->SetBinSize( 100 );
1131 statisticsFilter->SetCoordinateTolerance( 0.001 );
1132 statisticsFilter->SetDirectionTolerance( 0.001 );
1134 unsigned long observerTag = statisticsFilter->AddObserver( itk::ProgressEvent(), progressListener );
1137 statisticsFilter->Update();
1139 catch (
const itk::ExceptionObject& e)
1141 mitkThrow() <<
"Image statistics calculation failed due to following ITK Exception: \n " << e.what();
1143 catch(
const std::exception& e )
1148 statisticsFilter->RemoveObserver( observerTag );
1149 this->InvokeEvent( itk::EndEvent() );
1152 typedef itk::MinimumMaximumImageCalculator< ImageType > MinMaxFilterType;
1154 minMaxFilter->SetImage( image );
1155 unsigned long observerTag2 = minMaxFilter->AddObserver( itk::ProgressEvent(), progressListener );
1156 minMaxFilter->Compute();
1157 minMaxFilter->RemoveObserver( observerTag2 );
1158 this->InvokeEvent( itk::EndEvent() );
1163 statistics.
SetN(image->GetBufferedRegion().GetNumberOfPixels());
1164 statistics.
SetMin(statisticsFilter->GetMinimum());
1165 statistics.
SetMax(statisticsFilter->GetMaximum());
1166 statistics.
SetMean(statisticsFilter->GetMean());
1167 statistics.
SetMedian(statisticsFilter->GetMedian());
1168 statistics.
SetVariance(statisticsFilter->GetVariance());
1169 statistics.
SetSkewness(statisticsFilter->GetSkewness());
1170 statistics.
SetKurtosis(statisticsFilter->GetKurtosis());
1171 statistics.
SetUniformity( statisticsFilter->GetUniformity());
1172 statistics.
SetEntropy( statisticsFilter->GetEntropy());
1173 statistics.
SetUPP( statisticsFilter->GetUPP());
1174 statistics.
SetMPP( statisticsFilter->GetMPP());
1175 statistics.
SetSigma(statisticsFilter->GetSigma());
1178 statistics.
GetMinIndex().set_size(image->GetImageDimension());
1179 statistics.
GetMaxIndex().set_size(image->GetImageDimension());
1181 vnl_vector<int> tmpMaxIndex;
1182 vnl_vector<int> tmpMinIndex;
1184 tmpMaxIndex.set_size(image->GetImageDimension() );
1185 tmpMinIndex.set_size(image->GetImageDimension() );
1187 for (
unsigned int i=0; i<statistics.
GetMaxIndex().size(); i++)
1189 tmpMaxIndex[i] = minMaxFilter->GetIndexOfMaximum()[i];
1190 tmpMinIndex[i] = minMaxFilter->GetIndexOfMinimum()[i];
1198 typedef itk::Image< unsigned short, VImageDimension >
MaskImageType;
1200 bool isHotspotDefined(
false);
1202 if (isHotspotDefined)
1214 MITK_DEBUG <<
"Hotspot statistics available";
1219 MITK_ERROR <<
"No hotspot statistics available!";
1223 statisticsContainer->push_back( statistics );
1227 unsigned int numberOfBins = 200;
1234 numberOfBins = calcNumberOfBins(statistics.
GetMin(), statistics.
GetMax());
1237 histogramGenerator->SetInput( image );
1238 histogramGenerator->SetMarginalScale( 100 );
1239 histogramGenerator->SetNumberOfBins( numberOfBins );
1240 histogramGenerator->SetHistogramMin( statistics.
GetMin() );
1241 histogramGenerator->SetHistogramMax( statistics.
GetMax() );
1242 histogramGenerator->Compute();
1243 histogramContainer->push_back( histogramGenerator->GetOutput() );
1246 template <
typename TPixel,
unsigned int VImageDimension >
1248 const itk::Image< TPixel, VImageDimension > *image,
1249 itk::Image< unsigned short, VImageDimension > *maskImage )
1251 typedef itk::Image< TPixel, VImageDimension >
ImageType;
1252 typedef itk::Image< unsigned short, VImageDimension >
MaskImageType;
1254 itk::ImageRegionIterator<MaskImageType>
1255 itmask(maskImage, maskImage->GetLargestPossibleRegion());
1256 itk::ImageRegionConstIterator<ImageType>
1257 itimage(image, image->GetLargestPossibleRegion());
1260 itimage.GoToBegin();
1262 while( !itmask.IsAtEnd() )
1274 template <
typename TPixel,
unsigned int VImageDimension >
1275 void ImageStatisticsCalculator::InternalCalculateStatisticsMasked(
1276 const itk::Image< TPixel, VImageDimension > *image,
1277 itk::Image< unsigned short, VImageDimension > *maskImage,
1281 typedef itk::Image< TPixel, VImageDimension >
ImageType;
1282 typedef itk::Image< unsigned short, VImageDimension >
MaskImageType;
1283 typedef typename ImageType::IndexType IndexType;
1285 typedef typename ImageType::SpacingType SpacingType;
1288 typedef itk::ChangeInformationImageFilter< MaskImageType > ChangeInformationFilterType;
1289 typedef itk::ExtractImageFilter< ImageType, ImageType > ExtractImageFilterType;
1291 statisticsContainer->clear();
1292 histogramContainer->clear();
1295 if ( maskImage ==
nullptr )
1297 itkExceptionMacro( <<
"Mask image needs to be set!" );
1309 typedef typename ImageType::DirectionType DirectionType;
1310 DirectionType imageDirection = image->GetDirection();
1311 DirectionType maskDirection = maskImage->GetDirection();
1312 for(
int i = 0; i < imageDirection.ColumnDimensions; ++i )
1314 for(
int j = 0; j < imageDirection.ColumnDimensions; ++j )
1316 double differenceDirection = imageDirection[i][j] - maskDirection[i][j];
1317 if ( fabs( differenceDirection ) >
mitk::eps )
1319 double differenceDirection = imageDirection[i][j] - maskDirection[i][j];
1320 if ( fabs( differenceDirection ) > 0.001 )
1322 itkExceptionMacro( <<
"Mask needs to have same direction as image! (Image direction: " << imageDirection <<
"; Mask direction: " << maskDirection <<
")" );
1328 PointType imageOrigin = image->GetOrigin();
1329 PointType maskOrigin = maskImage->GetOrigin();
1330 long offset[ImageType::ImageDimension];
1332 typedef itk::ContinuousIndex<double, VImageDimension> ContinousIndexType;
1333 ContinousIndexType maskOriginContinousIndex, imageOriginContinousIndex;
1335 image->TransformPhysicalPointToContinuousIndex(maskOrigin, maskOriginContinousIndex);
1336 image->TransformPhysicalPointToContinuousIndex(imageOrigin, imageOriginContinousIndex);
1338 for (
unsigned int i = 0; i < ImageType::ImageDimension; ++i )
1340 double misalignment = maskOriginContinousIndex[i] - floor( maskOriginContinousIndex[i] + 0.5 );
1343 itkWarningMacro( <<
"Pixels/voxels of mask and image are not sufficiently aligned! (Misalignment: " << misalignment <<
")" );
1346 double indexCoordDistance = maskOriginContinousIndex[i] - imageOriginContinousIndex[i];
1347 offset[i] = int( indexCoordDistance + image->GetBufferedRegion().GetIndex()[i] + 0.5 );
1353 adaptMaskFilter->ChangeOriginOn();
1354 adaptMaskFilter->ChangeRegionOn();
1355 adaptMaskFilter->SetInput( maskImage );
1356 adaptMaskFilter->SetOutputOrigin( image->GetOrigin() );
1357 adaptMaskFilter->SetOutputOffset( offset );
1358 adaptMaskFilter->SetCoordinateTolerance( 0.001 );
1359 adaptMaskFilter->SetDirectionTolerance( 0.001 );
1365 adaptMaskFilter->Update();
1366 adaptedMaskImage = adaptMaskFilter->GetOutput();
1368 catch(
const itk::ExceptionObject &e)
1370 mitkThrow() <<
"Attempt to adapt shifted origin of the mask image failed due to ITK Exception: \n" << e.what();
1372 catch(
const std::exception& e )
1379 if ( adaptedMaskImage.IsNotNull() &&
1380 !image->GetLargestPossibleRegion().IsInside( adaptedMaskImage->GetLargestPossibleRegion() ) )
1382 itkWarningMacro( <<
"Mask region needs to be inside of image region! (Image region: "
1383 << image->GetLargestPossibleRegion() <<
"; Mask region: " << adaptedMaskImage->GetLargestPossibleRegion() <<
")" );
1388 typename ImageType::SizeType imageSize = image->GetBufferedRegion().GetSize();
1389 typename ImageType::SizeType maskSize = maskImage->GetBufferedRegion().GetSize();
1390 bool maskSmallerImage =
false;
1391 for (
unsigned int i = 0; i < ImageType::ImageDimension; ++i )
1393 if ( maskSize[i] < imageSize[i] )
1395 maskSmallerImage =
true;
1400 if ( maskSmallerImage )
1403 extractImageFilter->SetInput( image );
1404 extractImageFilter->SetExtractionRegion( adaptedMaskImage->GetBufferedRegion() );
1405 extractImageFilter->SetCoordinateTolerance( 0.001 );
1406 extractImageFilter->SetDirectionTolerance( 0.001 );
1407 extractImageFilter->Update();
1408 adaptedImage = extractImageFilter->GetOutput();
1412 adaptedImage = image;
1416 typedef itk::StatisticsImageFilter< ImageType > StatisticsFilterType;
1418 statisticsFilter->SetInput( adaptedImage );
1422 statisticsFilter->Update();
1424 catch(
const itk::ExceptionObject& e)
1426 mitkThrow() <<
"Image statistics initialization computation failed with ITK Exception: \n " << e.what();
1428 catch(
const std::exception& e )
1435 double maximum = 0.0;
1436 double minimum = 0.0;
1440 maximum = statisticsFilter->GetMaximum();
1441 minimum = statisticsFilter->GetMinimum();
1445 m_HistogramBinSize = std::ceil( static_cast<double>((statisticsFilter->GetMaximum() - statisticsFilter->GetMinimum() + 1)/numberOfBins) );
1449 numberOfBins = calcNumberOfBins(statisticsFilter->GetMinimum(), statisticsFilter->GetMaximum());
1468 labelStatisticsFilter->SetInput( adaptedImage );
1469 labelStatisticsFilter->SetLabelInput( adaptedMaskImage );
1470 labelStatisticsFilter->SetCoordinateTolerance( 0.001 );
1471 labelStatisticsFilter->SetDirectionTolerance( 0.001 );
1472 labelStatisticsFilter->UseHistogramsOn();
1473 labelStatisticsFilter->SetHistogramParameters( numberOfBins, floor(minimum), ceil(maximum) );
1476 typedef itk::SimpleMemberCommand< ImageStatisticsCalculator > ITKCommandType;
1479 progressListener->SetCallbackFunction(
this,
1481 unsigned long observerTag = labelStatisticsFilter->AddObserver(
1482 itk::ProgressEvent(), progressListener );
1485 this->InvokeEvent( itk::StartEvent() );
1489 labelStatisticsFilter->GetOutput()->SetRequestedRegion( adaptedMaskImage->GetLargestPossibleRegion() );
1494 labelStatisticsFilter->Update();
1496 catch(
const itk::ExceptionObject& e)
1498 mitkThrow() <<
"Image statistics calculation failed due to following ITK Exception: \n " << e.what();
1500 catch(
const std::exception& e )
1505 this->InvokeEvent( itk::EndEvent() );
1508 labelStatisticsFilter->RemoveObserver( observerTag );
1511 std::list< int > relevantLabels = labelStatisticsFilter->GetRelevantLabels();
1514 if ( labelStatisticsFilter->GetMaskingNonEmpty() )
1516 std::list< int >::iterator it;
1517 for ( it = relevantLabels.begin(), i = 0;
1518 it != relevantLabels.end();
1522 labelStatisticsFilter->GetHistogram(*it) ;
1526 statistics.
SetN(labelStatisticsFilter->GetCount( *it ));
1527 statistics.
SetMin(labelStatisticsFilter->GetMinimum( *it ));
1528 statistics.
SetMax(labelStatisticsFilter->GetMaximum( *it ));
1529 statistics.
SetMean(labelStatisticsFilter->GetMean( *it ));
1530 statistics.
SetMedian(labelStatisticsFilter->GetMedian( *it));
1531 statistics.
SetMedian(labelStatisticsFilter->GetMedian( *it ));
1532 statistics.
SetVariance(labelStatisticsFilter->GetVariance( *it ));
1533 statistics.
SetSigma(labelStatisticsFilter->GetSigma( *it ));
1534 statistics.
SetSkewness(labelStatisticsFilter->GetSkewness( *it ));
1535 statistics.
SetKurtosis(labelStatisticsFilter->GetKurtosis( *it ));
1536 statistics.
SetUniformity( labelStatisticsFilter->GetUniformity( *it ));
1537 statistics.
SetEntropy( labelStatisticsFilter->GetEntropy( *it ));
1538 statistics.
SetUPP( labelStatisticsFilter->GetUPP( *it));
1539 statistics.
SetMPP( labelStatisticsFilter->GetMPP( *it));
1544 typedef itk::MaskImageFilter< ImageType, MaskImageType, ImageType > MaskImageFilterType;
1546 bool isMinAndMaxSameValue = (statistics.
GetMin() == statistics.
GetMax());
1548 double outsideValue = (isMinAndMaxSameValue ? (statistics.
GetMax()/2) : (statistics.
GetMin()+statistics.
GetMax())/2);
1549 masker->SetOutsideValue( outsideValue );
1550 masker->SetInput1(adaptedImage);
1551 masker->SetInput2(adaptedMaskImage);
1552 masker->SetCoordinateTolerance( 0.001 );
1553 masker->SetDirectionTolerance( 0.001 );
1556 typedef itk::MinimumMaximumImageCalculator< ImageType > MinMaxFilterType;
1558 minMaxFilter->SetImage( masker->GetOutput() );
1559 unsigned long observerTag2 = minMaxFilter->AddObserver( itk::ProgressEvent(), progressListener );
1560 minMaxFilter->Compute();
1561 minMaxFilter->RemoveObserver( observerTag2 );
1562 this->InvokeEvent( itk::EndEvent() );
1564 typename MinMaxFilterType::IndexType tempMaxIndex = minMaxFilter->GetIndexOfMaximum();
1566 typename MinMaxFilterType::IndexType tempMinIndex =
1567 (isMinAndMaxSameValue ? minMaxFilter->GetIndexOfMaximum() : minMaxFilter->GetIndexOfMinimum());
1574 vnl_vector<int> maxIndex;
1575 vnl_vector<int> minIndex;
1576 maxIndex.set_size(m_Image->GetDimension());
1577 minIndex.set_size(m_Image->GetDimension());
1590 for (
unsigned int i = 0; i<maxIndex.size(); i++)
1592 maxIndex[i] = tempMaxIndex[i];
1593 minIndex[i] = tempMinIndex[i];
1603 bool isDefined(
false);
1608 MITK_DEBUG <<
"Hotspot statistics available";
1613 MITK_ERROR <<
"No hotspot statistics available!";
1616 statisticsContainer->push_back( statistics );
1622 statisticsContainer->push_back(
Statistics() );
1627 template <
typename TPixel,
unsigned int VImageDimension >
1630 const itk::Image<TPixel, VImageDimension> *inputImage,
1631 itk::Image<unsigned short, VImageDimension> *maskImage,
1632 double neccessaryDistanceToImageBorderInMM,
1635 typedef itk::Image< TPixel, VImageDimension >
ImageType;
1636 typedef itk::Image< unsigned short, VImageDimension >
MaskImageType;
1638 typedef itk::ImageRegionConstIteratorWithIndex<MaskImageType> MaskImageIteratorType;
1639 typedef itk::ImageRegionConstIteratorWithIndex<ImageType> InputImageIndexIteratorType;
1641 typename ImageType::SpacingType spacing = inputImage->GetSpacing();
1645 minMax.
MaxIndex.set_size(VImageDimension);
1646 minMax.
MaxIndex.set_size(VImageDimension);
1648 typename ImageType::RegionType allowedExtremaRegion = inputImage->GetLargestPossibleRegion();
1650 bool keepDistanceToImageBorders( neccessaryDistanceToImageBorderInMM > 0 );
1651 if (keepDistanceToImageBorders)
1653 long distanceInPixels[VImageDimension];
1654 for(
unsigned short dimension = 0; dimension < VImageDimension; ++dimension)
1660 distanceInPixels[dimension] = int( neccessaryDistanceToImageBorderInMM / spacing[dimension] + 0.5);
1663 allowedExtremaRegion.ShrinkByRadius(distanceInPixels);
1666 InputImageIndexIteratorType imageIndexIt(inputImage, allowedExtremaRegion);
1671 typename ImageType::IndexType maxIndex;
1672 typename ImageType::IndexType minIndex;
1674 for(
unsigned short i = 0; i < VImageDimension; ++i)
1680 if (maskImage !=
nullptr)
1682 MaskImageIteratorType maskIt(maskImage, maskImage->GetLargestPossibleRegion());
1683 typename ImageType::IndexType imageIndex;
1685 typename ImageType::IndexType maskIndex;
1687 for(maskIt.GoToBegin(); !maskIt.IsAtEnd(); ++maskIt)
1689 imageIndex = maskIndex = maskIt.GetIndex();
1691 if(maskIt.Get() == label)
1693 if( allowedExtremaRegion.IsInside(imageIndex) )
1695 imageIndexIt.SetIndex( imageIndex );
1696 double value = imageIndexIt.Get();
1700 if( value > maxValue )
1702 maxIndex = imageIndexIt.GetIndex();
1706 if(value < minValue )
1708 minIndex = imageIndexIt.GetIndex();
1717 for(imageIndexIt.GoToBegin(); !imageIndexIt.IsAtEnd(); ++imageIndexIt)
1719 double value = imageIndexIt.Get();
1723 if( value > maxValue )
1725 maxIndex = imageIndexIt.GetIndex();
1729 if(value < minValue )
1731 minIndex = imageIndexIt.GetIndex();
1737 minMax.
MaxIndex.set_size(VImageDimension);
1738 minMax.
MinIndex.set_size(VImageDimension);
1740 for(
unsigned int i = 0; i < minMax.
MaxIndex.size(); ++i)
1745 for(
unsigned int i = 0; i < minMax.
MinIndex.size(); ++i)
1750 minMax.
Max = maxValue;
1751 minMax.
Min = minValue;
1756 template <
unsigned int VImageDimension>
1757 itk::Size<VImageDimension>
1761 typedef itk::Image< float, VImageDimension > KernelImageType;
1762 typedef typename KernelImageType::SizeType SizeType;
1765 for(
unsigned int i = 0; i < VImageDimension; ++i)
1767 maskSize[i] =
static_cast<int>( 2 * radiusInMM / spacing[i]);
1770 if(maskSize[i] % 2 == 0 )
1778 template <
unsigned int VImageDimension>
1783 std::stringstream ss;
1784 for (
unsigned int i = 0; i < VImageDimension; ++i)
1786 ss << mmPerPixel[i];
1787 if (i < VImageDimension -1)
1790 MITK_DEBUG <<
"Update convolution kernel for spacing (" << ss.str() <<
") and radius " << radiusInMM <<
"mm";
1793 double radiusInMMSquared = radiusInMM * radiusInMM;
1794 typedef itk::Image< float, VImageDimension > KernelImageType;
1798 typedef typename KernelImageType::SizeType SizeType;
1799 SizeType maskSize = this->CalculateConvolutionKernelSize<VImageDimension>(mmPerPixel, radiusInMM);
1801 Point3D convolutionMaskCenterIndex; convolutionMaskCenterIndex.Fill(0.0);
1802 for(
unsigned int i = 0; i < VImageDimension; ++i)
1804 convolutionMaskCenterIndex[i] = 0.5 * (double)(maskSize[i]-1);
1807 typedef typename KernelImageType::IndexType IndexType;
1808 IndexType maskIndex;
1811 typedef typename KernelImageType::RegionType RegionType;
1812 RegionType maskRegion;
1813 maskRegion.SetSize(maskSize);
1814 maskRegion.SetIndex(maskIndex);
1816 convolutionKernel->SetRegions(maskRegion);
1817 convolutionKernel->SetSpacing(mmPerPixel);
1818 convolutionKernel->Allocate();
1821 typedef itk::ImageRegionIteratorWithIndex<KernelImageType> MaskIteratorType;
1822 MaskIteratorType maskIt(convolutionKernel,maskRegion);
1824 int numberOfSubVoxelsPerDimension = 2;
1825 int numberOfSubVoxels = ::pow( static_cast<float>(numberOfSubVoxelsPerDimension), static_cast<float>(VImageDimension) );
1826 double subVoxelSizeInPixels = 1.0 / (double)numberOfSubVoxelsPerDimension;
1827 double valueOfOneSubVoxel = 1.0 / (double)numberOfSubVoxels;
1828 double maskValue = 0.0;
1829 Point3D subVoxelIndexPosition;
1830 double distanceSquared = 0.0;
1832 typedef itk::ContinuousIndex<double, VImageDimension> ContinuousIndexType;
1833 for(maskIt.GoToBegin(); !maskIt.IsAtEnd(); ++maskIt)
1835 ContinuousIndexType indexPoint(maskIt.GetIndex());
1837 for (
unsigned int dimension = 0; dimension < VImageDimension; ++dimension)
1839 voxelPosition[dimension] = indexPoint[dimension];
1843 Vector3D subVoxelOffset; subVoxelOffset.Fill(0.0);
1845 for (subVoxelOffset[0] = -0.5 + subVoxelSizeInPixels / 2.0;
1846 subVoxelOffset[0] < +0.5;
1847 subVoxelOffset[0] += subVoxelSizeInPixels)
1849 for (subVoxelOffset[1] = -0.5 + subVoxelSizeInPixels / 2.0;
1850 subVoxelOffset[1] < +0.5;
1851 subVoxelOffset[1] += subVoxelSizeInPixels)
1853 for (subVoxelOffset[2] = -0.5 + subVoxelSizeInPixels / 2.0;
1854 subVoxelOffset[2] < +0.5;
1855 subVoxelOffset[2] += subVoxelSizeInPixels)
1857 subVoxelIndexPosition = voxelPosition + subVoxelOffset;
1859 (subVoxelIndexPosition[0]-convolutionMaskCenterIndex[0]) * mmPerPixel[0] * (subVoxelIndexPosition[0]-convolutionMaskCenterIndex[0]) * mmPerPixel[0]
1860 + (subVoxelIndexPosition[1]-convolutionMaskCenterIndex[1]) * mmPerPixel[1] * (subVoxelIndexPosition[1]-convolutionMaskCenterIndex[1]) * mmPerPixel[1]
1861 + (subVoxelIndexPosition[2]-convolutionMaskCenterIndex[2]) * mmPerPixel[2] * (subVoxelIndexPosition[2]-convolutionMaskCenterIndex[2]) * mmPerPixel[2];
1863 if (distanceSquared <= radiusInMMSquared)
1865 maskValue += valueOfOneSubVoxel;
1870 maskIt.Set( maskValue );
1873 return convolutionKernel;
1876 template <
typename TPixel,
unsigned int VImageDimension>
1880 double mmPerPixel[VImageDimension];
1881 for (
unsigned int dimension = 0; dimension < VImageDimension; ++dimension)
1883 mmPerPixel[dimension] = inputImage->GetSpacing()[dimension];
1887 typedef itk::Image< float, VImageDimension > KernelImageType;
1892 typedef itk::Image< TPixel, VImageDimension > ConvolutionImageType;
1895 ConvolutionImageType> ConvolutionFilterType;
1898 typedef itk::ConstantBoundaryCondition<InputImageType, InputImageType> BoundaryConditionType;
1899 BoundaryConditionType boundaryCondition;
1900 boundaryCondition.SetConstant(0.0);
1905 convolutionFilter->SetBoundaryCondition(&boundaryCondition);
1908 convolutionFilter->SetInput(inputImage);
1909 convolutionFilter->SetKernelImage(convolutionKernel);
1910 convolutionFilter->SetNormalize(
true);
1911 MITK_DEBUG <<
"Update Convolution image for hotspot search";
1912 convolutionFilter->UpdateLargestPossibleRegion();
1915 convolutionImage->SetSpacing( inputImage->GetSpacing() );
1918 return convolutionImage;
1921 template <
typename TPixel,
unsigned int VImageDimension>
1925 itk::Point<double, VImageDimension> sphereCenter,
1926 double sphereRadiusInMM)
1928 typedef itk::Image< TPixel, VImageDimension >
MaskImageType;
1929 typedef itk::ImageRegionIteratorWithIndex<MaskImageType> MaskImageIteratorType;
1931 MaskImageIteratorType maskIt(maskImage, maskImage->GetLargestPossibleRegion());
1933 typename MaskImageType::IndexType maskIndex;
1936 for(maskIt.GoToBegin(); !maskIt.IsAtEnd(); ++maskIt)
1938 maskIndex = maskIt.GetIndex();
1939 maskImage->TransformIndexToPhysicalPoint(maskIndex, worldPosition);
1940 maskIt.Set( worldPosition.EuclideanDistanceTo(sphereCenter) <= sphereRadiusInMM ? 1 : 0 );
1944 template <
typename TPixel,
unsigned int VImageDimension>
1947 const itk::Image<TPixel, VImageDimension>* inputImage,
1948 itk::Image<unsigned short, VImageDimension>* maskImage,
1950 bool& isHotspotDefined,
1955 typedef itk::Image< TPixel, VImageDimension > ConvolutionImageType;
1956 typedef itk::Image< float, VImageDimension > KernelImageType;
1957 typedef itk::Image< unsigned short, VImageDimension >
MaskImageType;
1962 if (convolutionImage.IsNull())
1964 MITK_ERROR <<
"Empty convolution image in CalculateHotspotStatistics(). We should never reach this state (logic error).";
1965 throw std::logic_error(
"Empty convolution image in CalculateHotspotStatistics()");
1972 isHotspotDefined = convolutionImageInformation.
Defined;
1974 if (!isHotspotDefined)
1977 MITK_ERROR <<
"No origin of hotspot-sphere was calculated! Returning empty statistics";
1983 typedef itk::ImageDuplicator< InputImageType > DuplicatorType;
1985 copyMachine->SetInputImage(inputImage);
1986 copyMachine->Update();
1988 typedef itk::CastImageFilter< InputImageType, MaskImageType > CastFilterType;
1990 caster->SetInput( copyMachine->GetOutput() );
1994 typedef typename InputImageType::IndexType IndexType;
1995 IndexType maskCenterIndex;
1996 for (
unsigned int d =0; d< VImageDimension;++d) maskCenterIndex[d]=convolutionImageInformation.
MaxIndex[d];
1998 inputImage->TransformIndexToPhysicalPoint(maskCenterIndex,maskCenter);
2006 labelStatisticsFilter->SetInput( inputImage );
2007 labelStatisticsFilter->SetLabelInput( hotspotMaskITK );
2008 labelStatisticsFilter->SetCoordinateTolerance( 0.001 );
2009 labelStatisticsFilter->SetDirectionTolerance( 0.001 );
2011 labelStatisticsFilter->Update();
2015 hotspotStatistics.
SetMean(convolutionImageInformation.
Max);
2017 if ( labelStatisticsFilter->HasLabel( 1 ) )
2020 hotspotStatistics.
SetN(labelStatisticsFilter->GetCount(1));
2021 hotspotStatistics.
SetMin(labelStatisticsFilter->GetMinimum(1));
2022 hotspotStatistics.
SetMax(labelStatisticsFilter->GetMaximum(1));
2023 hotspotStatistics.
SetMedian(labelStatisticsFilter->GetMedian(1));
2024 hotspotStatistics.
SetVariance(labelStatisticsFilter->GetVariance(1));
2025 hotspotStatistics.
SetSigma(labelStatisticsFilter->GetSigma(1));
2029 MITK_DEBUG <<
"Statistics for inside hotspot: Mean " << hotspotStatistics.
GetMean()
2030 <<
", SD " << hotspotStatistics.
GetSigma()
2031 <<
", Max " << hotspotStatistics.
GetMax()
2032 <<
", Min " << hotspotStatistics.
GetMin();
2036 MITK_ERROR <<
"Uh oh! Unable to calculate statistics for hotspot region...";
2040 return hotspotStatistics;
2044 template <
typename TPixel,
unsigned int VImageDimension >
2046 const itk::Image< TPixel, VImageDimension > *image,
unsigned int axis )
2048 typedef itk::Image< TPixel, VImageDimension >
ImageType;
2050 typedef itk::CastImageFilter< ImageType, MaskImage2DType > CastFilterType;
2055 castFilter->SetInput( image );
2056 castFilter->Update();
2057 castFilter->GetOutput()->FillBuffer( 1 );
2097 bool outOfBounds =
false;
2099 typename PlanarFigure::PolyLineType::const_iterator it;
2100 for ( it = planarFigurePolyline.begin();
2101 it != planarFigurePolyline.end();
2111 planarFigurePlaneGeometry->
Map( *it, point3D );
2115 if ( !imageGeometry3D->
IsInside( point3D ) )
2123 points->InsertNextPoint( point3D[i0], point3D[i1], 0 );
2126 vtkSmartPointer<vtkPoints> holePoints =
nullptr;
2128 if (!planarFigureHolePolyline.empty())
2133 PlanarFigure::PolyLineType::const_iterator end = planarFigureHolePolyline.end();
2135 for (it = planarFigureHolePolyline.begin(); it != end; ++it)
2138 planarFigurePlaneGeometry->
Map(*it, point3D);
2140 holePoints->InsertNextPoint(point3D[i0], point3D[i1], 0);
2146 double bounds[6] = {0, 0, 0, 0, 0, 0};
2147 points->GetBounds( bounds );
2148 bool extent_x = (fabs(bounds[0] - bounds[1])) <
mitk::eps;
2149 bool extent_y = (fabs(bounds[2] - bounds[3])) <
mitk::eps;
2150 bool extent_z = (fabs(bounds[4] - bounds[5])) <
mitk::eps;
2154 ((extent_x && extent_y) || (extent_x && extent_z) || (extent_y && extent_z)))
2156 mitkThrow() <<
"Figure has a zero area and cannot be used for masking.";
2161 throw std::runtime_error(
"Figure at least partially outside of image bounds!" );
2166 lassoStencil->SetShapeToPolygon();
2167 lassoStencil->SetPoints( points );
2169 vtkSmartPointer<vtkLassoStencilSource> holeLassoStencil =
nullptr;
2171 if (holePoints.GetPointer() !=
nullptr)
2174 holeLassoStencil->SetShapeToPolygon();
2175 holeLassoStencil->SetPoints(holePoints);
2179 typedef itk::VTKImageImport< MaskImage2DType > ImageImportType;
2180 typedef itk::VTKImageExport< MaskImage2DType > ImageExportType;
2183 itkExporter->SetInput( castFilter->GetOutput() );
2190 imageStencilFilter->SetInputConnection( vtkImporter->GetOutputPort() );
2191 imageStencilFilter->SetStencilConnection(lassoStencil->GetOutputPort());
2192 imageStencilFilter->ReverseStencilOff();
2193 imageStencilFilter->SetBackgroundValue( 0 );
2194 imageStencilFilter->Update();
2196 vtkSmartPointer<vtkImageStencil> holeStencilFilter =
nullptr;
2198 if (holeLassoStencil.GetPointer() !=
nullptr)
2201 holeStencilFilter->SetInputConnection(imageStencilFilter->GetOutputPort());
2202 holeStencilFilter->SetStencilConnection(holeLassoStencil->GetOutputPort());
2203 holeStencilFilter->ReverseStencilOn();
2204 holeStencilFilter->SetBackgroundValue(0);
2205 holeStencilFilter->Update();
2210 vtkExporter->SetInputConnection( holeStencilFilter.GetPointer() ==
nullptr
2211 ? imageStencilFilter->GetOutputPort()
2212 : holeStencilFilter->GetOutputPort());
2213 vtkExporter->Update();
2217 itkImporter->Update();
2219 typedef itk::ImageDuplicator< ImageImportType::OutputImageType > DuplicatorType;
2221 duplicator->SetInputImage( itkImporter->GetOutput() );
2222 duplicator->Update();
2233 static int updateCounter = 0;
2234 if ( updateCounter++ % 2 == 0 )
2236 this->InvokeEvent( itk::ProgressEvent() );
2243 this->InvokeEvent( itk::ProgressEvent() );
double m_HistogramBinSize
const Point3D GetOrigin() const
Get the origin, e.g. the upper-left corner of the plane.
mitk::Image::ConstPointer m_InternalImage
StatisticsVector m_ImageStatisticsVector
virtual double GetMin() const
bool m_UseBinSizeBasedOnVOIRegion
double m_HotspotRadiusInMM
double m_IgnorePixelValue
itk::SmartPointer< Self > Pointer
void SetMaskingModeToNone()
Set/Get operation mode for masking.
void SetHistogramBinSize(double size)
Set bin size for histogram resolution.
Statistics CalculateHotspotStatistics(const itk::Image< TPixel, VImageDimension > *inputImage, itk::Image< unsigned short, VImageDimension > *maskImage, double radiusInMM, bool &isHotspotDefined, unsigned int label)
Calculates the hotspot statistics depending on masking mode. Hotspot statistics are calculated for a ...
Statistics m_EmptyStatistics
void SetImage(const mitk::Image *image)
Set image from which to compute statistics.
virtual void SetMax(const double _arg)
bool GetHotspotMustBeCompletlyInsideImage() const
Returns true if hotspot has to be completly inside the image.
void SetDoIgnorePixelValue(bool doit)
Set whether a pixel value should be ignored in the statistics.
vnl_vector< int > MaxIndex
virtual void SetKurtosis(const double _arg)
virtual bool Map(const mitk::Point3D &pt3d_mm, mitk::Point2D &pt2d_mm) const
Project a 3D point given in mm (pt3d_mm) onto the 2D geometry. The result is a 2D point in mm (pt2d_m...
double GetVariance() const
Extension of the itkLabelStatisticsImageFilter that also calculates the Skewness,Kurtosis,Entropy,Uniformity.
HistogramVector m_ImageHistogramVector
virtual void SetLabel(const unsigned int _arg)
bool IsHotspotCalculated()
Returns true whether the hotspot should be calculated, otherwise false.
void InternalCalculateMaskFromPlanarFigure(const itk::Image< TPixel, VImageDimension > *image, unsigned int axis)
void SetUseDefaultBinSize(bool useDefault)
Automatically calculate bin size to obtain 200 bins.
HistogramVector m_PlanarFigureHistogramVector
void SetMaskingMode(unsigned int mode)
Set/Get operation mode for masking.
void SetVariance(const double)
Set variance.
virtual double GetMedian() const
DataCollection - Class to facilitate loading/accessing structured data.
virtual void SetMPP(const double _arg)
const StatisticsContainer & GetStatisticsVector(unsigned int timeStep=0) const
Retrieve statistics depending on the current masking mode (for all image labels). ...
void SetPlanarFigure(mitk::PlanarFigure *planarFigure)
Set planar figure for masking.
bool m_UseDefaultBinSize
Bin size for histogram resoluion.
itk::SmartPointer< itk::Image< float, VImageDimension > > GenerateHotspotSearchConvolutionKernel(double spacing[VImageDimension], double radiusInMM)
Generates image of kernel which is needed for convolution.
HistogramType::Pointer m_EmptyHistogram
virtual vnl_vector< int > GetHotspotIndex() const
Class for common statistics, includig hotspot properties.
StatisticsContainer::Pointer GetStatistics(unsigned int timeStep=0, unsigned int label=1)
Returns the statistics for label label and timeStep timeStep. If these requested statistics are not c...
unsigned int m_MaskingMode
void SetCalculateHotspot(bool calculateHotspot)
Sets whether the hotspot should be calculated.
unsigned int GetTimeSteps() const
Get the number of time steps from the TimeGeometry As the base data has not a data vector given by it...
itk::Size< VImageDimension > CalculateConvolutionKernelSize(double spacing[VImageDimension], double radiusInMM)
Returns size of convolution kernel depending on spacing and radius.
virtual double GetRMS() const
bool m_MaskingModeChanged
StatisticsVector m_MaskedImageStatisticsVector
itk::Statistics::Histogram< double > HistogramType
BinFrequencyType GetBinsAndFreuqencyForHistograms(unsigned int timeStep=0, unsigned int label=0) const
TimeStampVectorType m_PlanarFigureStatisticsTimeStampVector
#define AccessFixedDimensionByItk_3(mitkImage, itkImageTypeFunction, dimension, arg1, arg2, arg3)
HistogramVector m_MaskedImageHistogramVector
void FillHotspotMaskPixels(itk::Image< TPixel, VImageDimension > *maskImage, itk::Point< double, VImageDimension > sphereCenter, double sphereRadiusInMM)
Fills pixels of the spherical hotspot mask.
Vector3D GetNormal() const
Normal of the plane.
itk::SmartPointer< const Self > ConstPointer
virtual double GetUPP() const
TimeStampVectorType m_ImageStatisticsTimeStampVector
void UnmaskedStatisticsProgressUpdate()
void SetSigma(const double)
Set standard deviation (sigma)
const Statistics & GetHotspotStatistics() const
map::core::discrete::Elements< 3 >::InternalImageType ImageType
std::vector< HistogramType::ConstPointer > HistogramContainer
bool GetPrincipalAxis(const BaseGeometry *geometry, Vector3D vector, unsigned int &axis)
If the passed vector matches any of the three principal axes of the passed geometry, the ínteger value corresponding to the axis is set and true is returned.
virtual void SetSkewness(const double _arg)
Vector3D GetAxisVector(unsigned int direction) const
Get vector along bounding-box in the specified direction in mm.
virtual double GetKurtosis() const
virtual void SetEntropy(const double _arg)
itk::Image< double, 3 > InputImageType
virtual double GetMean() const
bool m_DoIgnorePixelValue
void MaskedStatisticsProgressUpdate()
virtual ~ImageStatisticsCalculator()
#define AccessFixedDimensionByItk_2(mitkImage, itkImageTypeFunction, dimension, arg1, arg2)
virtual void SetMedian(const double _arg)
virtual void SetUniformity(const double _arg)
StatisticsVector m_PlanarFigureStatisticsVector
Container class for storing the computed image statistics.
Statistics(bool withHotspotStatistics=true)
void SetHotspotRadiusInMM(double hotspotRadiusInMM)
Sets the radius for the hotspot.
virtual void SetHotspotIndex(const vnl_vector< int > _arg)
Image class for storing images.
void SetMaskingModeToPlanarFigure()
Set/Get operation mode for masking.
void SetMaskingModeToImage()
Set/Get operation mode for masking.
itk::Image< unsigned char, 3 > MaskImageType
virtual unsigned int GetLabel() const
BoolVectorType m_ImageStatisticsCalculationTriggerVector
void Reset(unsigned int dimension=2)
bool m_HotspotRadiusInMMChanged
unsigned int m_PlanarFigureSlice
int GetComponentType() const
Get the component type (the scalar (!) type). Each element may contain m_NumberOfComponents (more tha...
const mitk::PixelType GetPixelType(int n=0) const
Returns the PixelType of channel n.
void GetMinAndMaxValue(double &minimum, double &maximum, int &counter, double &sigma, const itk::Image< TPixel, VImageDimension > *InputImage, itk::Image< unsigned short, VImageDimension > *MaskImageType)
itk::SmartPointer< itk::Image< TPixel, VImageDimension > > GenerateConvolutionImage(const itk::Image< TPixel, VImageDimension > *inputImage)
Convolves image with spherical kernel image. Used for hotspot calculation.
const HistogramType * GetHistogram(unsigned int timeStep=0, unsigned int label=0) const
Retrieve the histogram depending on the current masking mode.
MaskImage3DType::Pointer m_InternalImageMask3D
bool HasHotspotStatistics() const
void ConnectPipelines(ITK_Exporter exporter, vtkSmartPointer< VTK_Importer > importer)
virtual vnl_vector< int > GetMinIndex() const
void SetHotspotMustBeCompletlyInsideImage(bool hotspotIsCompletlyInsideImage, bool warn=true)
Sets flag whether hotspot is completly inside the image. Please note that if set to false it can be p...
mitk::Image::ConstPointer m_ImageMask
vnl_vector< int > MinIndex
unsigned int m_PlanarFigureAxis
virtual double GetUniformity() const
virtual void SetN(const unsigned int _arg)
double GetHotspotRadiusInMM()
Returns the radius of the hotspot.
virtual vnl_vector< int > GetMaxIndex() const
void SetHasHotspotStatistics(bool hasHotspotStatistics)
BoolVectorType m_MaskedImageStatisticsCalculationTriggerVector
virtual void SetMin(const double _arg)
BoolVectorType m_PlanarFigureStatisticsCalculationTriggerVector
TimeStampVectorType m_MaskedImageStatisticsTimeStampVector
#define AccessFixedDimensionByItk_1(mitkImage, itkImageTypeFunction, dimension, arg1)
bool m_HotspotMustBeCompletelyInsideImage
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
virtual unsigned int GetN() const
bool m_IgnorePixelValueChanged
Extension of the itkStatisticsImageFilter that also calculates the Skewness and Kurtosis.
virtual void SetUPP(const double _arg)
MaskImage2DType::Pointer m_InternalImageMask2D
virtual bool ComputeStatistics(unsigned int timeStep=0)
Compute statistics (together with histogram) for the current masking mode.
virtual void SetMaxIndex(const vnl_vector< int > _arg)
virtual double GetSkewness() const
MITKCORE_EXPORT const ScalarType eps
ImageStatisticsCalculator()
virtual double GetMax() const
void SetIgnorePixelValue(double value)
Set a pixel value for pixels that will be ignored in the statistics.
mitk::PlanarFigure::Pointer m_PlanarFigure
Describes a two-dimensional, rectangular plane.
virtual void SetMean(const double _arg)
bool IsInside(const mitk::Point3D &p) const
Test whether the point p (world coordinates in mm) is inside the bounding box.
int m_PlanarFigureCoordinate0
void SetImageMask(const mitk::Image *imageMask)
Set image for masking.
ImageExtrema CalculateExtremaWorld(const itk::Image< TPixel, VImageDimension > *inputImage, itk::Image< unsigned short, VImageDimension > *maskImage, double neccessaryDistanceToImageBorderInMM, unsigned int label)
Calculates minimum, maximum, mean value and their corresponding indices in a given ROI...
unsigned int GetDimension() const
Get dimension of the image.
double GetHistogramBinSize()
Get bin size for histogram resolution.
Statistics & operator=(Statistics const &stats)
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
bool GetDoIgnorePixelValue()
Get whether a pixel value will be ignored in the statistics.
StatisticsContainer m_EmptyStatisticsContainer
virtual void SetMinIndex(const vnl_vector< int > _arg)
virtual void SetRMS(const double _arg)
HistogramContainer m_EmptyHistogramContainer
const HistogramContainer & GetHistogramVector(unsigned int timeStep=0) const
Retrieve the histogram depending on the current masking mode (for all image labels.
int m_PlanarFigureCoordinate1
double GetIgnorePixelValue()
Get the pixel value for pixels that will be ignored in the statistics.
virtual double GetEntropy() const
void ExtractImageAndMask(unsigned int timeStep=0)
Depending on the masking mode, the image and mask from which to calculate statistics is extracted fro...
void InternalMaskIgnoredPixels(const itk::Image< TPixel, VImageDimension > *image, itk::Image< unsigned short, VImageDimension > *maskImage)
itk::SmartPointer< const Self > ConstPointer
BaseGeometry Describes the geometry of a data object.
virtual double GetMPP() const
std::map< int, double > BinFrequencyType
void WorldToIndex(const mitk::Point3D &pt_mm, mitk::Point3D &pt_units) const
Convert world coordinates (in mm) of a point to (continuous!) index coordinates.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.