module #include "diplib/statistics.h"
Statistics Image sample statistics.
Contents
 Reference
See also Projection operators.
Functions

auto dip::
Count (dip::Image const& in, dip::Image const& mask = {}) > dip::uint  Counts the number of nonzero 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
. 
auto dip::
MaximumAndMinimum (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::
SampleStatistics (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.

auto dip::
PearsonCorrelation (dip::Image const& in1, dip::Image const& in2, dip::Image const& mask = {}) > dip::dfloat  Computes the Pearson correlation coefficient. See
dip::Covariance
. 
auto dip::
SpearmanRankCorrelation (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 bymask
. 
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 bymask
.
Function documentation
dip::uint
dip::Count (dip::Image const& in,
dip::Image const& mask = {})
Counts the number of nonzero pixels in a scalar image.
in
must be scalar, but can have any data type. mask
, if forged, must be of the same sizes as in
, or be
singleton expandable to that size, and must be binary.
dip::UnsignedArray
dip::MaximumPixel (dip::Image const& in,
dip::Image const& mask = {},
dip::String const& positionFlag = S::FIRST)
Returns the coordinates of the maximum pixel in the image.
The image must be scalar. If in
is complex, the modulus of its values are used.
If positionFlag
is "first"
, the first maximum is found, in linear index order.
If it is "last"
, the last one is found.
dip::UnsignedArray
dip::MinimumPixel (dip::Image const& in,
dip::Image const& mask = {},
dip::String const& positionFlag = S::FIRST)
Returns the coordinates of the minimum pixel in the image.
The image must be scalar. If in
is complex, the modulus of its values are used.
If positionFlag
is "first"
, the first minimum is found, in linear index order.
If it is "last"
, the last one is found.
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
.
If process
is an empty array, all dimensions are processed. The output is an image of the same size as the input.
For tensor images, the output has the same tensor size and shape as the input.
If mask
is forged, those pixels not selected by the mask are presumed to be 0.
dip::MinMaxAccumulator
dip::MaximumAndMinimum (dip::Image const& in,
dip::Image const& mask = {})
Finds the largest and smallest value in the image, within an optional mask.
If mask
is not forged, all input pixels are considered. In case of a tensor
image, returns the maximum and minimum sample values. In case of a complex
samples, treats real and imaginary components as individual samples.
dip::StatisticsAccumulator
dip::SampleStatistics (dip::Image const& in,
dip::Image const& mask = {})
Computes the first four central moments of the pixel intensities, within an optional mask.
If mask
is not forged, all input pixels are considered. In case of a tensor
image, returns the statistics over all sample values. The image must be realvalued.
dip::CovarianceAccumulator
dip::Covariance (dip::Image const& in1,
dip::Image const& in2,
dip::Image const& mask = {})
Computes the covariance and correlation between the two images, within an optional mask.
If mask
is not forged, all input pixels are considered. In case of tensor
images, returns the covariance over all sample values. The images must be realvalued and
have the same number of tensor elements.
To compute the covariance or correlation between two channels in a multichannel image (a tensor image):
Covariance( in[ 0 ], in[ 1 ], mask );
dip::dfloat
dip::SpearmanRankCorrelation (dip::Image const& in1,
dip::Image const& in2,
dip::Image const& mask = {})
Computes the Spearman rank correlation coefficient.
If mask
is not forged, all input pixels are considered. In case of tensor
images, returns the Spearman rank correlation coefficient over all sample values.
The images must be realvalued and have the same number of tensor elements.
To compute the Spearman rank correlation coefficient between two channels in a multichannel image (a tensor image):
SpearmanRankCorrelation( in[ 0 ], in[ 1 ], mask );
dip::FloatArray
dip::CenterOfMass (dip::Image const& in,
dip::Image const& mask = {})
Computes the center of mass (first order moments) of the image in
, optionally using only
those pixels selected by mask
.
If mask
is not forged, all input pixels are considered. in
must be scalar and realvalued.
dip::MomentAccumulator
dip::Moments (dip::Image const& in,
dip::Image const& mask = {})
Computes the first order normalized moments and second order normalized central moments of the image in
,
optionally using only those pixels selected by mask
.
If mask
is not forged, all input pixels are considered. in
must be scalar and realvalued.
Note that the normalization makes the moments invariant to scaling the image intensities, but not to
spatial scaling. Divide each element of dip::MomentAccumulator::PlainSecondOrder
by dip::MomentAccumulator::Sum
to obtain a value that is invariant also to spatial scaling. The first two Hu moments of a 2D image are obtained
as follows:
auto moments = dip::Moments( img ); auto m0 = moments.Sum(); auto m2 = moments.PlainSecondOrder(); // scale and translation invariant second order moments: double nu20 = m2[ 0 ] / m0; double nu02 = m2[ 1 ] / m0; double nu11 = m2[ 2 ] / m0; // scale, translation and rotationinvariant values: double hu1 = nu20 + nu02; double hu2 = ( nu20  nu02 ) * ( nu20  nu02 ) + 4 * nu11 * nu11;