Gaussian blur image filters. More...
Functions | |
SIMD_API void | SimdGaussianBlur3x3 (const uint8_t *src, size_t srcStride, size_t width, size_t height, size_t channelCount, uint8_t *dst, size_t dstStride) |
Performs Gaussian blur filtration with window 3x3. More... | |
SIMD_API void * | SimdGaussianBlurInit (size_t width, size_t height, size_t channels, const float *sigma, const float *epsilon) |
Creates Gaussian blur filter context. More... | |
SIMD_API void | SimdGaussianBlurRun (const void *filter, const uint8_t *src, size_t srcStride, uint8_t *dst, size_t dstStride) |
Performs image Gaussian bluring. More... | |
Detailed Description
Gaussian blur image filters.
Function Documentation
◆ SimdGaussianBlur3x3()
void SimdGaussianBlur3x3 | ( | const uint8_t * | src, |
size_t | srcStride, | ||
size_t | width, | ||
size_t | height, | ||
size_t | channelCount, | ||
uint8_t * | dst, | ||
size_t | dstStride | ||
) |
Performs Gaussian blur filtration with window 3x3.
For every point:
dst[x, y] = (src[x-1, y-1] + 2*src[x, y-1] + src[x+1, y-1] + 2*(src[x-1, y] + 2*src[x, y] + src[x+1, y]) + src[x-1, y+1] + 2*src[x, y+1] + src[x+1, y+1] + 8) / 16;
All images must have the same width, height and format (8-bit gray, 16-bit UV, 24-bit BGR or 32-bit BGRA).
- Note
- This function has a C++ wrapper Simd::GaussianBlur3x3(const View<A>& src, View<A>& dst).
- Parameters
-
[in] src - a pointer to pixels data of source image. [in] srcStride - a row size of the src image. [in] width - an image width. [in] height - an image height. [in] channelCount - a channel count. [out] dst - a pointer to pixels data of destination image. [in] dstStride - a row size of the dst image.
◆ SimdGaussianBlurInit()
void * SimdGaussianBlurInit | ( | size_t | width, |
size_t | height, | ||
size_t | channels, | ||
const float * | sigma, | ||
const float * | epsilon | ||
) |
Creates Gaussian blur filter context.
In particular calculates Gaussian blur coefficients:
half = floor(sqrt(log(1/epsilon)) * sigma); weight[2*half + 1]; for(x = -half; x <= half; ++x) weight[x + half] = exp(-sqr(x / sigma) / 2); sum = 0; for (x = -half; x <= half; ++x) sum += weight[x + half]; for (x = -half; x <= half; ++x) weight[x + half] /= sum;
- Parameters
-
[in] width - a width of input and output image. [in] height - a height of input and output image.
[in] channels - a channel number of input and output image. Its value must be in range [1..4]. [in] sigma - a pointer to sigma parameter (blur radius). Its value must be greater than 0.000001. [in] epsilon - a pointer to epsilon parameter (permissible relative error). Its value must be greater than 0.000001. Pointer can be NULL and by default value 0.001 is used.
- Returns
- a pointer to filter context. On error it returns NULL. This pointer is used in functions SimdGaussianBlurRun. It must be released with using of function SimdRelease.
◆ SimdGaussianBlurRun()
void SimdGaussianBlurRun | ( | const void * | filter, |
const uint8_t * | src, | ||
size_t | srcStride, | ||
uint8_t * | dst, | ||
size_t | dstStride | ||
) |
Performs image Gaussian bluring.
Bluring algorithm for every point:
sum = 0; for(x = -half; x <= half; ++x) { sx = min(max(0, dx + x), width - 1); for(y = -half; y <= half; ++y) { sy = min(max(0, dy + y), height - 1); sum += src[sx, sy]*weight[x + half]*weight[y + half]; } } dst[dx, dy] = sum;
- Parameters
-
[in] filter - a filter context. It must be created by function SimdGaussianBlurInit and released by function SimdRelease. [in] src - a pointer to pixels data of the original input image. [in] srcStride - a row size (in bytes) of the input image. [out] dst - a pointer to pixels data of the filtered output image. [in] dstStride - a row size (in bytes) of the output image.