From 02b9fca342aa95430f63d1552f6c4b488495a82d Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 4 Aug 2026 11:29:38 +0000 Subject: [PATCH] Improve Background function descriptions in SimdLib.hpp Align C++ wrapper Doxygen docs with implementation behavior and the improved C API wording, and record the changes in release 7.2.165 notes. Co-authored-by: Ihar Yermalayeu --- docs/2026.html | 11 ++++++++ src/Simd/SimdLib.hpp | 61 ++++++++++++++++++++++++-------------------- 2 files changed, 44 insertions(+), 28 deletions(-) diff --git a/docs/2026.html b/docs/2026.html index 5491898742..905e852d0e 100644 --- a/docs/2026.html +++ b/docs/2026.html @@ -62,6 +62,17 @@
Removing
  • Separate support of SVE extension (ARM/ARM64 platform).
  • +

    Documentation

    +
    Improving
    + + Home

    August 3, 2026 (version 7.2.164)

    diff --git a/src/Simd/SimdLib.hpp b/src/Simd/SimdLib.hpp index cd0771ced2..9c51b701f8 100644 --- a/src/Simd/SimdLib.hpp +++ b/src/Simd/SimdLib.hpp @@ -479,11 +479,11 @@ namespace Simd \fn void BackgroundGrowRangeSlow(const View& value, View& lo, View& hi) - \short Performs background update (initial grow, slow mode). + \short Performs slow expansion of background range. All images must have the same width, height and format (8-bit gray). - For every point: + For every point, range bounds are moved by one step toward current value: \verbatim lo[i] -= value[i] < lo[i] ? 1 : 0; hi[i] += value[i] > hi[i] ? 1 : 0; @@ -508,11 +508,11 @@ namespace Simd \fn void BackgroundGrowRangeFast(const View& value, View& lo, View& hi) - \short Performs background update (initial grow, fast mode). + \short Performs fast expansion of background range. All images must have the same width, height and format (8-bit gray). - For every point: + For every point, range bounds are expanded to include current value: \verbatim lo[i] = value[i] < lo[i] ? value[i] : lo[i]; hi[i] = value[i] > hi[i] ? value[i] : hi[i]; @@ -537,11 +537,11 @@ namespace Simd \fn void BackgroundIncrementCount(const View& value, const View& loValue, const View& hiValue, View& loCount, View& hiCount) - \short Performs collection of background statistic. + \short Collects background out-of-range statistics. All images must have the same width, height and format (8-bit gray). - Updates background statistic counters for every point: + For every point, counters are incremented with saturation to 255: \verbatim loCount[i] += (value[i] < loValue[i] && loCount[i] < 255) ? 1 : 0; hiCount[i] += (value[i] > hiValue[i] && hiCount[i] < 255) ? 1 : 0; @@ -570,11 +570,11 @@ namespace Simd \fn void BackgroundAdjustRange(View& loCount, View& loValue, View& hiCount, View& hiValue, uint8_t threshold) - \short Performs adjustment of background range. + \short Adjusts background range using collected counters. All images must have the same width, height and format (8-bit gray). - Adjusts background range for every point: + For every point: \verbatim loValue[i] -= (loCount[i] > threshold && loValue[i] > 0) ? 1 : 0; loValue[i] += (loCount[i] < threshold && loValue[i] < 255) ? 1 : 0; @@ -606,21 +606,21 @@ namespace Simd \fn void BackgroundAdjustRange(View& loCount, View& loValue, View& hiCount, View& hiValue, uint8_t threshold, const View& mask) - \short Performs adjustment of background range with using adjust range mask. + \short Adjusts background range using collected counters and a mask. All images must have the same width, height and format (8-bit gray). - Adjusts background range for every point: + For every point: \verbatim if(mask[i]) { loValue[i] -= (loCount[i] > threshold && loValue[i] > 0) ? 1 : 0; loValue[i] += (loCount[i] < threshold && loValue[i] < 255) ? 1 : 0; - loCount[i] = 0; hiValue[i] += (hiCount[i] > threshold && hiValue[i] < 255) ? 1 : 0; hiValue[i] -= (hiCount[i] < threshold && hiValue[i] > 0) ? 1 : 0; - hiCount[i] = 0; } + loCount[i] = 0; + hiCount[i] = 0; \endverbatim This function is used for background updating in motion detection algorithm. @@ -647,21 +647,23 @@ namespace Simd \fn void BackgroundShiftRange(const View& value, View& lo, View& hi) - \short Shifts background range. + \short Shifts background range to include current value. All images must have the same width, height and format (8-bit gray). For every point: \verbatim - if (value[i] > hi[i]) + add = value[i] - hi[i]; + sub = lo[i] - value[i]; + if(add > 0) { - lo[i] = min(lo[i] + value[i] - hi[i], 255); - hi[i] = value[i]; + lo[i] = min(lo[i] + add, 255); + hi[i] = min(hi[i] + add, 255); } - if (lo[i] > value[i]) + if(sub > 0) { - lo[i] = value[i]; - hi[i] = max(hi[i] - lo[i] + value[i], 0); + lo[i] = max(lo[i] - sub, 0); + hi[i] = max(hi[i] - sub, 0); } \endverbatim @@ -684,7 +686,7 @@ namespace Simd \fn void BackgroundShiftRange(const View& value, View& lo, View& hi, const View& mask); - \short Shifts background range with using shift range mask. + \short Shifts background range to include current value using a mask. All images must have the same width, height and format (8-bit gray). @@ -692,15 +694,17 @@ namespace Simd \verbatim if(mask[i]) { - if (value[i] > hi[i]) + add = value[i] - hi[i]; + sub = lo[i] - value[i]; + if(add > 0) { - lo[i] = min(lo[i] + value[i] - hi[i], 255); - hi[i] = value[i]; + lo[i] = min(lo[i] + add, 255); + hi[i] = min(hi[i] + add, 255); } - if (lo[i] > value[i]) + if(sub > 0) { - lo[i] = value[i]; - hi[i] = max(hi[i] - lo[i] + value[i], 0); + lo[i] = max(lo[i] - sub, 0); + hi[i] = max(hi[i] - sub, 0); } } \endverbatim @@ -726,15 +730,16 @@ namespace Simd \fn void BackgroundInitMask(const View& src, uint8_t index, uint8_t value, View& dst); - \short Creates background update mask. + \short Initializes background update mask by selected source index. All images must have the same width, height and format (8-bit gray). For every point: \verbatim - if(mask[i] == index) + if(src[i] == index) dst[i] = value; \endverbatim + Otherwise dst[i] is left unchanged. This function is used for background updating in motion detection algorithm.