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 the sum of absolute 3x3 Laplace values for an 8-bit gray image. 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 rounded average pixel values for an 8-bit gray 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)
 Calculates geometric moments of mask pixels with a 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)
 Calculates weighted geometric moments of an object. More...
 
template<template< class > class A>
SIMD_INLINE void ValueSum (const View< A > &src, uint64_t &sum)
 Calculates the sum of pixel values for an 8-bit gray image. More...
 
template<template< class > class A>
SIMD_INLINE void SquareSum (const View< A > &src, uint64_t &sum)
 Calculates the sum of squared pixel values for an 8-bit gray image. More...
 
template<template< class > class A>
SIMD_INLINE void ValueSquareSum (const View< A > &src, uint64_t &valueSum, uint64_t &squareSum)
 Calculates value sum and squared value sum for an 8-bit gray image. More...
 
template<template< class > class A>
SIMD_INLINE void ValueSquareSums (const View< A > &src, uint64_t *valueSums, uint64_t *squareSums)
 Calculates per-channel value sums and squared value sums for an 8-bit image. More...
 
template<template< class > class A>
SIMD_INLINE void CorrelationSum (const View< A > &a, const View< A > &b, uint64_t &sum)
 Calculates the sum of pixel-wise products for two 8-bit gray 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 the sum of absolute 3x3 Laplace values for an 8-bit gray image.

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

Note
This function is a C++ wrapper for function SimdLaplaceAbsSum.
Parameters
[in]src- an input 8-bit gray image. Its width must be greater than 1.
[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 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 is a C++ wrapper for function SimdGetStatistic.
Parameters
[in]src- an input 8-bit gray 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 rounded 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 
)

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 += 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- an 8-bit gray mask image.
[in]index- a mask index to include in moment calculation.
[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 
)

Calculates weighted geometric moments of an object.

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

For every point:

if(mask is empty || mask[X, Y] == index)
{
    S = src is empty ? 1 : src[X, Y];
    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 8-bit gray image. Can be empty to use weight 1 for selected pixels.
[in]mask- an 8-bit gray mask image. Can be empty to include every pixel.
[in]index- a mask index to include when mask is not empty.
[out]n- a reference to unsigned 64-bit integer value with found number of selected pixels.
[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 
)

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 += src[x, y];
Note
This function is a C++ wrapper for function SimdValueSum.
Parameters
[in]src- an input 8-bit gray image.
[out]sum- a reference to unsigned 64-bit integer result sum.

◆ SquareSum()

void SquareSum ( const View< A > &  src,
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 += src[x, y]*src[x, y];
Note
This function is a C++ wrapper for function SimdSquareSum.
Parameters
[in]src- an input 8-bit gray image.
[out]sum- a reference to unsigned 64-bit integer result sum.

◆ ValueSquareSum()

void ValueSquareSum ( const View< A > &  src,
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 += src[x, y];
squareSum += src[x, y]*src[x, y];
Note
This function is a C++ wrapper for function SimdValueSquareSum.
Parameters
[in]src- an input 8-bit gray image.
[out]valueSum- a reference to unsigned 64-bit integer value sum.
[out]squareSum- a reference to unsigned 64-bit integer squared value sum.

◆ ValueSquareSums()

void ValueSquareSums ( const View< A > &  src,
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 channel count 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 is a C++ wrapper for function SimdValueSquareSums.
Parameters
[in]src- an input image with 8-bit channels.
[out]valueSums- a pointer to output buffer with per-channel value sums. Its size must be at least channel count.
[out]squareSums- a pointer to output buffer with per-channel squared value sums. Its size must be at least channel count.

◆ CorrelationSum()

void CorrelationSum ( const View< A > &  a,
const View< A > &  b,
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 += a[i]*b[i];
Note
This function is a C++ wrapper for function SimdCorrelationSum.
Parameters
[in]a- a first 8-bit gray image.
[in]b- a second 8-bit gray image.
[out]sum- a reference to unsigned 64-bit integer result sum.