本文整理汇总了C++中typenamefiltertype::Pointer::GetCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::GetCount方法的具体用法?C++ Pointer::GetCount怎么用?C++ Pointer::GetCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typenamefiltertype::Pointer
的用法示例。
在下文中一共展示了Pointer::GetCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalculateVolumeStatistic
void
CalculateVolumeStatistic(itk::Image<TPixel, VImageDimension>* itkImage, mitk::Image::Pointer mask, mitk::GIFVolumetricStatistics::FeatureListType & featureList, std::string prefix)
{
typedef itk::Image<TPixel, VImageDimension> ImageType;
typedef itk::Image<int, VImageDimension> MaskType;
typedef itk::LabelStatisticsImageFilter<ImageType, MaskType> FilterType;
typename MaskType::Pointer maskImage = MaskType::New();
mitk::CastToItkImage(mask, maskImage);
typename FilterType::Pointer labelStatisticsImageFilter = FilterType::New();
labelStatisticsImageFilter->SetInput( itkImage );
labelStatisticsImageFilter->SetLabelInput(maskImage);
labelStatisticsImageFilter->Update();
double volume = labelStatisticsImageFilter->GetCount(1);
double voxelVolume = 1;
for (int i = 0; i < (int)(VImageDimension); ++i)
{
volume *= itkImage->GetSpacing()[i];
voxelVolume *= itkImage->GetSpacing()[i];
}
featureList.push_back(std::make_pair(prefix + "Voxel Volume", voxelVolume));
featureList.push_back(std::make_pair(prefix + "Volume (voxel based)", volume));
}
示例2: CalculateFirstOrderStatistics
void
CalculateFirstOrderStatistics(itk::Image<TPixel, VImageDimension>* itkImage, mitk::Image::Pointer mask, mitk::GIFFirstOrderStatistics::FeatureListType & featureList)
{
typedef itk::Image<TPixel, VImageDimension> ImageType;
typedef itk::Image<int, VImageDimension> MaskType;
typedef itk::LabelStatisticsImageFilter<ImageType, MaskType> FilterType;
typedef typename FilterType::HistogramType HistogramType;
typedef typename HistogramType::IndexType HIndexType;
typedef itk::MinimumMaximumImageCalculator<ImageType> MinMaxComputerType;
typename MaskType::Pointer maskImage = MaskType::New();
mitk::CastToItkImage(mask, maskImage);
typename MinMaxComputerType::Pointer minMaxComputer = MinMaxComputerType::New();
minMaxComputer->SetImage(itkImage);
minMaxComputer->Compute();
double imageRange = minMaxComputer->GetMaximum() - minMaxComputer->GetMinimum();
typename FilterType::Pointer labelStatisticsImageFilter = FilterType::New();
labelStatisticsImageFilter->SetInput( itkImage );
labelStatisticsImageFilter->SetLabelInput(maskImage);
labelStatisticsImageFilter->SetUseHistograms(true);
labelStatisticsImageFilter->SetHistogramParameters(256, minMaxComputer->GetMinimum(),minMaxComputer->GetMaximum());
labelStatisticsImageFilter->Update();
// --------------- Range --------------------
double range = labelStatisticsImageFilter->GetMaximum(1) - labelStatisticsImageFilter->GetMinimum(1);
// --------------- Uniformity, Entropy --------------------
double count = labelStatisticsImageFilter->GetCount(1);
double std_dev = labelStatisticsImageFilter->GetSigma(1);
double mean = labelStatisticsImageFilter->GetMean(1);
auto histogram = labelStatisticsImageFilter->GetHistogram(1);
HIndexType index;
index.SetSize(1);
double binWidth = histogram->GetBinMax(0, 0) - histogram->GetBinMin(0, 0);
double uniformity = 0;
double entropy = 0;
double squared_sum = 0;
double kurtosis = 0;
double mean_absolut_deviation = 0;
double skewness = 0;
for (int i = 0; i < (int)(histogram->GetSize(0)); ++i)
{
index[0] = i;
double prob = histogram->GetFrequency(index);
double voxelValue = histogram->GetBinMin(0, i) +binWidth * 0.5;
squared_sum += prob * voxelValue*voxelValue;
kurtosis += prob* (voxelValue - mean) * (voxelValue - mean) * (voxelValue - mean) * (voxelValue - mean);
skewness += prob* (voxelValue - mean) * (voxelValue - mean) * (voxelValue - mean);
mean_absolut_deviation = prob* std::abs(voxelValue - mean);
prob /= count;
uniformity += prob*prob;
if (prob > 0)
entropy += prob * std::log(prob);
}
double rms = std::sqrt(squared_sum / count);
kurtosis = kurtosis / count / (std_dev * std_dev);
skewness = skewness / count / (std_dev * std_dev * std_dev);
mean_absolut_deviation = mean_absolut_deviation / count;
double coveredGrayValueRange = range / imageRange;
featureList.push_back(std::make_pair("FirstOrder Range",range));
featureList.push_back(std::make_pair("FirstOrder Uniformity",uniformity));
featureList.push_back(std::make_pair("FirstOrder Entropy",entropy));
featureList.push_back(std::make_pair("FirstOrder Energy",squared_sum));
featureList.push_back(std::make_pair("FirstOrder RMS",rms));
featureList.push_back(std::make_pair("FirstOrder Kurtosis",kurtosis));
featureList.push_back(std::make_pair("FirstOrder Skewness",skewness));
featureList.push_back(std::make_pair("FirstOrder Mean absolute deviation",mean_absolut_deviation));
featureList.push_back(std::make_pair("FirstOrder Covered Image Intensity Range",coveredGrayValueRange));
featureList.push_back(std::make_pair("FirstOrder Minimum",labelStatisticsImageFilter->GetMinimum(1)));
featureList.push_back(std::make_pair("FirstOrder Maximum ",labelStatisticsImageFilter->GetMaximum(1)));
featureList.push_back(std::make_pair("FirstOrder Mean",labelStatisticsImageFilter->GetMean(1)));
featureList.push_back(std::make_pair("FirstOrder Variance",labelStatisticsImageFilter->GetVariance(1)));
featureList.push_back(std::make_pair("FirstOrder Sum",labelStatisticsImageFilter->GetSum(1)));
featureList.push_back(std::make_pair("FirstOrder Median",labelStatisticsImageFilter->GetMedian(1)));
featureList.push_back(std::make_pair("FirstOrder Standard deviation",labelStatisticsImageFilter->GetSigma(1)));
featureList.push_back(std::make_pair("FirstOrder No. of Voxel",labelStatisticsImageFilter->GetCount(1)));
}
示例3: if
void
CalculateFirstOrderStatistics(itk::Image<TPixel, VImageDimension>* itkImage, mitk::Image::Pointer mask, mitk::GIFFirstOrderStatistics::FeatureListType & featureList, mitk::GIFFirstOrderStatistics::ParameterStruct params)
{
typedef itk::Image<TPixel, VImageDimension> ImageType;
typedef itk::Image<unsigned short, VImageDimension> MaskType;
typedef itk::LabelStatisticsImageFilter<ImageType, MaskType> FilterType;
typedef typename FilterType::HistogramType HistogramType;
typedef typename HistogramType::IndexType HIndexType;
typedef itk::MinimumMaximumImageCalculator<ImageType> MinMaxComputerType;
typename MaskType::Pointer maskImage = MaskType::New();
mitk::CastToItkImage(mask, maskImage);
double voxelVolume = 1;
for (unsigned int i = 0; i < std::min<unsigned int>(3, VImageDimension); ++i)
voxelVolume *= itkImage->GetSpacing()[i];
double voxelSpace = 1;
for (unsigned int i = 0; i < VImageDimension; ++i)
voxelSpace *= itkImage->GetSpacing()[i];
typename MinMaxComputerType::Pointer minMaxComputer = MinMaxComputerType::New();
minMaxComputer->SetImage(itkImage);
minMaxComputer->Compute();
double imageRange = minMaxComputer->GetMaximum() - minMaxComputer->GetMinimum();
typename FilterType::Pointer labelStatisticsImageFilter = FilterType::New();
labelStatisticsImageFilter->SetInput( itkImage );
labelStatisticsImageFilter->SetLabelInput(maskImage);
labelStatisticsImageFilter->SetUseHistograms(true);
double min = params.MinimumIntensity;
double max = params.MaximumIntensity;
labelStatisticsImageFilter->SetHistogramParameters(params.Bins, min,max);
labelStatisticsImageFilter->Update();
// --------------- Range --------------------
double range = labelStatisticsImageFilter->GetMaximum(1) - labelStatisticsImageFilter->GetMinimum(1);
// --------------- Uniformity, Entropy --------------------
double count = labelStatisticsImageFilter->GetCount(1);
//double std_dev = labelStatisticsImageFilter->GetSigma(1);
double mean = labelStatisticsImageFilter->GetMean(1);
double median = labelStatisticsImageFilter->GetMedian(1);
auto histogram = labelStatisticsImageFilter->GetHistogram(1);
bool histogramIsCalculated = histogram;
HIndexType index;
index.SetSize(1);
double uniformity = 0;
double entropy = 0;
double squared_sum = 0;
double kurtosis = 0;
double mean_absolut_deviation = 0;
double median_absolut_deviation = 0;
double skewness = 0;
double sum_prob = 0;
double binWidth = 0;
double p05th = 0, p10th = 0, p15th = 0, p20th = 0, p25th = 0, p30th = 0, p35th = 0, p40th = 0, p45th = 0, p50th = 0;
double p55th = 0, p60th = 0, p65th = 0, p70th = 0, p75th = 0, p80th = 0, p85th = 0, p90th = 0, p95th = 0;
double voxelValue = 0;
if (histogramIsCalculated)
{
binWidth = histogram->GetBinMax(0, 0) - histogram->GetBinMin(0, 0);
p05th = histogram->Quantile(0, 0.05);
p10th = histogram->Quantile(0, 0.10);
p15th = histogram->Quantile(0, 0.15);
p20th = histogram->Quantile(0, 0.20);
p25th = histogram->Quantile(0, 0.25);
p30th = histogram->Quantile(0, 0.30);
p35th = histogram->Quantile(0, 0.35);
p40th = histogram->Quantile(0, 0.40);
p45th = histogram->Quantile(0, 0.45);
p50th = histogram->Quantile(0, 0.50);
p55th = histogram->Quantile(0, 0.55);
p60th = histogram->Quantile(0, 0.60);
p65th = histogram->Quantile(0, 0.65);
p70th = histogram->Quantile(0, 0.70);
p75th = histogram->Quantile(0, 0.75);
p80th = histogram->Quantile(0, 0.80);
p85th = histogram->Quantile(0, 0.85);
p90th = histogram->Quantile(0, 0.90);
p95th = histogram->Quantile(0, 0.95);
}
double Log2=log(2);
double mode_bin;
double mode_value = 0;
double variance = 0;
if (histogramIsCalculated)
{
for (int i = 0; i < (int)(histogram->GetSize(0)); ++i)
{
index[0] = i;
double prob = histogram->GetFrequency(index);
if (prob < 0.00000001)
continue;
//.........这里部分代码省略.........