Functions for image binarization. More...
Functions | |
SIMD_API void | SimdBinarization (const uint8_t *src, size_t srcStride, size_t width, size_t height, uint8_t value, uint8_t positive, uint8_t negative, uint8_t *dst, size_t dstStride, SimdCompareType compareType) |
Performs binarization of 8-bit gray image. More... | |
SIMD_API void | SimdAveragingBinarization (const uint8_t *src, size_t srcStride, size_t width, size_t height, uint8_t value, size_t neighborhood, uint8_t threshold, uint8_t positive, uint8_t negative, uint8_t *dst, size_t dstStride, SimdCompareType compareType) |
Performs averaging binarization of 8-bit gray image. More... | |
SIMD_API void | SimdAveragingBinarizationV2 (const uint8_t *src, size_t srcStride, size_t width, size_t height, size_t neighborhood, int32_t shift, uint8_t positive, uint8_t negative, uint8_t *dst, size_t dstStride) |
Performs averaging binarization of 8-bit gray image. More... | |
template<template< class > class A> | |
SIMD_INLINE void | Binarization (const View< A > &src, uint8_t value, uint8_t positive, uint8_t negative, View< A > &dst, SimdCompareType compareType) |
Performs binarization of 8-bit gray image. More... | |
template<template< class > class A> | |
SIMD_INLINE void | AveragingBinarization (const View< A > &src, uint8_t value, size_t neighborhood, uint8_t threshold, uint8_t positive, uint8_t negative, View< A > &dst, SimdCompareType compareType) |
Performs averaging binarization of 8-bit gray image. More... | |
template<template< class > class A> | |
SIMD_INLINE void | AveragingBinarizationV2 (const View< A > &src, size_t neighborhood, int32_t shift, uint8_t positive, uint8_t negative, View< A > &dst) |
Performs averaging binarization of 8-bit gray image. More... | |
Detailed Description
Functions for image binarization.
Function Documentation
◆ SimdBinarization()
void SimdBinarization | ( | const uint8_t * | src, |
size_t | srcStride, | ||
size_t | width, | ||
size_t | height, | ||
uint8_t | value, | ||
uint8_t | positive, | ||
uint8_t | negative, | ||
uint8_t * | dst, | ||
size_t | dstStride, | ||
SimdCompareType | compareType | ||
) |
Performs binarization of 8-bit gray image.
All images must have 8-bit gray format and must have the same width and height.
For every point:
dst[i] = compare(src[i], value) ? positive : negative;
where compare(a, b) depends from compareType (see SimdCompareType).
- Note
- This function has a C++ wrapper Simd::Binarization(const View<A>& src, uint8_t value, uint8_t positive, uint8_t negative, View<A>& dst, SimdCompareType compareType).
- Parameters
-
[in] src - a pointer to pixels data of input 8-bit gray image (first value for compare operation). [in] srcStride - a row size of the src image. [in] width - an image width. [in] height - an image height. [in] value - a second value for compare operation. [in] positive - a destination value if comparison operation has a positive result. [in] negative - a destination value if comparison operation has a negative result. [out] dst - a pointer to pixels data of output 8-bit gray binarized image. [in] dstStride - a row size of the dst image. [in] compareType - a compare operation type (see SimdCompareType).
◆ SimdAveragingBinarization()
void SimdAveragingBinarization | ( | const uint8_t * | src, |
size_t | srcStride, | ||
size_t | width, | ||
size_t | height, | ||
uint8_t | value, | ||
size_t | neighborhood, | ||
uint8_t | threshold, | ||
uint8_t | positive, | ||
uint8_t | negative, | ||
uint8_t * | dst, | ||
size_t | dstStride, | ||
SimdCompareType | compareType | ||
) |
Performs averaging binarization of 8-bit gray image.
All images must have 8-bit gray format and must have the same width and height.
For every point:
sum = 0; area = 0; for(dy = -neighborhood; dy <= neighborhood; ++dy) { for(dx = -neighborhood; dx <= neighborhood; ++dx) { if(x + dx >= 0 && x + dx < width && y + dy >= 0 && y + dy < height) { area++; if(compare(src[x + dx, x + dy], value)) sum++; } } } dst[x, y] = sum*255 > area*threshold ? positive : negative;
where compare(a, b) depends from compareType (see SimdCompareType).
- Note
- This function has a C++ wrapper Simd::AveragingBinarization(const View<A>& src, uint8_t value, size_t neighborhood, uint8_t threshold, uint8_t positive, uint8_t negative, View<A>& dst, SimdCompareType compareType).
- Parameters
-
[in] src - a pointer to pixels data of input 8-bit gray image (first value for compare operation). [in] srcStride - a row size of the src image. [in] width - an image width. [in] height - an image height. [in] value - a second value for compare operation. [in] neighborhood - an averaging neighborhood. [in] threshold - a threshold value for binarization. It can range from 0 to 255. [in] positive - a destination value if for neighborhood of this point number of positive comparison is greater then threshold. [in] negative - a destination value if for neighborhood of this point number of positive comparison is lesser or equal then threshold. [out] dst - a pointer to pixels data of output 8-bit gray binarized image. [in] dstStride - a row size of the dst image. [in] compareType - a compare operation type (see SimdCompareType).
◆ SimdAveragingBinarizationV2()
void SimdAveragingBinarizationV2 | ( | const uint8_t * | src, |
size_t | srcStride, | ||
size_t | width, | ||
size_t | height, | ||
size_t | neighborhood, | ||
int32_t | shift, | ||
uint8_t | positive, | ||
uint8_t | negative, | ||
uint8_t * | dst, | ||
size_t | dstStride | ||
) |
Performs averaging binarization of 8-bit gray image.
All images must have 8-bit gray format and must have the same width and height.
For every point:
sum = 0; area = 0; for(dy = -neighborhood; dy <= neighborhood; ++dy) { for(dx = -neighborhood; dx <= neighborhood; ++dx) { if(x + dx >= 0 && x + dx < width && y + dy >= 0 && y + dy < height) { area++; sum += src[x + dx, x + dy]; } } } dst[x, y] = (src[x, y] + shift)*area > sum ? positive : negative;
- Note
- This function has a C++ wrapper Simd::AveragingBinarizationV2(const View<A>& src, size_t neighborhood, int32_t shift, uint8_t positive, uint8_t negative, View<A>& dst).
- Parameters
-
[in] src - a pointer to pixels data of input 8-bit gray image. [in] srcStride - a row size of the src image. [in] width - an image width. [in] height - an image height. [in] neighborhood - an averaging neighborhood. [in] shift - a shift value for binarization. It can range from -255 to 255. [in] positive - a destination value for positive value of condition (seen before). [in] negative - a destination value for negative value of condition (seen before). [out] dst - a pointer to pixels data of output 8-bit gray binarized image. [in] dstStride - a row size of the dst image.
◆ Binarization()
void Binarization | ( | const View< A > & | src, |
uint8_t | value, | ||
uint8_t | positive, | ||
uint8_t | negative, | ||
View< A > & | dst, | ||
SimdCompareType | compareType | ||
) |
Performs binarization of 8-bit gray image.
All images must have 8-bit gray format and must have the same width and height.
For every point:
dst[i] = compare(src[i], value) ? positive : negative;
where compare(a, b) depends from compareType (see SimdCompareType).
- Note
- This function is a C++ wrapper for function SimdBinarization.
- Parameters
-
[in] src - an input 8-bit gray image (first value for compare operation). [in] value - a second value for compare operation. [in] positive - a destination value if comparison operation has a positive result. [in] negative - a destination value if comparison operation has a negative result. [out] dst - an output 8-bit gray binarized image. [in] compareType - a compare operation type (see SimdCompareType).
◆ AveragingBinarization()
void AveragingBinarization | ( | const View< A > & | src, |
uint8_t | value, | ||
size_t | neighborhood, | ||
uint8_t | threshold, | ||
uint8_t | positive, | ||
uint8_t | negative, | ||
View< A > & | dst, | ||
SimdCompareType | compareType | ||
) |
Performs averaging binarization of 8-bit gray image.
All images must have 8-bit gray format and must have the same width and height.
For every point:
sum = 0; area = 0; for(dy = -neighborhood; dy <= neighborhood; ++dy) { for(dx = -neighborhood; dx <= neighborhood; ++dx) { if(x + dx >= 0 && x + dx < width && y + dy >= 0 && y + dy < height) { area++; if(compare(src[x + dx, x + dy], value)) sum++; } } } dst[x, y] = sum*255 > area*threshold ? positive : negative;
where compare(a, b) depends from compareType (see SimdCompareType).
- Note
- This function is a C++ wrapper for function SimdAveragingBinarization.
- Parameters
-
[in] src - an input 8-bit gray image (first value for compare operation). [in] value - a second value for compare operation. [in] neighborhood - an averaging neighborhood. [in] threshold - a threshold value for binarization. It can range from 0 to 255. [in] positive - a destination value if for neighborhood of this point number of positive comparison is greater then threshold. [in] negative - a destination value if for neighborhood of this point number of positive comparison is lesser or equal then threshold. [out] dst - an output 8-bit gray binarized image. [in] compareType - a compare operation type (see SimdCompareType).
◆ AveragingBinarizationV2()
void AveragingBinarizationV2 | ( | const View< A > & | src, |
size_t | neighborhood, | ||
int32_t | shift, | ||
uint8_t | positive, | ||
uint8_t | negative, | ||
View< A > & | dst | ||
) |
Performs averaging binarization of 8-bit gray image.
All images must have 8-bit gray format and must have the same width and height.
For every point:
sum = 0; area = 0; for(dy = -neighborhood; dy <= neighborhood; ++dy) { for(dx = -neighborhood; dx <= neighborhood; ++dx) { if(x + dx >= 0 && x + dx < width && y + dy >= 0 && y + dy < height) { area++; sum += src[x + dx, x + dy]; } } } dst[x, y] = (src[x, y] + shift)*area > sum ? positive : negative;
- Note
- This function is a C++ wrapper for function SimdAveragingBinarizationV2.
- Parameters
-
[in] src - an input 8-bit gray image (first value for compare operation). [in] neighborhood - an averaging neighborhood. [in] shift - a shift value for binarization. It can range from -255 to 255. [in] positive - a destination value for positive value of condition (seen before). [in] negative - a destination value for negative value of condition (seen before). [out] dst - an output 8-bit gray binarized image.