Functions for extraction and processing of HOG features. More...
Functions | |
| SIMD_API void | SimdHogDirectionHistograms (const uint8_t *src, size_t stride, size_t width, size_t height, size_t cellX, size_t cellY, size_t quantization, float *histograms) |
| Calculates HOG direction histograms for an 8-bit gray image. More... | |
| SIMD_API void | SimdHogExtractFeatures (const uint8_t *src, size_t stride, size_t width, size_t height, float *features) |
| Extracts 31 HOG features per 8x8 cell from an 8-bit gray image. More... | |
| SIMD_API void | SimdHogDeinterleave (const float *src, size_t srcStride, size_t width, size_t height, size_t count, float **dst, size_t dstStride) |
| Deinterleaves a 32-bit floating-point image into separate planes. More... | |
| SIMD_API void | SimdHogFilterSeparable (const float *src, size_t srcStride, size_t width, size_t height, const float *rowFilter, size_t rowSize, const float *colFilter, size_t colSize, float *dst, size_t dstStride, int add) |
| Applies a valid-area separable filter to a 32-bit floating-point image. More... | |
| template<template< class > class A> | |
| SIMD_INLINE void | HogExtractFeatures (const View< A > &src, float *features) |
| Extracts HOG features for 8-bit gray image. More... | |
Detailed Description
Functions for extraction and processing of HOG features.
Function Documentation
◆ SimdHogDirectionHistograms()
| void SimdHogDirectionHistograms | ( | const uint8_t * | src, |
| size_t | stride, | ||
| size_t | width, | ||
| size_t | height, | ||
| size_t | cellX, | ||
| size_t | cellY, | ||
| size_t | quantization, | ||
| float * | histograms | ||
| ) |
Calculates HOG direction histograms for an 8-bit gray image.
The function uses central differences for pixels except the one-pixel image border:
dx = src[x + 1, y] - src[x - 1, y]; dy = src[x, y + 1] - src[x, y - 1]; magnitude = Sqrt(dx*dx + dy*dy); direction = index with maximal absolute dot product against quantization directions;
Pixel magnitudes are bilinearly distributed to neighboring cells. The output buffer is cleared and then filled in row-major cell order: histograms[(cellYIndex*(width/cellX) + cellXIndex)*quantization + direction].
- Note
- This function has a C++ wrapper Simd::HogDirectionHistograms(const View<A> & src, const Point<ptrdiff_t> & cell, size_t quantization, float * histograms).
- Parameters
-
[in] src - a pointer to pixels data of input 8-bit gray image. [in] stride - a row size of the image (in bytes). [in] width - an image width. It must be a multiple of cellX. [in] height - an image height. It must be a multiple of cellY. [in] cellX - a width of cell. [in] cellY - a height of cell. [in] quantization - a direction quantization. Must be even. [out] histograms - a pointer to buffer with histograms. Array must have size greater or equal to (width/cellX)*(height/cellY)*quantization.
◆ SimdHogExtractFeatures()
| void SimdHogExtractFeatures | ( | const uint8_t * | src, |
| size_t | stride, | ||
| size_t | width, | ||
| size_t | height, | ||
| float * | features | ||
| ) |
Extracts 31 HOG features per 8x8 cell from an 8-bit gray image.
The function builds 18 signed gradient-orientation histograms for 8x8 cells, estimates normalization factors from neighboring 2x2 blocks, clips normalized values by 0.2, and writes 31 features per cell:
features[(cellY*(width/8) + cellX)*31 + 0..17] - contrast-sensitive features; features[(cellY*(width/8) + cellX)*31 + 18..26] - contrast-insensitive features; features[(cellY*(width/8) + cellX)*31 + 27..30] - texture energy features.
- Note
- This function has a C++ wrapper Simd::HogExtractFeatures(const View<A> & src, float * features).
- Parameters
-
[in] src - a pointer to pixels data of input 8-bit gray image. [in] stride - a row size of the image (in bytes). [in] width - an image width. It must be a multiple of 8. Its minimal value is 16. [in] height - an image height. It must be a multiple of 8. Its minimal value is 16. [out] features - a pointer to buffer with features. Array must have size greater or equal to (width/8)*(height/8)*31.
◆ SimdHogDeinterleave()
| void SimdHogDeinterleave | ( | const float * | src, |
| size_t | srcStride, | ||
| size_t | width, | ||
| size_t | height, | ||
| size_t | count, | ||
| float ** | dst, | ||
| size_t | dstStride | ||
| ) |
Deinterleaves a 32-bit floating-point image into separate planes.
For every point and plane:
dst[i][y*dstStride + x] = src[y*srcStride + x*count + i];
Strides are measured in 32-bit floats.
- Parameters
-
[in] src - a pointer to the input interleaved 32-bit float point image. [in] srcStride - a row size of input image (in 32-bit floats). [in] width - a width of input and output images. [in] height - a height of input and output images. [in] count - the number of output planes. [out] dst - a pointer to array with pointers to output planes. [in] dstStride - a row size of output images (in 32-bit floats).
◆ SimdHogFilterSeparable()
| void SimdHogFilterSeparable | ( | const float * | src, |
| size_t | srcStride, | ||
| size_t | width, | ||
| size_t | height, | ||
| const float * | rowFilter, | ||
| size_t | rowSize, | ||
| const float * | colFilter, | ||
| size_t | colSize, | ||
| float * | dst, | ||
| size_t | dstStride, | ||
| int | add | ||
| ) |
Applies a valid-area separable filter to a 32-bit floating-point image.
The destination size is (width - rowSize + 1) by (height - colSize + 1). For every output point:
sum = 0;
for(dy = 0; dy < colSize; dy++)
for(dx = 0; dx < rowSize; dx++)
sum += src[x + dx, y + dy]*colFilter[dy]*rowFilter[dx];
if(add)
dst[x, y] += sum;
else
dst[x, y] = sum;
- Note
- Input image has to have size not less than the filter size: width >= rowSize and height >= colSize.
- Parameters
-
[in] src - a pointer to input 32-bit float point image. [in] srcStride - a row size of input image (in 32-bit floats). [in] width - a width of input image. It must be not less than size of row filter. [in] height - a height of input image. It must be not less than size of column filter. [in] rowFilter - a pointer to 32-bit float point array with row filter. [in] rowSize - a size of row filter. [in] colFilter - a pointer to 32-bit float point array with column filter. [in] colSize - a size of column filter. [in,out] dst - a pointer to output 32-bit float point image. [in] dstStride - a row size of output image (in 32-bit floats). [in] add - a flag: if non-zero, the filtered result is added to dst; otherwise dst is overwritten.
◆ HogExtractFeatures()
| void HogExtractFeatures | ( | const View< A > & | src, |
| float * | features | ||
| ) |
Extracts HOG features for 8-bit gray image.
Extracts HOG features 8-bit gray image. 31 features are extracted for 8x8 cell size and 2x2 block size. This function is useful for face recognition.
- Note
- This function is a C++ wrapper for function SimdHogExtractFeatures.
- Parameters
-
[in] src - an input 8-bit gray image. Its width and height must be a multiple of 8 and greater or equal to 16. [out] features - a pointer to buffer with features. Array must have size greater or equal to (width/8)*(height/8)*31.