Simd Library Documentation.

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

Functions for estimation of image histogram. More...

Functions

SIMD_API void SimdAbsSecondDerivativeHistogram (const uint8_t *src, size_t width, size_t height, size_t stride, size_t step, size_t indent, uint32_t *histogram)
 Calculates histogram of second derivative for 8-bit gray image. More...
 
SIMD_API void SimdHistogram (const uint8_t *src, size_t width, size_t height, size_t stride, uint32_t *histogram)
 Calculates histogram for 8-bit gray image. More...
 
SIMD_API void SimdHistogramMasked (const uint8_t *src, size_t srcStride, size_t width, size_t height, const uint8_t *mask, size_t maskStride, uint8_t index, uint32_t *histogram)
 Calculates histogram for 8-bit gray image with using mask. More...
 
SIMD_API void SimdHistogramConditional (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, uint32_t *histogram)
 Calculates histogram of 8-bit gray image for those points when mask points satisfying certain condition. More...
 
SIMD_API void SimdNormalizedColors (const uint32_t *histogram, uint8_t *colors)
 Gets normalized color map for given histogram. More...
 
SIMD_API void SimdChangeColors (const uint8_t *src, size_t srcStride, size_t width, size_t height, const uint8_t *colors, uint8_t *dst, size_t dstStride)
 Changes colors for 8-bit gray image with using of color map. More...
 
SIMD_API void SimdNormalizeHistogram (const uint8_t *src, size_t srcStride, size_t width, size_t height, uint8_t *dst, size_t dstStride)
 Normalizes histogram for 8-bit gray image. More...
 
template<template< class > class A>
SIMD_INLINE void AbsSecondDerivativeHistogram (const View< A > &src, size_t step, size_t indent, uint32_t *histogram)
 Calculates histogram of second derivative for 8-bit gray image. More...
 
template<template< class > class A>
SIMD_INLINE void Histogram (const View< A > &src, uint32_t *histogram)
 Calculates histogram for 8-bit gray image. More...
 
template<template< class > class A>
SIMD_INLINE void HistogramMasked (const View< A > &src, const View< A > &mask, uint8_t index, uint32_t *histogram)
 Calculates histogram for 8-bit gray image with using mask. More...
 
template<template< class > class A>
SIMD_INLINE void HistogramConditional (const View< A > &src, const View< A > &mask, uint8_t value, SimdCompareType compareType, uint32_t *histogram)
 Calculates histogram of 8-bit gray image for those points when mask points satisfying certain condition. More...
 
template<template< class > class A>
SIMD_INLINE void ChangeColors (const View< A > &src, const uint8_t *colors, View< A > &dst)
 Changes colors for 8-bit gray image with using of color map. More...
 
template<template< class > class A>
SIMD_INLINE void NormalizeHistogram (const View< A > &src, View< A > &dst)
 Normalizes histogram for 8-bit gray image. More...
 
SIMD_INLINE double Mean (const uint32_t *histogram)
 Calculates mean from image histogram. More...
 
SIMD_INLINE uint8_t OtsuThreshold (const uint32_t *histogram)
 Calculates Otsu threhsold from image histogram. More...
 

Detailed Description

Functions for estimation of image histogram.

Function Documentation

◆ SimdAbsSecondDerivativeHistogram()

void SimdAbsSecondDerivativeHistogram ( const uint8_t *  src,
size_t  width,
size_t  height,
size_t  stride,
size_t  step,
size_t  indent,
uint32_t *  histogram 
)

Calculates histogram of second derivative for 8-bit gray image.

For all points except the boundary (defined by parameter indent):

dx = abs(src[x, y] - average(src[x+step, y], src[x-step, y]));
dy = abs(src[x, y] - average(src[x, y+step], src[x, y-step]));
histogram[max(dx, dy)]++;
Note
This function has a C++ wrapper Simd::AbsSecondDerivativeHistogram(const View<A>& src, size_t step, size_t indent, uint32_t * histogram).
Parameters
[in]src- a pointer to pixels data of input 8-bit gray image.
[in]width- an image width.
[in]height- an image height.
[in]stride- a row size of the image.
[in]step- a step for second derivative calculation.
[in]indent- a indent from image boundary.
[out]histogram- a pointer to histogram (array of 256 unsigned 32-bit values).

◆ SimdHistogram()

void SimdHistogram ( const uint8_t *  src,
size_t  width,
size_t  height,
size_t  stride,
uint32_t *  histogram 
)

Calculates histogram for 8-bit gray image.

For all points:

histogram[src[i]]++.
Note
This function has a C++ wrapper Simd::Histogram(const View<A>& src, uint32_t * histogram).
Parameters
[in]src- a pointer to pixels data of input 8-bit gray image.
[in]width- an image width.
[in]height- an image height.
[in]stride- a row size of the image.
[out]histogram- a pointer to histogram (array of 256 unsigned 32-bit values).

◆ SimdHistogramMasked()

void SimdHistogramMasked ( const uint8_t *  src,
size_t  srcStride,
size_t  width,
size_t  height,
const uint8_t *  mask,
size_t  maskStride,
uint8_t  index,
uint32_t *  histogram 
)

Calculates histogram for 8-bit gray image with using mask.

For every point:

if(mask[i] == index)
    histogram[src[i]]++.
Note
This function has a C++ wrapper Simd::HistogramMasked(const View<A> & src, const View<A> & mask, uint8_t index, uint32_t * histogram).
Parameters
[in]src- a pointer to pixels data of input 8-bit gray image.
[in]srcStride- a row size of the image.
[in]width- an image width.
[in]height- an image height.
[in]mask- a pointer to pixels data of the mask 8-bit image.
[in]maskStride- a row size of the mask image.
[in]index- a mask index.
[out]histogram- a pointer to histogram (array of 256 unsigned 32-bit values).

◆ SimdHistogramConditional()

void SimdHistogramConditional ( 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,
uint32_t *  histogram 
)

Calculates histogram of 8-bit gray image for those points when mask points satisfying certain condition.

For every point:

if(compare(mask[x, y], value))
    histogram[src[x, y]]++.
Note
This function has a C++ wrapper Simd::HistogramConditional(const View<A>& src, const View<A>& mask, uint8_t value, SimdCompareType compareType, uint32_t * histogram).
Parameters
[in]src- a pointer to pixels data of input 8-bit gray image.
[in]srcStride- a row size of the image.
[in]width- an image width.
[in]height- an image height.
[in]mask- a pointer to pixels data of the mask 8-bit image.
[in]maskStride- a row size of the mask image.
[in]value- a second value for compare operation.
[in]compareType- a compare operation type (see SimdCompareType).
[out]histogram- a pointer to histogram (array of 256 unsigned 32-bit values).

◆ SimdNormalizedColors()

void SimdNormalizedColors ( const uint32_t *  histogram,
uint8_t *  colors 
)

Gets normalized color map for given histogram.

Parameters
[in]histogram- a pointer to histogram (array of 256 unsigned 32-bit values).
[out]colors- a pointer to the color map (array of 256 unsigned 8-bit values).

◆ SimdChangeColors()

void SimdChangeColors ( const uint8_t *  src,
size_t  srcStride,
size_t  width,
size_t  height,
const uint8_t *  colors,
uint8_t *  dst,
size_t  dstStride 
)

Changes colors for 8-bit gray image with using of color map.

The input and output 8-bit gray images must have the same size. Algorithm description:

for(y = 0; y < height; ++y)
    for(x = 0; x < width; ++x)
        dst[x, y] = colors[src[x, y]];
Note
This function has a C++ wrapper Simd::ChangeColors(const View<A> & src, const uint8_t * colors, View<A> & dst).
Parameters
[in]src- a pointer to pixels data of input 8-bit gray image.
[in]srcStride- a row size of the image.
[in]width- an image width.
[in]height- an image height.
[in]colors- a pointer to the color map (array of 256 unsigned 8-bit values).
[out]dst- a pointer to pixels data of output 8-bit gray image.
[in]dstStride- a row size of the output gray image.

◆ SimdNormalizeHistogram()

void SimdNormalizeHistogram ( const uint8_t *  src,
size_t  srcStride,
size_t  width,
size_t  height,
uint8_t *  dst,
size_t  dstStride 
)

Normalizes histogram for 8-bit gray image.

The input and output 8-bit gray images must have the same size.

Note
This function has a C++ wrapper Simd::NormalizeHistogram(const View<A> & src, View<A> & dst).
Parameters
[in]src- a pointer to pixels data of input 8-bit gray image.
[in]srcStride- a row size of the image.
[in]width- an image width.
[in]height- an image height.
[out]dst- a pointer to pixels data of output 8-bit image with normalized histogram.
[in]dstStride- a row size of the output image.

◆ AbsSecondDerivativeHistogram()

void AbsSecondDerivativeHistogram ( const View< A > &  src,
size_t  step,
size_t  indent,
uint32_t *  histogram 
)

Calculates histogram of second derivative for 8-bit gray image.

For all points except the boundary (defined by parameter indent):

dx = abs(src[x, y] - average(src[x+step, y], src[x-step, y]));
dy = abs(src[x, y] - average(src[x, y+step], src[x, y-step]));
histogram[max(dx, dy)]++;
Note
This function is a C++ wrapper for function SimdAbsSecondDerivativeHistogram.
Parameters
[in]src- an input 8-bit gray image.
[in]step- a step for second derivative calculation.
[in]indent- a indent from image boundary.
[out]histogram- a pointer to histogram (array of 256 unsigned 32-bit values).

◆ Histogram()

void Histogram ( const View< A > &  src,
uint32_t *  histogram 
)

Calculates histogram for 8-bit gray image.

For all points:

histogram[src[i]]++.
Note
This function is a C++ wrapper for function SimdHistogram.
Parameters
[in]src- an input 8-bit gray image.
[out]histogram- a pointer to histogram (array of 256 unsigned 32-bit values).

◆ HistogramMasked()

void HistogramMasked ( const View< A > &  src,
const View< A > &  mask,
uint8_t  index,
uint32_t *  histogram 
)

Calculates histogram for 8-bit gray image with using mask.

For every point:

if(mask[i] == index)
    histogram[src[i]]++.
Note
This function is a C++ wrapper for function SimdHistogramMasked.
Parameters
[in]src- an input 8-bit gray image.
[in]mask- a mask 8-bit image.
[in]index- a mask index.
[out]histogram- a pointer to histogram (array of 256 unsigned 32-bit values).

◆ HistogramConditional()

void HistogramConditional ( const View< A > &  src,
const View< A > &  mask,
uint8_t  value,
SimdCompareType  compareType,
uint32_t *  histogram 
)

Calculates histogram of 8-bit gray image for those points when mask points satisfying certain condition.

For every point:

if(compare(mask[x, y], value))
    histogram[src[x, y]]++.
Note
This function is a C++ wrapper for function SimdHistogramConditional.
Parameters
[in]src- an input 8-bit gray image.
[in]mask- a mask 8-bit image.
[in]value- a second value for compare operation.
[in]compareType- a compare operation type (see SimdCompareType).
[out]histogram- a pointer to histogram (array of 256 unsigned 32-bit values).

◆ ChangeColors()

void ChangeColors ( const View< A > &  src,
const uint8_t *  colors,
View< A > &  dst 
)

Changes colors for 8-bit gray image with using of color map.

The input and output 8-bit gray images must have the same size. Algorithm description:

for(y = 0; y < height; ++y)
    for(x = 0; x < width; ++x)
        dst[x, y] = colors[src[x, y]];
Note
This function is a C++ wrapper for function SimdChangeColors.
Parameters
[in]src- an input 8-bit gray image.
[in]colors- a pointer to the color map (array of 256 unsigned 8-bit values).
[out]dst- an output 8-bit gray image.

◆ NormalizeHistogram()

void NormalizeHistogram ( const View< A > &  src,
View< A > &  dst 
)

Normalizes histogram for 8-bit gray image.

The input and output 8-bit gray images must have the same size.

Note
This function is a C++ wrapper for function SimdNormalizeHistogram.
Parameters
[in]src- an input 8-bit gray image.
[out]dst- an output 8-bit image with normalized histogram.

◆ Mean()

void uint8_t Mean ( const uint32_t *  histogram)

Calculates mean from image histogram.

Parameters
[in]histogram- a pointer to image histogram (array of 256 unsigned 32-bit integre values).
Returns
value of mean for image with given histogram.

◆ OtsuThreshold()

void uint8_t OtsuThreshold ( const uint32_t *  histogram)

Calculates Otsu threhsold from image histogram.

Parameters
[in]histogram- a pointer to image histogram (array of 256 unsigned 32-bit integre values).
Returns
value of Otsu threshold for image with given histogram.