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 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 HOG features for 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) |
Separates one interleaved 32-bit float point image to 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 separable filter to given image of 32-bit float point format. More... | |
SIMD_API void | SimdHogLiteExtractFeatures (const uint8_t *src, size_t srcStride, size_t width, size_t height, size_t cell, float *features, size_t featuresStride) |
Extracts lite HOG features for 8-bit gray image. More... | |
SIMD_API void | SimdHogLiteFilterFeatures (const float *src, size_t srcStride, size_t srcWidth, size_t srcHeight, size_t featureSize, const float *filter, size_t filterWidth, size_t filterHeight, const uint32_t *mask, size_t maskStride, float *dst, size_t dstStride) |
Applies filter to lite HOG features. More... | |
SIMD_API void | SimdHogLiteResizeFeatures (const float *src, size_t srcStride, size_t srcWidth, size_t srcHeight, size_t featureSize, float *dst, size_t dstStride, size_t dstWidth, size_t dstHeight) |
Resizes 2D-array with lite HOG features. More... | |
SIMD_API void | SimdHogLiteCompressFeatures (const float *src, size_t srcStride, size_t width, size_t height, const float *pca, float *dst, size_t dstStride) |
Compresses 16 features to 8 features for 2D-array. More... | |
SIMD_API void | SimdHogLiteFilterSeparable (const float *src, size_t srcStride, size_t srcWidth, size_t srcHeight, size_t featureSize, const float *hFilter, size_t hSize, const float *vFilter, size_t vSize, float *dst, size_t dstStride, int add) |
Applies separable filter to lite HOG features. More... | |
SIMD_API void | SimdHogLiteFindMax7x7 (const float *a, size_t aStride, const float *b, size_t bStride, size_t height, float *value, size_t *col, size_t *row) |
Adds two 32-bit float point 2D-array with size 7x7 and finds value and position of maximum in the result array. More... | |
SIMD_API void | SimdHogLiteCreateMask (const float *src, size_t srcStride, size_t srcWidth, size_t srcHeight, const float *threshold, size_t scale, size_t size, uint32_t *dst, size_t dstStride) |
Creates mask for function SimdHogLiteFilterFeatures. 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... | |
template<template< class > class A> | |
SIMD_INLINE void | HogLiteExtractFeatures (const View< A > &src, size_t cell, float *features, size_t featuresStride) |
Extracts lite 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 8-bit gray image.
Calculates HOG direction histogram for every cell of 8-bit gray image. This function is useful for face recognition.
- 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] 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 has size grater 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 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 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] 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 has size grater 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 | ||
) |
Separates one interleaved 32-bit float point image to separate planes.
- Parameters
-
[in] src - a pointer to the input interleaved 32-bit float point image. [in] srcStride - a row size of input image. [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.
◆ 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 separable filter to given image of 32-bit float point format.
For every point (except border):
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 at least not less then size of filter: (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] width - a width of input image. It must be not less then size of row filter. [in] height - a height of input image. It must be not less then 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] add - a flag which signalizes that result has to be added to existing image.
◆ SimdHogLiteExtractFeatures()
void SimdHogLiteExtractFeatures | ( | const uint8_t * | src, |
size_t | srcStride, | ||
size_t | width, | ||
size_t | height, | ||
size_t | cell, | ||
float * | features, | ||
size_t | featuresStride | ||
) |
Extracts lite HOG features for 8-bit gray image.
Extracts lite (for 8 directions) HOG features 8-bit gray image. 16 features are extracted for 8x8 or 4x4 cell size and 2x2 block size.
- Note
- This function has a C++ wrapper Simd::HogLiteExtractFeatures(const View<A> & src, size_t cell, float * features, size_t featuresStride).
- 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. Its minimal value is cell*3. [in] height - an image height. Its minimal value is cell*3. [in] cell - a size of cell. It must be 4 or 8. [out] features - a pointer to buffer with features. Array must has size greater or equal to (height/cell - 2)*featuresStride. [in] featuresStride - a row size of the buffer with features. It must be greater or equal to (width/cell - 2)*16.
◆ SimdHogLiteFilterFeatures()
void SimdHogLiteFilterFeatures | ( | const float * | src, |
size_t | srcStride, | ||
size_t | srcWidth, | ||
size_t | srcHeight, | ||
size_t | featureSize, | ||
const float * | filter, | ||
size_t | filterWidth, | ||
size_t | filterHeight, | ||
const uint32_t * | mask, | ||
size_t | maskStride, | ||
float * | dst, | ||
size_t | dstStride | ||
) |
Applies filter to lite HOG features.
Applies filter of square shape to lite HOG features.
For every point of output image:
if(mask[x, y]) sum = 0; for(dy = 0; dy < filterHeight; dy++) for(dx = 0; dx < filterWidth*featureSize; dx++) sum += src[x*featureSize + dx, y + dy]*filter[dx, dy]; dst[x, y] = sum; else dst[x, y] = -FLT_MAX;
- Parameters
-
[in] src - a pointer to the input 32-bit float array with features. [in] srcStride - a row size of input array with features. [in] srcWidth - a width of input array with features. Its minimal value is filterSize. [in] srcHeight - a height of input array with features. Its minimal value is filterSize. [in] featureSize - a size of cell with features. It must be 8 or 16. [in] filter - a pointer to the 32-bit float array with filter values. Array must have size equal to filterSize*filterSize*featureSize. [in] filterWidth - a width of used filter. [in] filterHeight - a height of used filter. [in] mask - a pointer to the 32-bit integer array with mask (0 or -1). Pointer can be null otherwise the array must have size greater then (srcHeight - filterSize)*(srcWidth - filterSize). A function SimdHogLiteCreateMask is usefull in order to create this mask. [in] maskStride - a row size of mask array. [out] dst - a pointer to output buffer with result of filtration. Array must have size greater then (srcHeight - filterSize)*(srcWidth - filterSize). [in] dstStride - a row size of the output buffer with result of filtration.
◆ SimdHogLiteResizeFeatures()
void SimdHogLiteResizeFeatures | ( | const float * | src, |
size_t | srcStride, | ||
size_t | srcWidth, | ||
size_t | srcHeight, | ||
size_t | featureSize, | ||
float * | dst, | ||
size_t | dstStride, | ||
size_t | dstWidth, | ||
size_t | dstHeight | ||
) |
Resizes 2D-array with lite HOG features.
Resizes 2D-array with lite HOG features. It use method of bilinear interpolation.
- Parameters
-
[in] src - a pointer to the input 32-bit float array with features. [in] srcStride - a row size of input array with features. [in] srcWidth - a width of input array with features. [in] srcHeight - a height of input array with features. [in] featureSize - a size of cell with features. It must be 8 or 16. [out] dst - a pointer to the output 32-bit float array with features. [in] dstStride - a row size of output array with features. [in] dstWidth - a width of output array with features. [in] dstHeight - a height of output array with features.
◆ SimdHogLiteCompressFeatures()
void SimdHogLiteCompressFeatures | ( | const float * | src, |
size_t | srcStride, | ||
size_t | width, | ||
size_t | height, | ||
const float * | pca, | ||
float * | dst, | ||
size_t | dstStride | ||
) |
Compresses 16 features to 8 features for 2D-array.
Compresses 16 features to 8 features for 2D-array. The method uses PCA.
- Parameters
-
[in] src - a pointer to the input 32-bit float array with uncompessed features. [in] srcStride - a row size of input array with uncompessed features. [in] width - a width of 2D-array with features. [in] height - a height of 2D-array with features. [in] pca - a pointer to the PCA matrix with size 16x8. [out] dst - a pointer to the output 32-bit float array with compessed features. [in] dstStride - a row size of output array with compessed features.
◆ SimdHogLiteFilterSeparable()
void SimdHogLiteFilterSeparable | ( | const float * | src, |
size_t | srcStride, | ||
size_t | srcWidth, | ||
size_t | srcHeight, | ||
size_t | featureSize, | ||
const float * | hFilter, | ||
size_t | hSize, | ||
const float * | vFilter, | ||
size_t | vSize, | ||
float * | dst, | ||
size_t | dstStride, | ||
int | add | ||
) |
Applies separable filter to lite HOG features.
For every point (except border):
sum = 0; for(dy = 0; dy < vSize; dy++) for(dx = 0; dx < hSize*featureSize; dx++) sum += src[x*featureSize + dx, y + dy]*vFilter[dy]*hFilter[dx]; if(add) dst[x, y] += sum; else dst[x, y] = sum;
- Note
- Input image has to have size at least not less then size of filter: (srcWidth <= hSize and srcHeight <= vSize).
- Parameters
-
[in] src - a pointer to the input 32-bit float array with features. [in] srcStride - a row size of input array with features. [in] srcWidth - a width of input array with features. Its minimal value is hSize. [in] srcHeight - a height of input array with features. Its minimal value is vSize. [in] featureSize - a size of cell with features. It must be 8 or 16. [in] hFilter - a pointer to 32-bit float point array with horizontal filter. [in] hSize - a size of horizontal filter (in featureSize). Total size of horizontal filter is hSize*featureSize. [in] vFilter - a pointer to 32-bit float point array with vertical filter. [in] vSize- a size of vertical filter. [in,out] dst - a pointer to output 32-bit float point image. [in] dstStride - a row size of output image. [in] add - a flag which signalizes that result has to be added to existing image.
◆ SimdHogLiteFindMax7x7()
void SimdHogLiteFindMax7x7 | ( | const float * | a, |
size_t | aStride, | ||
const float * | b, | ||
size_t | bStride, | ||
size_t | height, | ||
float * | value, | ||
size_t * | col, | ||
size_t * | row | ||
) |
Adds two 32-bit float point 2D-array with size 7x7 and finds value and position of maximum in the result array.
Algorithm description:
value = -FLT_MAX; for (y = 0; y < height; ++y) { for (x = 0; x < 7; ++x) { v = a[x, y] + b[x, y]; if (v > value) { value = v; col = x; row = y; break; } } }
- Parameters
-
[in] a - a pointer to the first input 32-bit float array with size 7x7. [in] aStride - a row size of the first input array. [in] b - a pointer to the second input 32-bit float array with size 7x7. [in] bStride - a row size of the second input array. [in] height - a height of the input arrays. It must be equal or less then 7. [out] value - a pointer to the output 32-bit float value with maximum. [out] col - a pointer to the output integer value with x-position of maximum. [out] row - a pointer to the output integer value with y-position of maximum.
◆ SimdHogLiteCreateMask()
void SimdHogLiteCreateMask | ( | const float * | src, |
size_t | srcStride, | ||
size_t | srcWidth, | ||
size_t | srcHeight, | ||
const float * | threshold, | ||
size_t | scale, | ||
size_t | size, | ||
uint32_t * | dst, | ||
size_t | dstStride | ||
) |
Creates mask for function SimdHogLiteFilterFeatures.
Zeroes destination mask. Then for every source point:
if(src[x, y] > threshold) for (dy = 0; dy < size; ++dy) for (dx = 0; dx < size; ++dx) dst[x*scale + dx, y*scale + dy] = -1;
- Parameters
-
[in] src - a pointer to the input 32-bit float 2D array. [in] srcStride - a row size of the input array. [in] srcWidth - a width of input array. [in] srcHeight - a height of input array. [in] threshold - a pointer to 32-bit float threshold. [in] scale - a scale coefficient between input and output array. [in] size - a size of neighborhood. [out] dst - a pointer to the output 32-bit integer array with mask (0 or -1). [in] dstStride - a row size of the output array.
◆ 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 has size grater or equal to (width/8)*(height/8)*31.
◆ HogLiteExtractFeatures()
void HogLiteExtractFeatures | ( | const View< A > & | src, |
size_t | cell, | ||
float * | features, | ||
size_t | featuresStride | ||
) |
Extracts lite HOG features for 8-bit gray image.
Extracts lite (for 8 directions) HOG features 8-bit gray image. 16 features are extracted for 8x8 or 4x4 cell size and 2x2 block size.
- Note
- This function is a C++ wrapper for function SimdHogLiteExtractFeatures.
- Parameters
-
[in] src - an input 8-bit gray image. Its width and height must be a multiple of cell and greater or equal to cell*3. [in] cell - a size of cell. It must be 4 or 8. [out] features - a pointer to buffer with features. Array must has size grater or equal to (height/cell - 2)*featuresStride. [in] featuresStride - a row size of the buffer with features. It must be grater or equal to (width/cell - 2)*16.