# diplib/statistics.h file

Declares image statistics functions, including projections. See Math and statistics.

• Reference

## Classes

struct dip::SpatialOverlapMetrics
Holds return values for the function `dip::SpatialOverlap`.

## Functions

auto dip::Count(dip::Image const& in, dip::Image const& mask = {}) -> dip::uint
Counts the number of non-zero pixels in a scalar image.
auto dip::MaximumPixel(dip::Image const& in, dip::Image const& mask = {}, dip::String const& positionFlag = S::FIRST) -> dip::UnsignedArray
Returns the coordinates of the maximum pixel in the image.
auto dip::MinimumPixel(dip::Image const& in, dip::Image const& mask = {}, dip::String const& positionFlag = S::FIRST) -> dip::UnsignedArray
Returns the coordinates of the minimum pixel in the image.
void dip::CumulativeSum(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the cumulative sum of the pixel values over all those dimensions which are specified by `process`.
dip::Image const& in, dip::Image const& mask = {}) -> dip::MinMaxAccumulator
Finds the largest and smallest value in the image, within an optional mask.
auto dip::Quartiles(dip::Image const& in, dip::Image const& mask = {}) -> dip::QuartilesResult
Computes the minimum, lower quartile (25th percentile), median (50th percentile), upper quartile (75th percentile), and maximum.
dip::Image const& in, dip::Image const& mask = {}) -> dip::StatisticsAccumulator
Computes the first four central moments of the pixel intensities, within an optional mask.
auto dip::Covariance(dip::Image const& in1, dip::Image const& in2, dip::Image const& mask = {}) -> dip::CovarianceAccumulator
Computes the covariance and correlation between the two images, within an optional mask.
dip::Image const& in1, dip::Image const& in2, dip::Image const& mask = {}) -> dip::dfloat
Computes the Pearson correlation coefficient. See `dip::Covariance`.
dip::Image const& in1, dip::Image const& in2, dip::Image const& mask = {}) -> dip::dfloat
Computes the Spearman rank correlation coefficient.
auto dip::CenterOfMass(dip::Image const& in, dip::Image const& mask = {}) -> dip::FloatArray
Computes the center of mass (first order moments) of the image `in`, optionally using only those pixels selected by `mask`.
auto dip::Moments(dip::Image const& in, dip::Image const& mask = {}) -> dip::MomentAccumulator
Computes the first order normalized moments and second order normalized central moments of the image `in`, optionally using only those pixels selected by `mask`.
void dip::Mean(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::String const& mode = "", dip::BooleanArray const& process = {})
Calculates the (arithmetic) mean of the pixel values over all those dimensions which are specified by `process`.
void dip::Sum(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the sum of the pixel values over all those dimensions which are specified by `process`.
void dip::GeometricMean(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the geometric mean of the pixel values over all those dimensions which are specified by `process`.
void dip::Product(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the product of the pixel values over all those dimensions which are specified by `process`.
void dip::MeanAbs(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the mean of the absolute pixel values over all those dimensions which are specified by `process`.
void dip::MeanModulus(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the mean of the modulus of the pixel values. Alias to `dip::MeanAbs`.
void dip::SumAbs(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the sum of the absolute pixel values over all those dimensions which are specified by `process`.
void dip::SumModulus(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the sum of the modulus of the pixel values. Alias to `dip::SumAbs`.
void dip::MeanSquare(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the mean of the square pixel values over all those dimensions which are specified by `process`.
void dip::SumSquare(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the sum of the square pixel values over all those dimensions which are specified by `process`.
dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the mean of the square modulus of the pixel values over all those dimensions which are specified by `process`.
dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the sum of the square modulus of the pixel values over all those dimensions which are specified by `process`.
void dip::Variance(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::String mode = S::FAST, dip::BooleanArray const& process = {})
Calculates the variance of the pixel values over all those dimensions which are specified by `process`.
dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::String mode = S::FAST, dip::BooleanArray const& process = {})
Calculates the standard deviation of the pixel values over all those dimensions which are specified by `process`.
void dip::Maximum(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the maximum of the pixel values over all those dimensions which are specified by `process`.
void dip::Minimum(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the minimum of the pixel values over all those dimensions which are specified by `process`.
void dip::MaximumAbs(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the maximum of the absolute pixel values over all those dimensions which are specified by `process`.
void dip::MinimumAbs(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the minimum of the absolute pixel values over all those dimensions which are specified by `process`.
void dip::Percentile(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::dfloat percentile = 50, dip::BooleanArray const& process = {})
Calculates the percentile of the pixel values over all those dimensions which are specified by `process`.
void dip::Median(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Calculates the median of the pixel values over all those dimensions which are specified by `process`.
dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Computes the median absolute deviation (MAD)
void dip::All(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Determines if all pixels have non-zero values over all those dimensions which are specified by `process`.
void dip::Any(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::BooleanArray const& process = {})
Determines if any pixel has a non-zero value over all those dimensions which are specified by `process`.
void dip::PositionMaximum(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::uint dim = 0, dip::String const& mode = S::FIRST)
Calculates the position of the maximum of the pixel values in a single dimension specified by `dim`.
void dip::PositionMinimum(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::uint dim = 0, dip::String const& mode = S::FIRST)
Calculates the position of the minimum of the pixel values in a single dimension specified by `dim`.
dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::dfloat percentile = 50, dip::uint dim = 0, dip::String const& mode = S::FIRST)
Calculates the position of the percentile of the pixel values in a single dimension specified by `dim`.
void dip::PositionMedian(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::uint dim = 0, dip::String const& mode = S::FIRST)
Calculates the position of the median of the pixel values in a single dimension specified by `dim`.
void dip::RadialSum(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::dfloat binSize = 1, dip::String const& maxRadius = S::OUTERRADIUS, dip::FloatArray const& center = {})
Computes the radial projection of the sum of the pixel values of `in`.
void dip::RadialMean(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::dfloat binSize = 1, dip::String const& maxRadius = S::OUTERRADIUS, dip::FloatArray const& center = {})
Computes the radial projection of the mean of the pixel values of `in`.
void dip::RadialMinimum(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::dfloat binSize = 1, dip::String const& maxRadius = S::OUTERRADIUS, dip::FloatArray const& center = {})
Computes the radial projection of the minimum of the pixel values of `in`.
void dip::RadialMaximum(dip::Image const& in, dip::Image const& mask, dip::Image& out, dip::dfloat binSize = 1, dip::String const& maxRadius = S::OUTERRADIUS, dip::FloatArray const& center = {})
Computes the radial projection of the maximum of the pixel values of `in`.
auto dip::MeanError(dip::Image const& in, dip::Image const& reference, dip::Image const& mask = {}) -> dip::dfloat
Calculates the mean error difference between corresponding sample values of `in` and `reference`.
auto dip::MeanSquareError(dip::Image const& in, dip::Image const& reference, dip::Image const& mask = {}) -> dip::dfloat
Calculates the mean square error difference between corresponding sample values of `in` and `reference`.
dip::Image const& in, dip::Image const& reference, dip::Image const& mask = {}) -> dip::dfloat
Calculates the root mean square (RMS) error difference between corresponding sample values of `in` and `reference`.
dip::Image const& in, dip::Image const& reference, dip::Image const& mask = {}) -> dip::dfloat
Calculates the mean absolute error difference between corresponding sample values of `in` and `reference`.
dip::Image const& in, dip::Image const& reference, dip::Image const& mask = {}) -> dip::dfloat
Calculates the maximum absolute error difference between corresponding sample values of `in` and `reference`.
dip::Image const& in, dip::Image const& reference, dip::Image const& mask = {}) -> dip::dfloat
Calculates the mean relative error difference between corresponding sample values of `in` and `reference`.
dip::Image const& in, dip::Image const& reference, dip::Image const& mask = {}) -> dip::dfloat
Calculates the maximum relative error difference between corresponding sample values of `in` and `reference`.
auto dip::IDivergence(dip::Image const& in, dip::Image const& reference, dip::Image const& mask = {}) -> dip::dfloat
Calculates the I-divergence between corresponding sample values of `in` and `reference`.
auto dip::InProduct(dip::Image const& in, dip::Image const& reference, dip::Image const& mask = {}) -> dip::dfloat
Calculates the sum of the product of corresponding sample values of `in` and `reference`.
auto dip::LnNormError(dip::Image const& in, dip::Image const& reference, dip::Image const& mask = {}, dip::dfloat order = 2.0) -> dip::dfloat
Calculates the `order` norm difference between corresponding sample values of `in` and `reference`.
auto dip::PSNR(dip::Image const& in, dip::Image const& reference, dip::Image const& mask = {}, dip::dfloat peakSignal = 0.0) -> dip::dfloat
Calculates the peak signal-to-noise ratio, in dB.
auto dip::SSIM(dip::Image const& in, dip::Image const& reference, dip::Image const& mask = {}, dip::dfloat sigma = 1.5, dip::dfloat K1 = 0.01, dip::dfloat K2 = 0.03) -> dip::dfloat
Calculates the structural similarity index (a visual similarity measure)
dip::Image const& in, dip::Image const& reference, dip::Image const& mask = {}, dip::uint nBins = 256) -> dip::dfloat
Calculates the mutual information, in bits, using a histogram with `nBins`-by-`nBins` bins.
auto dip::SpatialOverlap(dip::Image const& in, dip::Image const& reference) -> dip::SpatialOverlapMetrics
Compares a segmentation result `in` to the ground truth `reference`.
auto dip::DiceCoefficient(dip::Image const& in, dip::Image const& reference) -> dip::dfloat
Compares a segmentation result `in` to the ground truth `reference`, determining the Dice coefficient.
auto dip::JaccardIndex(dip::Image const& in, dip::Image const& reference) -> dip::dfloat
Compares a segmentation result `in` to the ground truth `reference`, determining the Jaccard index.
auto dip::Specificity(dip::Image const& in, dip::Image const& reference) -> dip::dfloat
Compares a segmentation result `in` to the ground truth `reference`, determining the specificity of the segmentation.
auto dip::Sensitivity(dip::Image const& in, dip::Image const& reference) -> dip::dfloat
Compares a segmentation result `in` to the ground truth `reference`, determining the sensitivity of the segmentation.
auto dip::Accuracy(dip::Image const& in, dip::Image const& reference) -> dip::dfloat
Compares a segmentation result `in` to the ground truth `reference`, determining the accuracy of the segmentation.
auto dip::Precision(dip::Image const& in, dip::Image const& reference) -> dip::dfloat
Compares a segmentation result `in` to the ground truth `reference`, determining the precision of the segmentation.
dip::Image const& in, dip::Image const& reference) -> dip::dfloat
Computes the Hausdorff distance between two binary images.
dip::Image const& in, dip::Image const& reference) -> dip::dfloat
Computes the modified Hausdorff distance between two binary images.
dip::Image const& in, dip::Image const& reference) -> dip::dfloat
Computes the sum of minimal distances (SMD) between two binary images.
dip::Image const& in, dip::Image const& reference) -> dip::dfloat
Computes the complement weighted sum of minimal distances (CWSMD) between two binary images.
auto dip::Entropy(dip::Image const& in, dip::Image const& mask = {}, dip::uint nBins = 256) -> dip::dfloat
Calculates the entropy, in bits, using a histogram with `nBins` bins.
dip::Image const& in, dip::Image const& mask = {}) -> dip::dfloat
Estimates the variance of white Gaussian noise in an image.