Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/2026.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ <h5>Removing</h5>
<li>Function SimdFill.</li>
<li>Function SimdFillBgr.</li>
<li>Function SimdFillBgra.</li>
<li>Function SimdHogDirectionHistograms.</li>
<li>C++ wrapper Simd::HogDirectionHistograms.</li>
</ul>

<h4>Python wrapper</h4>
Expand Down Expand Up @@ -90,6 +92,7 @@ <h5>Removing</h5>
<li>Tests for verifying functionality of function Fill.</li>
<li>Tests for verifying functionality of function FillBgr.</li>
<li>Tests for verifying functionality of function FillBgra.</li>
<li>Tests for verifying functionality of function HogDirectionHistograms.</li>
</ul>

<h4>Documentation</h4>
Expand Down
3 changes: 0 additions & 3 deletions src/Simd/SimdAvx2.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,6 @@ namespace Simd
void AbsSecondDerivativeHistogram(const uint8_t *src, size_t width, size_t height, size_t stride,
size_t step, size_t indent, uint32_t * histogram);

void HogDirectionHistograms(const uint8_t * src, size_t stride, size_t width, size_t height,
size_t cellX, size_t cellY, size_t quantization, float * histograms);

void HogExtractFeatures(const uint8_t * src, size_t stride, size_t width, size_t height, float * features);

void HogDeinterleave(const float * src, size_t srcStride, size_t width, size_t height, size_t count, float ** dst, size_t dstStride);
Expand Down
372 changes: 0 additions & 372 deletions src/Simd/SimdAvx2Hog.cpp

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions src/Simd/SimdAvx512bw.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,6 @@ namespace Simd

void Gemm32fNT(size_t M, size_t N, size_t K, const float* alpha, const float* A, size_t lda, const float* B, size_t ldb, const float* beta, float* C, size_t ldc);

void HogDirectionHistograms(const uint8_t * src, size_t stride, size_t width, size_t height,
size_t cellX, size_t cellY, size_t quantization, float * histograms);

void HogExtractFeatures(const uint8_t * src, size_t stride, size_t width, size_t height, float * features);

void HogDeinterleave(const float * src, size_t srcStride, size_t width, size_t height, size_t count, float ** dst, size_t dstStride);
Expand Down
345 changes: 0 additions & 345 deletions src/Simd/SimdAvx512bwHog.cpp

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions src/Simd/SimdBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,6 @@ namespace Simd

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

void AddRowToHistograms(int * indexes, float * values, size_t row, size_t width, size_t height,
size_t cellX, size_t cellY, size_t quantization, float * histograms);

void HogDirectionHistograms(const uint8_t * src, size_t stride, size_t width, size_t height,
size_t cellX, size_t cellY, size_t quantization, float * histograms);

void HogExtractFeatures(const uint8_t * src, size_t stride, size_t width, size_t height, float * features);

void HogDeinterleave(const float * src, size_t srcStride, size_t width, size_t height, size_t count, float ** dst, size_t dstStride);
Expand Down
213 changes: 0 additions & 213 deletions src/Simd/SimdBaseHog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,219 +27,6 @@ namespace Simd
{
namespace Base
{
namespace
{
struct Buffer
{
const int size;
float * cos, *sin;
int * index;
float * value;

Buffer(size_t width, size_t quantization)
: size((int)quantization / 2)
{
_p = Allocate(width*(sizeof(int) + sizeof(float)) + sizeof(float) * 2 * size);
index = (int*)_p;
value = (float*)index + width;
cos = value + width;
sin = cos + size;
for (int i = 0; i < size; ++i)
{
cos[i] = (float)::cos(i*M_PI / size);
sin[i] = (float)::sin(i*M_PI / size);
}
}

~Buffer()
{
Free(_p);
}

private:
void *_p;
};
}

void AddRowToHistograms(int * indexes, float * values, size_t row, size_t width, size_t height, size_t cellX, size_t cellY, size_t quantization, float * histograms)
{
int blockX = int(width / cellX);
int blockY = int(height / cellY);
int blockStride = int(quantization*blockX);

float yp = ((float)row + 0.5f) / (float)cellY - 0.5f;
int iyp = (int)floor(yp);
float vy0 = yp - iyp;
float vy1 = 1.0f - vy0;

size_t noseEnd = cellX / 2;
size_t bodyEnd = width - cellX / 2;

if (iyp < 0)
{
float * h = histograms + (iyp + 1)*blockStride;
for (size_t col = 1; col < width - 1; ++col)
{
float value = values[col];
int index = indexes[col];

float xp = ((float)col + 0.5f) / (float)cellX - 0.5f;
int ixp = (int)floor(xp);
float vx0 = xp - ixp;
float vx1 = 1.0f - vx0;

if (ixp >= 0)
h[ixp*quantization + index] += vx1 * vy0*value;
if (ixp + 1 < blockX)
h[(ixp + 1)*quantization + index] += vx0 * vy0*value;
}
}
else if (iyp + 1 == blockY)
{
float * h = histograms + iyp * blockStride;
for (size_t col = 1; col < width - 1; ++col)
{
float value = values[col];
int index = indexes[col];

float xp = ((float)col + 0.5f) / (float)cellX - 0.5f;
int ixp = (int)floor(xp);
float vx0 = xp - ixp;
float vx1 = 1.0f - vx0;

if (ixp >= 0)
h[ixp*quantization + index] += vx1 * vy1*value;
if (ixp + 1 < blockX)
h[(ixp + 1)*quantization + index] += vx0 * vy1*value;
}
}
else
{
float * h0 = histograms + iyp * blockStride;
float * h1 = histograms + (iyp + 1)*blockStride;
size_t col = 1;
for (; col < noseEnd; ++col)
{
float value = values[col];
int index = indexes[col];

float xp = ((float)col + 0.5f) / (float)cellX - 0.5f;
int ixp = (int)floor(xp);
float vx0 = xp - ixp;

h0[(ixp + 1)*quantization + index] += vx0 * vy1*value;
h1[(ixp + 1)*quantization + index] += vx0 * vy0*value;
}

for (; col < bodyEnd; ++col)
{
float value = values[col];
int index = indexes[col];

float xp = ((float)col + 0.5f) / (float)cellX - 0.5f;
int ixp = (int)floor(xp);
float vx0 = xp - ixp;
float vx1 = 1.0f - vx0;

h0[ixp*quantization + index] += vx1 * vy1*value;
h1[ixp*quantization + index] += vx1 * vy0*value;
h0[(ixp + 1)*quantization + index] += vx0 * vy1*value;
h1[(ixp + 1)*quantization + index] += vx0 * vy0*value;
}

for (; col < width - 1; ++col)
{
float value = values[col];
int index = indexes[col];

float xp = ((float)col + 0.5f) / (float)cellX - 0.5f;
int ixp = (int)floor(xp);
float vx0 = xp - ixp;
float vx1 = 1.0f - vx0;

h0[ixp*quantization + index] += vx1 * vy1*value;
h1[ixp*quantization + index] += vx1 * vy0*value;
}
}
}

void HogDirectionHistograms(const uint8_t * src, size_t stride, size_t width, size_t height,
size_t cellX, size_t cellY, size_t quantization, float * histograms)
{
assert(width%cellX == 0 && height%cellY == 0 && quantization % 2 == 0);

Buffer buffer(width, quantization);

memset(histograms, 0, quantization*(width / cellX)*(height / cellY) * sizeof(float));

for (size_t row = 1; row < height - 1; ++row)
{
const uint8_t * src1 = src + stride * row;
const uint8_t * src0 = src1 - stride;
const uint8_t * src2 = src1 + stride;

#if 1
for (size_t col = 1; col < width - 1; ++col)
{
float dy = (float)(src2[col] - src0[col]);
float dx = (float)(src1[col + 1] - src1[col - 1]);
float value = (float)::sqrt(dx*dx + dy * dy);

float bestDot = 0;
int index = 0;
for (int direction = 0; direction < buffer.size; direction++)
{
float dot = buffer.cos[direction] * dx + buffer.sin[direction] * dy;
if (dot > bestDot)
{
bestDot = dot;
index = direction;
}
else if (-dot > bestDot)
{
bestDot = -dot;
index = direction + buffer.size;
}
}

buffer.value[col] = value;
buffer.index[col] = index;
}
#else
size_t size = (buffer.size + 1) / 2;
for (size_t col = 1; col < width - 1; ++col)
{
float dy = (float)(src2[col] - src0[col]);
float dx = (float)(src1[col + 1] - src1[col - 1]);
float value = (float)::sqrt(dx*dx + dy * dy);
float ady = Simd::Abs(dy);
float adx = Simd::Abs(dx);

float bestDot = 0;
int index = 0;
for (int direction = 0; direction < size; direction++)
{
float dot = buffer.cos[direction] * adx + buffer.sin[direction] * ady;
if (dot > bestDot)
{
bestDot = dot;
index = direction;
}
}
if (dx < 0)
index = buffer.size - index;
if (dy < 0 && index != 0)
index = buffer.size * 2 - index - (dx == 0);

buffer.value[col] = value;
buffer.index[col] = index;
}
#endif

AddRowToHistograms(buffer.index, buffer.value, row, width, height, cellX, cellY, quantization, histograms);
}
}

class HogFeatureExtractor
{
static const size_t C = 8;
Expand Down
32 changes: 0 additions & 32 deletions src/Simd/SimdLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3218,38 +3218,6 @@ SIMD_API void SimdNormalizeHistogram(const uint8_t * src, size_t srcStride, size
Base::NormalizeHistogram(src, srcStride, width, height, dst, dstStride);
}

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)
{
SIMD_EMPTY();
#ifdef SIMD_AVX512BW_ENABLE
if (Avx512bw::Enable && width >= Avx512bw::HA + 2)
Avx512bw::HogDirectionHistograms(src, stride, width, height, cellX, cellY, quantization, histograms);
else
#endif
#ifdef SIMD_AVX2_ENABLE
if(Avx2::Enable && width >= Avx2::A + 2)
Avx2::HogDirectionHistograms(src, stride, width, height, cellX, cellY, quantization, histograms);
else
#endif
#ifdef SIMD_SSE41_ENABLE
if (Sse41::Enable && width >= Sse41::A + 2)
Sse41::HogDirectionHistograms(src, stride, width, height, cellX, cellY, quantization, histograms);
else
#endif
#ifdef SIMD_SVE2_ENABLE
if (Sve2::Enable && width >= 3)
Sve2::HogDirectionHistograms(src, stride, width, height, cellX, cellY, quantization, histograms);
else
#endif
#ifdef SIMD_NEON_ENABLE
if (Neon::Enable && width >= Neon::A + 2)
Neon::HogDirectionHistograms(src, stride, width, height, cellX, cellY, quantization, histograms);
else
#endif
Base::HogDirectionHistograms(src, stride, width, height, cellX, cellY, quantization, histograms);
}

SIMD_API void SimdHogExtractFeatures(const uint8_t * src, size_t stride, size_t width, size_t height, float * features)
{
SIMD_EMPTY();
Expand Down
34 changes: 0 additions & 34 deletions src/Simd/SimdLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -4410,40 +4410,6 @@ extern "C"
*/
SIMD_API void SimdNormalizeHistogram(const uint8_t * src, size_t srcStride, size_t width, size_t height, uint8_t * dst, size_t dstStride);

/*! @ingroup hog

\fn 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);

\short Calculates HOG direction histograms for an 8-bit gray image.

\deprecated This function will be removed in the nearest future.

The function uses central differences for pixels except the one-pixel image border:
\verbatim
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;
\endverbatim

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).

\param [in] src - a pointer to pixels data of input 8-bit gray image.
\param [in] stride - a row size of the image (in bytes).
\param [in] width - an image width. It must be a multiple of cellX.
\param [in] height - an image height. It must be a multiple of cellY.
\param [in] cellX - a width of cell.
\param [in] cellY - a height of cell.
\param [in] quantization - a direction quantization. Must be even.
\param [out] histograms - a pointer to buffer with histograms. Array must have size greater or equal to (width/cellX)*(height/cellY)*quantization.
*/
SIMD_DEPRECATED 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);

/*! @ingroup hog

\fn void SimdHogExtractFeatures(const uint8_t * src, size_t stride, size_t width, size_t height, float * features);
Expand Down
34 changes: 0 additions & 34 deletions src/Simd/SimdLib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2482,40 +2482,6 @@ namespace Simd
return (uint8_t)bestThreshold;
}

/*! @ingroup hog

\fn void HogDirectionHistograms(const View<A> & src, const Point<ptrdiff_t> & cell, size_t quantization, float * histograms);

\short Calculates HOG direction histograms for an 8-bit gray image.

\deprecated This function will be removed in the nearest future.

The function uses central differences for pixels except the one-pixel image border:
\verbatim
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;
\endverbatim

Pixel magnitudes are bilinearly distributed to neighboring cells. The output buffer is
cleared and then filled in row-major cell order:
histograms[(cellYIndex*(src.width/cell.x) + cellXIndex)*quantization + direction].

\note This function is a C++ wrapper for function ::SimdHogDirectionHistograms.

\param [in] src - an input 8-bit gray image. Its width must be a multiple of cell.x and its height must be a multiple of cell.y.
\param [in] cell - a cell size in pixels.
\param [in] quantization - a direction quantization. Must be even.
\param [out] histograms - a pointer to buffer with histograms. Array must have size greater or equal to (src.width/cell.x)*(src.height/cell.y)*quantization.
*/
template<template<class> class A> SIMD_DEPRECATED SIMD_INLINE void HogDirectionHistograms(const View<A> & src, const Point<ptrdiff_t> & cell, size_t quantization, float * histograms)
{
assert(src.format == View<A>::Gray8 && src.width%cell.x == 0 && src.height%cell.y == 0 && quantization % 2 == 0);

SimdHogDirectionHistograms(src.data, src.stride, src.width, src.height, cell.x, cell.y, quantization, histograms);
}

/*! @ingroup hog

\fn void HogExtractFeatures(const View<A> & src, float * features)
Expand Down
Loading