Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub
Conditional

Functions for conditional estimation of image statistic. More...

Functions

SIMD_API void SimdConditionalCount8u (const uint8_t *src, size_t stride, size_t width, size_t height, uint8_t value, SimdCompareType compareType, uint32_t *count)
 Counts the number of pixels in an 8-bit gray image that satisfy a given comparison condition against a reference value. More...
 
SIMD_API void SimdConditionalCount16i (const uint8_t *src, size_t stride, size_t width, size_t height, int16_t value, SimdCompareType compareType, uint32_t *count)
 Counts the number of pixels in a 16-bit signed integer image that satisfy a given comparison condition against a reference value. More...
 
SIMD_API void SimdConditionalSum (const uint8_t *src, size_t srcStride, size_t width, size_t height, const uint8_t *mask, size_t maskStride, uint8_t value, SimdCompareType compareType, uint64_t *sum)
 Calculates the sum of pixels in a source image at positions where the corresponding mask pixels satisfy a given comparison condition. More...
 
SIMD_API void SimdConditionalSquareSum (const uint8_t *src, size_t srcStride, size_t width, size_t height, const uint8_t *mask, size_t maskStride, uint8_t value, SimdCompareType compareType, uint64_t *sum)
 Calculates the sum of squared pixel values in a source image at positions where the corresponding mask pixels satisfy a given comparison condition. More...
 
SIMD_API void SimdConditionalSquareGradientSum (const uint8_t *src, size_t srcStride, size_t width, size_t height, const uint8_t *mask, size_t maskStride, uint8_t value, SimdCompareType compareType, uint64_t *sum)
 Calculates the sum of squared gradient magnitudes in a source image at positions where the corresponding mask pixels satisfy a given comparison condition. More...
 
SIMD_API void SimdConditionalFill (const uint8_t *src, size_t srcStride, size_t width, size_t height, uint8_t threshold, SimdCompareType compareType, uint8_t value, uint8_t *dst, size_t dstStride)
 Fills pixels of an 8-bit gray destination image with a given value at positions where the corresponding source pixels satisfy a given comparison condition. Pixels that do not satisfy the condition are left unchanged. More...
 
template<template< class > class A>
SIMD_INLINE void ConditionalCount8u (const View< A > &src, uint8_t value, SimdCompareType compareType, uint32_t &count)
 Calculates number of points satisfying certain condition for 8-bit gray image. More...
 
template<template< class > class A>
SIMD_INLINE void ConditionalCount16i (const View< A > &src, int16_t value, SimdCompareType compareType, uint32_t &count)
 Calculates number of points satisfying certain condition for 16-bit signed integer image. More...
 
template<template< class > class A>
SIMD_INLINE void ConditionalSum (const View< A > &src, const View< A > &mask, uint8_t value, SimdCompareType compareType, uint64_t &sum)
 Calculates sum of image points when mask points satisfying certain condition. More...
 
template<template< class > class A>
SIMD_INLINE void ConditionalSquareSum (const View< A > &src, const View< A > &mask, uint8_t value, SimdCompareType compareType, uint64_t &sum)
 Calculates sum of squared image points when mask points satisfying certain condition. More...
 
template<template< class > class A>
SIMD_INLINE void ConditionalSquareGradientSum (const View< A > &src, const View< A > &mask, uint8_t value, SimdCompareType compareType, uint64_t &sum)
 Calculates sum of squared gradient of image points when mask points satisfying certain condition. More...
 
template<template< class > class A>
SIMD_INLINE void ConditionalFill (const View< A > &src, uint8_t threshold, SimdCompareType compareType, uint8_t value, View< A > &dst)
 Fills pixels of 8-bit gray image by given value if corresponding pixels of input 8-bit gray image satisfy certain condition. More...
 

Detailed Description

Functions for conditional estimation of image statistic.

Function Documentation

◆ SimdConditionalCount8u()

void SimdConditionalCount8u ( const uint8_t *  src,
size_t  stride,
size_t  width,
size_t  height,
uint8_t  value,
SimdCompareType  compareType,
uint32_t *  count 
)

Counts the number of pixels in an 8-bit gray image that satisfy a given comparison condition against a reference value.

For every pixel:

if(compare(src[x, y], value))
    count++;

where compare(a, b) depends on compareType (see SimdCompareType).

The output count is initialized to zero before accumulation.

Note
This function has a C++ wrapper Simd::ConditionalCount8u(const View<A> & src, uint8_t value, SimdCompareType compareType, uint32_t & count).
Parameters
[in]src- a pointer to pixels data of the input 8-bit gray image. Each pixel is compared against value.
[in]stride- a row size of the src image in bytes.
[in]width- an image width in pixels.
[in]height- an image height in pixels.
[in]value- a reference value used as the second operand in the comparison.
[in]compareType- a comparison operation type (see SimdCompareType).
[out]count- a pointer to an unsigned 32-bit integer that receives the number of pixels satisfying the condition.

◆ SimdConditionalCount16i()

void SimdConditionalCount16i ( const uint8_t *  src,
size_t  stride,
size_t  width,
size_t  height,
int16_t  value,
SimdCompareType  compareType,
uint32_t *  count 
)

Counts the number of pixels in a 16-bit signed integer image that satisfy a given comparison condition against a reference value.

For every pixel:

if(compare(src[x, y], value))
    count++;

where compare(a, b) depends on compareType (see SimdCompareType).

The output count is initialized to zero before accumulation. Although the src pointer has type uint8_t *, each pixel occupies 2 bytes and is interpreted as a signed 16-bit integer. The stride is expressed in bytes, while width is expressed in 16-bit pixels (elements).

Note
This function has a C++ wrapper Simd::ConditionalCount16i(const View<A> & src, int16_t value, SimdCompareType compareType, uint32_t & count).
Parameters
[in]src- a pointer to pixels data of the input 16-bit signed integer image. Each pixel is compared against value.
[in]stride- a row size of the src image in bytes.
[in]width- an image width in 16-bit pixels (elements per row).
[in]height- an image height in pixels.
[in]value- a reference value used as the second operand in the comparison.
[in]compareType- a comparison operation type (see SimdCompareType).
[out]count- a pointer to an unsigned 32-bit integer that receives the number of pixels satisfying the condition.

◆ SimdConditionalSum()

void SimdConditionalSum ( const uint8_t *  src,
size_t  srcStride,
size_t  width,
size_t  height,
const uint8_t *  mask,
size_t  maskStride,
uint8_t  value,
SimdCompareType  compareType,
uint64_t *  sum 
)

Calculates the sum of pixels in a source image at positions where the corresponding mask pixels satisfy a given comparison condition.

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

For every pixel:

if(compare(mask[x, y], value))
    sum += src[x, y];

where compare(a, b) depends on compareType (see SimdCompareType).

The output sum is initialized to zero before accumulation.

Note
This function has a C++ wrapper Simd::ConditionalSum(const View<A> & src, const View<A> & mask, uint8_t value, SimdCompareType compareType, uint64_t & sum).
Parameters
[in]src- a pointer to pixels data of the input 8-bit gray image whose pixel values are accumulated.
[in]srcStride- a row size of the src image in bytes.
[in]width- an image width in pixels.
[in]height- an image height in pixels.
[in]mask- a pointer to pixels data of the 8-bit gray mask image. Each mask pixel is compared against value.
[in]maskStride- a row size of the mask image in bytes.
[in]value- a reference value used as the second operand in the comparison.
[in]compareType- a comparison operation type (see SimdCompareType).
[out]sum- a pointer to an unsigned 64-bit integer that receives the accumulated sum.

◆ SimdConditionalSquareSum()

void SimdConditionalSquareSum ( const uint8_t *  src,
size_t  srcStride,
size_t  width,
size_t  height,
const uint8_t *  mask,
size_t  maskStride,
uint8_t  value,
SimdCompareType  compareType,
uint64_t *  sum 
)

Calculates the sum of squared pixel values in a source image at positions where the corresponding mask pixels satisfy a given comparison condition.

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

For every pixel:

if(compare(mask[x, y], value))
    sum += src[x, y] * src[x, y];

where compare(a, b) depends on compareType (see SimdCompareType).

The output sum is initialized to zero before accumulation.

Note
This function has a C++ wrapper Simd::ConditionalSquareSum(const View<A> & src, const View<A> & mask, uint8_t value, SimdCompareType compareType, uint64_t & sum).
Parameters
[in]src- a pointer to pixels data of the input 8-bit gray image whose squared pixel values are accumulated.
[in]srcStride- a row size of the src image in bytes.
[in]width- an image width in pixels.
[in]height- an image height in pixels.
[in]mask- a pointer to pixels data of the 8-bit gray mask image. Each mask pixel is compared against value.
[in]maskStride- a row size of the mask image in bytes.
[in]value- a reference value used as the second operand in the comparison.
[in]compareType- a comparison operation type (see SimdCompareType).
[out]sum- a pointer to an unsigned 64-bit integer that receives the accumulated sum of squares.

◆ SimdConditionalSquareGradientSum()

void SimdConditionalSquareGradientSum ( const uint8_t *  src,
size_t  srcStride,
size_t  width,
size_t  height,
const uint8_t *  mask,
size_t  maskStride,
uint8_t  value,
SimdCompareType  compareType,
uint64_t *  sum 
)

Calculates the sum of squared gradient magnitudes in a source image at positions where the corresponding mask pixels satisfy a given comparison condition.

All images must have 8-bit gray format and the same width and height. The image width and height must each be at least 3. Border pixels (first and last row, first and last column) are excluded from processing.

For every non-border pixel:

if(compare(mask[x, y], value))
{
    dx = src[x + 1, y] - src[x - 1, y];
    dy = src[x, y + 1] - src[x, y - 1];
    sum += dx*dx + dy*dy;
}

where compare(a, b) depends on compareType (see SimdCompareType).

The output sum is initialized to zero before accumulation.

Note
This function has a C++ wrapper Simd::ConditionalSquareGradientSum(const View<A> & src, const View<A> & mask, uint8_t value, SimdCompareType compareType, uint64_t & sum).
Parameters
[in]src- a pointer to pixels data of the input 8-bit gray image used to compute gradients.
[in]srcStride- a row size of the src image in bytes.
[in]width- an image width in pixels (must be >= 3).
[in]height- an image height in pixels (must be >= 3).
[in]mask- a pointer to pixels data of the 8-bit gray mask image. Each mask pixel is compared against value.
[in]maskStride- a row size of the mask image in bytes.
[in]value- a reference value used as the second operand in the comparison.
[in]compareType- a comparison operation type (see SimdCompareType).
[out]sum- a pointer to an unsigned 64-bit integer that receives the accumulated sum of squared gradients.

◆ SimdConditionalFill()

void SimdConditionalFill ( const uint8_t *  src,
size_t  srcStride,
size_t  width,
size_t  height,
uint8_t  threshold,
SimdCompareType  compareType,
uint8_t  value,
uint8_t *  dst,
size_t  dstStride 
)

Fills pixels of an 8-bit gray destination image with a given value at positions where the corresponding source pixels satisfy a given comparison condition. Pixels that do not satisfy the condition are left unchanged.

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

For every pixel:

if(compare(src[x, y], threshold))
    dst[x, y] = value;

where compare(a, b) depends on compareType (see SimdCompareType).

Note
This function has a C++ wrapper Simd::ConditionalFill(const View<A> & src, uint8_t threshold, SimdCompareType compareType, uint8_t value, View<A> & dst).
Parameters
[in]src- a pointer to pixels data of the input 8-bit gray image. Each pixel is compared against threshold.
[in]srcStride- a row size of the src image in bytes.
[in]width- an image width in pixels.
[in]height- an image height in pixels.
[in]threshold- a reference value used as the second operand in the comparison.
[in]compareType- a comparison operation type (see SimdCompareType).
[in]value- a fill value written to dst pixels where the condition is satisfied.
[in,out]dst- a pointer to pixels data of the output 8-bit gray image. Pixels not satisfying the condition retain their existing values.
[in]dstStride- a row size of the dst image in bytes.

◆ ConditionalCount8u()

void ConditionalCount8u ( const View< A > &  src,
uint8_t  value,
SimdCompareType  compareType,
uint32_t &  count 
)

Calculates number of points satisfying certain condition for 8-bit gray image.

For every point:

if(compare(src[i], value))
    count++;

where compare(a, b) depends from compareType (see SimdCompareType).

Note
This function is a C++ wrapper for function SimdConditionalCount8u.
Parameters
[in]src- an input 8-bit gray image (first value for compare operation).
[in]value- a second value for compare operation.
[in]compareType- a compare operation type (see SimdCompareType).
[out]count- a pointer to result unsigned 32-bit value.

◆ ConditionalCount16i()

void ConditionalCount16i ( const View< A > &  src,
int16_t  value,
SimdCompareType  compareType,
uint32_t &  count 
)

Calculates number of points satisfying certain condition for 16-bit signed integer image.

For every point:

if(compare(src[i], value))
    count++;

where compare(a, b) depends from compareType (see SimdCompareType).

Note
This function is a C++ wrapper for function SimdConditionalCount16i.
Parameters
[in]src- an input 16-bit signed integer image (first value for compare operation).
[in]value- a second value for compare operation.
[in]compareType- a compare operation type (see SimdCompareType).
[out]count- a pointer to result unsigned 32-bit value.

◆ ConditionalSum()

void ConditionalSum ( const View< A > &  src,
const View< A > &  mask,
uint8_t  value,
SimdCompareType  compareType,
uint64_t &  sum 
)

Calculates sum of image points when mask points satisfying certain condition.

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

For every point:

if(compare(mask[i], value))
    sum += src[i];

where compare(a, b) depends from compareType (see SimdCompareType).

Note
This function is a C++ wrapper for function SimdConditionalSum.
Parameters
[in]src- an input 8-bit gray image.
[in]mask- a 8-bit gray mask (first value for compare operation).
[in]value- a second value for compare operation.
[in]compareType- a compare operation type (see SimdCompareType).
[out]sum- a pointer to result unsigned 64-bit value.

◆ ConditionalSquareSum()

void ConditionalSquareSum ( const View< A > &  src,
const View< A > &  mask,
uint8_t  value,
SimdCompareType  compareType,
uint64_t &  sum 
)

Calculates sum of squared image points when mask points satisfying certain condition.

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

For every point:

if(compare(mask[i], value))
    sum += src[i]*src[i];

where compare(a, b) depends from compareType (see SimdCompareType).

Note
This function is a C++ wrapper for function SimdConditionalSquareSum.
Parameters
[in]src- an input 8-bit gray image.
[in]mask- a 8-bit gray mask (first value for compare operation).
[in]value- a second value for compare operation.
[in]compareType- a compare operation type (see SimdCompareType).
[out]sum- a pointer to result unsigned 64-bit value.

◆ ConditionalSquareGradientSum()

void ConditionalSquareGradientSum ( const View< A > &  src,
const View< A > &  mask,
uint8_t  value,
SimdCompareType  compareType,
uint64_t &  sum 
)

Calculates sum of squared gradient of image points when mask points satisfying certain condition.

All images must have 8-bit gray format and must have the same width and height. The image height and width must be equal or greater 3.

For every point except border:

if(compare(mask[x, y], value))
{
    dx = src[x + 1, y] - src[x - 1, y];
    dy = src[x, y + 1] - src[x, y - 1];
    sum += dx*dx + dy*dy;
}

where compare(a, b) depends from compareType (see SimdCompareType).

Note
This function is a C++ wrapper for function SimdConditionalSquareGradientSum.
Parameters
[in]src- an input 8-bit gray image.
[in]mask- a 8-bit gray mask (first value for compare operation).
[in]value- a second value for compare operation.
[in]compareType- a compare operation type (see SimdCompareType).
[out]sum- a pointer to result unsigned 64-bit value.

◆ ConditionalFill()

void ConditionalFill ( const View< A > &  src,
uint8_t  threshold,
SimdCompareType  compareType,
uint8_t  value,
View< A > &  dst 
)

Fills pixels of 8-bit gray image by given value if corresponding pixels of input 8-bit gray image satisfy certain condition.

All images must have the same width and height.

For every point:

if(compare(src[i], threshold))
    dst[i] = value;

where compare(a, b) depends from compareType (see SimdCompareType).

Note
This function is a C++ wrapper for function SimdConditionalFill
Parameters
[in]src- an input 8-bit gray image.
[in]threshold- a second value for compare operation.
[in]compareType- a compare operation type (see SimdCompareType).
[in]value- a value for fill operation.
[in,out]dst- an output 8-bit gray image.