25 #include <itkLabelStatisticsImageFilter.h>
26 #include <itkMinimumMaximumImageCalculator.h>
31 template<
typename TPixel,
unsigned int VImageDimension>
35 typedef itk::Image<TPixel, VImageDimension>
ImageType;
36 typedef itk::Image<int, VImageDimension> MaskType;
37 typedef itk::LabelStatisticsImageFilter<ImageType, MaskType> FilterType;
38 typedef typename FilterType::HistogramType HistogramType;
39 typedef typename HistogramType::IndexType HIndexType;
40 typedef itk::MinimumMaximumImageCalculator<ImageType> MinMaxComputerType;
46 minMaxComputer->SetImage(itkImage);
47 minMaxComputer->Compute();
48 double imageRange = minMaxComputer->GetMaximum() - minMaxComputer->GetMinimum();
51 labelStatisticsImageFilter->SetInput( itkImage );
52 labelStatisticsImageFilter->SetLabelInput(maskImage);
53 labelStatisticsImageFilter->SetUseHistograms(
true);
56 labelStatisticsImageFilter->SetHistogramParameters(1024.5+3096.5, -1024.5,3096.5);
58 labelStatisticsImageFilter->SetHistogramParameters(params.
m_HistogramSize, minMaxComputer->GetMinimum(),minMaxComputer->GetMaximum());
60 labelStatisticsImageFilter->Update();
63 double range = labelStatisticsImageFilter->GetMaximum(1) - labelStatisticsImageFilter->GetMinimum(1);
65 double count = labelStatisticsImageFilter->GetCount(1);
67 double uncorrected_std_dev = std::sqrt((count - 1) / count * labelStatisticsImageFilter->GetVariance(1));
68 double mean = labelStatisticsImageFilter->GetMean(1);
69 auto histogram = labelStatisticsImageFilter->GetHistogram(1);
72 double binWidth = histogram->GetBinMax(0, 0) - histogram->GetBinMin(0, 0);
74 double uniformity = 0;
76 double squared_sum = 0;
78 double mean_absolut_deviation = 0;
83 for (
int i = 0; i < (int)(histogram->GetSize(0)); ++i)
86 double prob = histogram->GetFrequency(index);
91 double voxelValue = histogram->GetBinMin(0, i) +binWidth * 0.5;
94 squared_sum += prob * voxelValue*voxelValue;
97 mean_absolut_deviation += prob* std::abs(voxelValue - mean);
99 kurtosis +=prob* (voxelValue - mean) * (voxelValue - mean) * (voxelValue - mean) * (voxelValue - mean);
100 skewness += prob* (voxelValue - mean) * (voxelValue - mean) * (voxelValue - mean);
102 uniformity += prob*prob;
105 entropy += prob * std::log(prob) / Log2;
109 double rms = std::sqrt(squared_sum / count);
110 kurtosis = kurtosis / (uncorrected_std_dev*uncorrected_std_dev * uncorrected_std_dev*uncorrected_std_dev);
111 skewness = skewness / (uncorrected_std_dev*uncorrected_std_dev * uncorrected_std_dev);
113 double coveredGrayValueRange = range / imageRange;
115 featureList.push_back(std::make_pair(
"FirstOrder Range",range));
116 featureList.push_back(std::make_pair(
"FirstOrder Uniformity",uniformity));
117 featureList.push_back(std::make_pair(
"FirstOrder Entropy",entropy));
118 featureList.push_back(std::make_pair(
"FirstOrder Energy",squared_sum));
119 featureList.push_back(std::make_pair(
"FirstOrder RMS",rms));
120 featureList.push_back(std::make_pair(
"FirstOrder Kurtosis",kurtosis));
121 featureList.push_back(std::make_pair(
"FirstOrder Skewness",skewness));
122 featureList.push_back(std::make_pair(
"FirstOrder Mean absolute deviation",mean_absolut_deviation));
123 featureList.push_back(std::make_pair(
"FirstOrder Covered Image Intensity Range",coveredGrayValueRange));
125 featureList.push_back(std::make_pair(
"FirstOrder Minimum",labelStatisticsImageFilter->GetMinimum(1)));
126 featureList.push_back(std::make_pair(
"FirstOrder Maximum",labelStatisticsImageFilter->GetMaximum(1)));
127 featureList.push_back(std::make_pair(
"FirstOrder Mean",labelStatisticsImageFilter->GetMean(1)));
128 featureList.push_back(std::make_pair(
"FirstOrder Variance",labelStatisticsImageFilter->GetVariance(1)));
129 featureList.push_back(std::make_pair(
"FirstOrder Sum",labelStatisticsImageFilter->GetSum(1)));
130 featureList.push_back(std::make_pair(
"FirstOrder Median",labelStatisticsImageFilter->GetMedian(1)));
131 featureList.push_back(std::make_pair(
"FirstOrder Standard deviation",labelStatisticsImageFilter->GetSigma(1)));
132 featureList.push_back(std::make_pair(
"FirstOrder No. of Voxel",labelStatisticsImageFilter->GetCount(1)));
136 m_HistogramSize(256), m_UseCtRange(false)
156 featureList.push_back(
"FirstOrder Minimum");
157 featureList.push_back(
"FirstOrder Maximum");
158 featureList.push_back(
"FirstOrder Mean");
159 featureList.push_back(
"FirstOrder Variance");
160 featureList.push_back(
"FirstOrder Sum");
161 featureList.push_back(
"FirstOrder Median");
162 featureList.push_back(
"FirstOrder Standard deviation");
163 featureList.push_back(
"FirstOrder No. of Voxel");
#define AccessByItk_3(mitkImage, itkImageTypeFunction, arg1, arg2, arg3)
itk::SmartPointer< Self > Pointer
std::vector< std::string > FeatureNameListType
itk::Image< unsigned char, 3 > ImageType
std::vector< std::pair< std::string, double > > FeatureListType
virtual FeatureNameListType GetFeatureNames() override
Returns a list of the names of all features that are calculated from this class.
void CalculateFirstOrderStatistics(itk::Image< TPixel, VImageDimension > *itkImage, mitk::Image::Pointer mask, mitk::GIFFirstOrderStatistics::FeatureListType &featureList, mitk::GIFFirstOrderStatistics::ParameterStruct params)
GIFFirstOrderStatistics()
virtual FeatureListType CalculateFeatures(const Image::Pointer &image, const Image::Pointer &feature) override
Calculates the Cooccurence-Matrix based features for this class.
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.