Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub
Other Statistic

Estimation of various image statistic. More...

Functions

SIMD_API void SimdLaplaceAbsSum (const uint8_t *src, size_t stride, size_t width, size_t height, uint64_t *sum)
 Calculates the sum of absolute 3x3 Laplace values for an 8-bit gray image. More...
 
SIMD_API void SimdGetStatistic (const uint8_t *src, size_t stride, size_t width, size_t height, uint8_t *min, uint8_t *max, uint8_t *average)
 Finds minimal, maximal and rounded average pixel values for an 8-bit gray image. More...
 
SIMD_API void SimdGetMoments (const uint8_t *mask, size_t stride, size_t width, size_t height, uint8_t index, uint64_t *area, uint64_t *x, uint64_t *y, uint64_t *xx, uint64_t *xy, uint64_t *yy)
 Calculates geometric moments of mask pixels with a given index. More...
 
SIMD_API void SimdGetObjectMoments (const uint8_t *src, size_t srcStride, size_t width, size_t height, const uint8_t *mask, size_t maskStride, uint8_t index, uint64_t *n, uint64_t *s, uint64_t *sx, uint64_t *sy, uint64_t *sxx, uint64_t *sxy, uint64_t *syy)
 Calculates weighted geometric moments of an object. More...
 
SIMD_API void SimdValueSum (const uint8_t *src, size_t stride, size_t width, size_t height, uint64_t *sum)
 Calculates the sum of pixel values for an 8-bit gray image. More...
 
SIMD_API void SimdSquareSum (const uint8_t *src, size_t stride, size_t width, size_t height, uint64_t *sum)
 Calculates the sum of squared pixel values for an 8-bit gray image. More...
 
SIMD_API void SimdValueSquareSum (const uint8_t *src, size_t stride, size_t width, size_t height, uint64_t *valueSum, uint64_t *squareSum)
 Calculates value sum and squared value sum for an 8-bit gray image. More...
 
SIMD_API void SimdValueSquareSums (const uint8_t *src, size_t stride, size_t width, size_t height, size_t channels, uint64_t *valueSums, uint64_t *squareSums)
 Calculates per-channel value sums and squared value sums for an 8-bit image. More...
 
SIMD_API void SimdCorrelationSum (const uint8_t *a, size_t aStride, const uint8_t *b, size_t bStride, size_t width, size_t height, uint64_t *sum)
 Calculates the sum of pixel-wise products for two 8-bit gray images. More...
 
template<template< class > class A>
SIMD_INLINE void LaplaceAbsSum (const View< A > &src, uint64_t &sum)
 Calculates sum of absolute value of Laplace's filter. More...
 
template<template< class > class A>
SIMD_INLINE void GetStatistic (const View< A > &src, uint8_t &min, uint8_t &max, uint8_t &average)
 Finds minimal, maximal and average pixel values for given image. More...
 
template<template< class > class A>
SIMD_INLINE void GetMoments (const View< A > &mask, uint8_t index, uint64_t &area, uint64_t &x, uint64_t &y, uint64_t &xx, uint64_t &xy, uint64_t &yy)
 Calculate statistical characteristics (moments) of pixels with given index. More...
 
template<template< class > class A>
SIMD_INLINE void GetObjectMoments (const View< A > &src, const View< A > &mask, uint8_t index, uint64_t &n, uint64_t &s, uint64_t &sx, uint64_t &sy, uint64_t &sxx, uint64_t &sxy, uint64_t &syy)
 Calculate statistical characteristics (moments) of given object. More...
 
template<template< class > class A>
SIMD_INLINE void ValueSum (const View< A > &src, uint64_t &sum)
 Gets sum of value of pixels for gray 8-bit image. More...
 
template<template< class > class A>
SIMD_INLINE void SquareSum (const View< A > &src, uint64_t &sum)
 Gets sum of squared value of pixels for gray 8-bit image. More...
 
template<template< class > class A>
SIMD_INLINE void ValueSquareSum (const View< A > &src, uint64_t &valueSum, uint64_t &squareSum)
 Gets sum and sum of squared value of pixels for gray 8-bit image. More...
 
template<template< class > class A>
SIMD_INLINE void ValueSquareSums (const View< A > &src, uint64_t *valueSums, uint64_t *squareSums)
 Gets image channels value sums and squared value sums for image. The image must have 8-bit depth per channel. More...
 
template<template< class > class A>
SIMD_INLINE void CorrelationSum (const View< A > &a, const View< A > &b, uint64_t &sum)
 Gets sum of pixel correlation for two gray 8-bit images. More...
 

Detailed Description

Estimation of various image statistic.

Function Documentation

◆ SimdLaplaceAbsSum()

void SimdLaplaceAbsSum ( const uint8_t *  src,
size_t  stride,
size_t  width,
size_t  height,
uint64_t *  sum 
)

Calculates the sum of absolute 3x3 Laplace values for an 8-bit gray image.

The function sets sum[0] to zero and accumulates Abs(Laplace(src)) for every pixel. Border pixels are handled by nearest-pixel replication as in SimdLaplace.

Note
This function has a C++ wrapper: Simd::LaplaceAbsSum(const View<A>& src, uint64_t & sum).
Parameters
[in]src- a pointer to pixels data of the input 8-bit gray image.
[in]stride- a row size of the input image (in bytes).
[in]width- an image width. It must be greater than 1.
[in]height- an image height.
[out]sum- a pointer to result sum.

◆ SimdGetStatistic()

void SimdGetStatistic ( const uint8_t *  src,
size_t  stride,
size_t  width,
size_t  height,
uint8_t *  min,
uint8_t *  max,
uint8_t *  average 
)

Finds minimal, maximal and rounded average pixel values for an 8-bit gray image.

The image must have 8-bit gray format and non-zero area. The average is rounded to the nearest integer as (sum + width*height/2)/(width*height).

Note
This function has a C++ wrappers: Simd::GetStatistic(const View<A>& src, uint8_t & min, uint8_t & max, uint8_t & average).
Parameters
[in]src- a pointer to pixels data of the input image.
[in]stride- a row size of the image in bytes.
[in]width- an image width.
[in]height- an image height.
[out]min- a pointer to unsigned 8-bit integer value with found minimal pixel value.
[out]max- a pointer to unsigned 8-bit integer value with found maximal pixel value.
[out]average- a pointer to unsigned 8-bit integer value with found rounded average pixel value.

◆ SimdGetMoments()

void SimdGetMoments ( const uint8_t *  mask,
size_t  stride,
size_t  width,
size_t  height,
uint8_t  index,
uint64_t *  area,
uint64_t *  x,
uint64_t *  y,
uint64_t *  xx,
uint64_t *  xy,
uint64_t *  yy 
)

Calculates geometric moments of mask pixels with a given index.

The mask image must have 8-bit gray format. All output values are initialized to zero inside the function before accumulation.

For every point:

if(mask[X, Y] == index)
{
    area[0] += 1;
    x[0] += X;
    y[0] += Y;
    xx[0] += X*X;
    xy[0] += X*Y;
    yy[0] += Y*Y;
}
Note
This function has a C++ wrappers: Simd::GetMoments(const View<A>& mask, uint8_t index, uint64_t & area, uint64_t & x, uint64_t & y, uint64_t & xx, uint64_t & xy, uint64_t & yy).
Parameters
[in]mask- a pointer to pixels data of the mask image.
[in]stride- a row size of the mask image in bytes.
[in]width- an image width.
[in]height- an image height.
[in]index- a mask index to include in moment calculation.
[out]area- a pointer to unsigned 64-bit integer value with found area (number of pixels with given index).
[out]x- a pointer to unsigned 64-bit integer value with found first-order moment x.
[out]y- a pointer to unsigned 64-bit integer value with found first-order moment y.
[out]xx- a pointer to unsigned 64-bit integer value with found second-order moment xx.
[out]xy- a pointer to unsigned 64-bit integer value with found second-order moment xy.
[out]yy- a pointer to unsigned 64-bit integer value with found second-order moment yy.

◆ SimdGetObjectMoments()

void SimdGetObjectMoments ( const uint8_t *  src,
size_t  srcStride,
size_t  width,
size_t  height,
const uint8_t *  mask,
size_t  maskStride,
uint8_t  index,
uint64_t *  n,
uint64_t *  s,
uint64_t *  sx,
uint64_t *  sy,
uint64_t *  sxx,
uint64_t *  sxy,
uint64_t *  syy 
)

Calculates weighted geometric moments of an object.

The images must have 8-bit gray format and equal size. Either src or mask can be NULL, but not both. If mask is NULL, every source pixel is included. If src is NULL, every selected mask pixel has weight 1. All output values are initialized to zero inside the function before accumulation.

For every point:

if(mask == NULL || mask[X, Y] == index)
{
    S = src ? src[X, Y] : 1;
    n[0] += 1;
    s[0] += S;
    sx[0] += S*X;
    sy[0] += S*Y;
    sxx[0] += S*X*X;
    sxy[0] += S*X*Y;
    syy[0] += S*Y*Y;
}
Note
This function has a C++ wrappers: Simd::GetObjectMoments(const View<A> & src, const View<A> & mask, uint8_t index, uint64_t & n, uint64_t & s, uint64_t & sx, uint64_t & sy, uint64_t & sxx, uint64_t & sxy, uint64_t & syy).
Parameters
[in]src- a pointer to pixels data of the input image. Can be NULL to use weight 1 for selected pixels.
[in]srcStride- a row size of the input image in bytes.
[in]width- an image width.
[in]height- an image height.
[in]mask- a pointer to pixels data of the mask image. Can be NULL to include every pixel.
[in]maskStride- a row size of the mask image in bytes.
[in]index- a mask index to include when mask is not NULL.
[out]n- a pointer to unsigned 64-bit integer value with found number of selected pixels.
[out]s- a pointer to unsigned 64-bit integer value with sum of image values of given object.
[out]sx- a pointer to unsigned 64-bit integer value with found first-order moment x of given object.
[out]sy- a pointer to unsigned 64-bit integer value with found first-order moment y of given object.
[out]sxx- a pointer to unsigned 64-bit integer value with found second-order moment xx of given object.
[out]sxy- a pointer to unsigned 64-bit integer value with found second-order moment xy of given object.
[out]syy- a pointer to unsigned 64-bit integer value with found second-order moment yy of given object.

◆ SimdValueSum()

void SimdValueSum ( const uint8_t *  src,
size_t  stride,
size_t  width,
size_t  height,
uint64_t *  sum 
)

Calculates the sum of pixel values for an 8-bit gray image.

The output sum is initialized to zero inside the function before accumulation.

For every point:

sum[0] += src[x, y];
Note
This function has a C++ wrappers: Simd::ValueSum(const View<A>& src, uint64_t & sum).
Parameters
[in]src- a pointer to pixels data of the image.
[in]stride- a row size of the image in bytes.
[in]width- an image width.
[in]height- an image height.
[out]sum- a pointer to unsigned 64-bit integer result sum.

◆ SimdSquareSum()

void SimdSquareSum ( const uint8_t *  src,
size_t  stride,
size_t  width,
size_t  height,
uint64_t *  sum 
)

Calculates the sum of squared pixel values for an 8-bit gray image.

The output sum is initialized to zero inside the function before accumulation.

For every point:

sum[0] += src[x, y]*src[x, y];
Note
This function has a C++ wrappers: Simd::SquareSum(const View<A>& src, uint64_t & sum).
Parameters
[in]src- a pointer to pixels data of the image.
[in]stride- a row size of the image in bytes.
[in]width- an image width.
[in]height- an image height.
[out]sum- a pointer to unsigned 64-bit integer result sum.

◆ SimdValueSquareSum()

void SimdValueSquareSum ( const uint8_t *  src,
size_t  stride,
size_t  width,
size_t  height,
uint64_t *  valueSum,
uint64_t *  squareSum 
)

Calculates value sum and squared value sum for an 8-bit gray image.

Output sums are initialized to zero inside the function before accumulation.

For every point:

valueSum[0] += src[x, y];
squareSum[0] += src[x, y]*src[x, y];
Note
This function has a C++ wrappers: Simd::ValueSquareSum(const View<A>& src, uint64_t & valueSum, uint64_t & squareSum).
Parameters
[in]src- a pointer to pixels data of the image.
[in]stride- a row size of the image in bytes.
[in]width- an image width.
[in]height- an image height.
[out]valueSum- a pointer to unsigned 64-bit integer value sum.
[out]squareSum- a pointer to unsigned 64-bit integer squared value sum.

◆ SimdValueSquareSums()

void SimdValueSquareSums ( const uint8_t *  src,
size_t  stride,
size_t  width,
size_t  height,
size_t  channels,
uint64_t *  valueSums,
uint64_t *  squareSums 
)

Calculates per-channel value sums and squared value sums for an 8-bit image.

The image must have 8-bit depth per channel, and channels must be 1, 2, 3 or 4. Output arrays are initialized to zero inside the function before accumulation.

for(c = 0; c < channels; c++)
{
    valueSums[c] = 0;
    squareSums[c] = 0;
}
for(y = 0; y < height; y++) 
    for(x = 0; x < width; x++)
        for(c = 0; c < channels; c++)
        {
            value = src[y * stride + x * channels + c];
            valueSums[c] += value;
            squareSums[c] += value * value;
        }
Note
This function has a C++ wrappers: Simd::ValueSquareSums(const View<A>& src, uint64_t * valueSums, uint64_t * squareSums).
Parameters
[in]src- a pointer to pixels data of the image.
[in]stride- a row size of the image in bytes.
[in]width- an image width.
[in]height- an image height.
[in]channels- a number of image channels. It must be 1, 2, 3 or 4.
[out]valueSums- a pointer to output buffer with per-channel value sums. Its size must be at least channels.
[out]squareSums- a pointer to output buffer with per-channel squared value sums. Its size must be at least channels.

◆ SimdCorrelationSum()

void SimdCorrelationSum ( const uint8_t *  a,
size_t  aStride,
const uint8_t *  b,
size_t  bStride,
size_t  width,
size_t  height,
uint64_t *  sum 
)

Calculates the sum of pixel-wise products for two 8-bit gray images.

All images must have the same width and height and 8-bit gray pixel format. The output sum is initialized to zero inside the function before accumulation.

For all points:

sum[0] += a[i]*b[i];
Note
This function has a C++ wrappers: Simd::CorrelationSum(const View<A> & a, const View<A> & b, uint64_t & sum).
Parameters
[in]a- a pointer to pixels data of the first image.
[in]aStride- a row size of the first image in bytes.
[in]b- a pointer to pixels data of the second image.
[in]bStride- a row size of the second image in bytes.
[in]width- an image width.
[in]height- an image height.
[out]sum- a pointer to unsigned 64-bit integer result sum.

◆ LaplaceAbsSum()

void LaplaceAbsSum ( const View< A > &  src,
uint64_t &  sum 
)

Calculates sum of absolute value of Laplace's filter.

Input image must have 8-bit gray format.

For every point:

sum += abs(
    - src[x-1, y-1] -   src[x, y-1] - src[x+1, y-1]
    - src[x-1, y]   + 8*src[x, y]   - src[x+1, y]
    - src[x-1, y+1] -   src[x, y+1] - src[x+1, y+1]).
Note
This function is a C++ wrapper for function SimdLaplaceAbsSum.
Parameters
[in]src- an input image.
[out]sum- a result sum.

◆ GetStatistic()

void GetStatistic ( const View< A > &  src,
uint8_t &  min,
uint8_t &  max,
uint8_t &  average 
)

Finds minimal, maximal and average pixel values for given image.

The image must have 8-bit gray format.

Note
This function is a C++ wrapper for function SimdGetStatistic.
Parameters
[in]src- an input image.
[out]min- a reference to unsigned 8-bit integer value with found minimal pixel value.
[out]max- a reference to unsigned 8-bit integer value with found maximal pixel value.
[out]average- a reference to unsigned 8-bit integer value with found average pixel value.

◆ GetMoments()

void GetMoments ( const View< A > &  mask,
uint8_t  index,
uint64_t &  area,
uint64_t &  x,
uint64_t &  y,
uint64_t &  xx,
uint64_t &  xy,
uint64_t &  yy 
)

Calculate statistical characteristics (moments) of pixels with given index.

The image must have 8-bit gray format.

For every point:

if(mask[X, Y] == index)
{
    area += 1.
    x += X.
    y += Y.
    xx += X*X.
    xy += X*Y.
    yy += Y*Y.
}
Note
This function is a C++ wrapper for function SimdGetMoments.
Parameters
[in]mask- a mask image.
[in]index- a mask index.
[out]area- a reference to unsigned 64-bit integer value with found area (number of pixels with given index).
[out]x- a reference to unsigned 64-bit integer value with found first-order moment x.
[out]y- a reference to unsigned 64-bit integer value with found first-order moment y.
[out]xx- a reference to unsigned 64-bit integer value with found second-order moment xx.
[out]xy- a reference to unsigned 64-bit integer value with found second-order moment xy.
[out]yy- a reference to unsigned 64-bit integer value with found second-order moment yy.

◆ GetObjectMoments()

void GetObjectMoments ( const View< A > &  src,
const View< A > &  mask,
uint8_t  index,
uint64_t &  n,
uint64_t &  s,
uint64_t &  sx,
uint64_t &  sy,
uint64_t &  sxx,
uint64_t &  sxy,
uint64_t &  syy 
)

Calculate statistical characteristics (moments) of given object.

The images must have 8-bit gray format and equal size. One of them can be empty.

For every point:

if(mask[X, Y] == index || mask == 0)
{
    S = src ? src[X, Y] : 1;
    n += 1.
    s += S;
    sx += S*X.
    sy += S*Y.
    sxx += S*X*X.
    sxy += S*X*Y.
    syy += S*Y*Y.
}
Note
This function is a C++ wrapper for function SimdGetObjectMoments.
Parameters
[in]src- an input image.
[in]mask- a mask image. Can be empty.
[in]index- an object index.
[out]n- a reference to unsigned 64-bit integer value with found area of given object.
[out]s- a reference to unsigned 64-bit integer value with sum of image values of given object.
[out]sx- a reference to unsigned 64-bit integer value with found first-order moment x of given object.
[out]sy- a reference to unsigned 64-bit integer value with found first-order moment y of given object.
[out]sxx- a reference to unsigned 64-bit integer value with found second-order moment xx of given object.
[out]sxy- a reference to unsigned 64-bit integer value with found second-order moment xy of given object.
[out]syy- a reference to unsigned 64-bit integer value with found second-order moment yy of given object.

◆ ValueSum()

void ValueSum ( const View< A > &  src,
uint64_t &  sum 
)

Gets sum of value of pixels for gray 8-bit image.

Note
This function is a C++ wrapper for function SimdValueSum.
Parameters
[in]src- an input image.
[out]sum- a result sum.

◆ SquareSum()

void SquareSum ( const View< A > &  src,
uint64_t &  sum 
)

Gets sum of squared value of pixels for gray 8-bit image.

Note
This function is a C++ wrapper for function SimdSquareSum.
Parameters
[in]src- an input image.
[out]sum- a result sum.

◆ ValueSquareSum()

void ValueSquareSum ( const View< A > &  src,
uint64_t &  valueSum,
uint64_t &  squareSum 
)

Gets sum and sum of squared value of pixels for gray 8-bit image.

Note
This function is a C++ wrapper for function SimdValueSquareSum.
Parameters
[in]src- an input image.
[out]valueSum- a result value sum.
[out]squareSum- a result square sum.

◆ ValueSquareSums()

void ValueSquareSums ( const View< A > &  src,
uint64_t *  valueSums,
uint64_t *  squareSums 
)

Gets image channels value sums and squared value sums for image. The image must have 8-bit depth per channel.

Note
This function is a C++ wrapper for function SimdValueSquareSums.
Parameters
[in]src- an input image.
[out]valueSums- the pointer to output buffer with value sums. Size of the buffer must be equal to count of image channels.
[out]squareSums- the pointer to output buffer with square sums. Size of the buffer must be equal to count of image channels.

◆ CorrelationSum()

void CorrelationSum ( const View< A > &  a,
const View< A > &  b,
uint64_t &  sum 
)

Gets sum of pixel correlation for two gray 8-bit images.

For all points:

sum += a[i]*b[i];

All images must have the same width and height and 8-bit gray pixel format.

Note
This function is a C++ wrapper for function SimdCorrelationSum.
Parameters
[in]a- a first image.
[in]b- a second image.
[out]sum- a result sum.