8 #ifndef META_OCEAN_CV_FRAME_FILTER_GRADIENT_H
9 #define META_OCEAN_CV_FRAME_FILTER_GRADIENT_H
48 template <
typename TSource,
typename TTarget,
unsigned int tChannels,
bool tNormalizeByTwo>
49 static inline void filterHorizontalVertical(
const TSource* source, TTarget* target,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const TTarget multiplicationFactor = TTarget(1),
Worker* worker =
nullptr);
68 template <
typename TSource,
typename TTarget,
unsigned int tChannels,
bool tNormalizeByTwo>
69 static inline void filterHorizontalVerticalMagnitudeSquared(
const TSource* source, TTarget* target,
const unsigned int width,
const unsigned int height,
const TTarget multiplicationFactor = TTarget(1),
Worker* worker =
nullptr);
92 template <
typename TSource,
typename TTarget,
unsigned int tChannels,
bool tNormalizeByTwo>
93 static inline void filterHorizontalVerticalSubFrame(
const TSource* source,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int sourcePaddingElements,
const unsigned int sourceLeft,
const unsigned int sourceTop, TTarget* target,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetPaddingElements,
const TTarget multiplicationFactor = TTarget(1),
Worker* worker =
nullptr);
124 template <
typename T,
typename TIntegral,
bool tAbsoluteGradient = false>
125 static void filterHorizontal1x2LinedIntegralImage(
const T* source,
const unsigned int width,
const unsigned int height, TIntegral* integral,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements);
157 template <
typename T,
typename TIntegral,
bool tAbsoluteGradient = false>
158 static void filterVertical2x1LinedIntegralImage(
const T* source,
const unsigned int width,
const unsigned int height, TIntegral* integral,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements);
161 template <
typename TSource,
typename TTarget,
unsigned int tChannels,
bool tNormalizeByTwo>
162 inline void FrameFilterGradient::filterHorizontalVertical(
const TSource* source, TTarget* target,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const TTarget multiplicationFactor,
Worker* worker)
164 FrameFilterGradientBase::filterHorizontalVertical<TSource, TTarget, tChannels, tNormalizeByTwo>(source, target, width, height, sourcePaddingElements, targetPaddingElements, multiplicationFactor, worker);
167 template <
typename TSource,
typename TTarget,
unsigned int tChannels,
bool tNormalizeByTwo>
170 FrameFilterGradientBase::filterHorizontalVerticalMagnitudeSquared<TSource, TTarget, tChannels, tNormalizeByTwo>(source, target, width, height, multiplicationFactor, worker);
173 template <
typename TSource,
typename TTarget,
unsigned int tChannels,
bool tNormalizeByTwo>
174 inline void FrameFilterGradient::filterHorizontalVerticalSubFrame(
const TSource* source,
const unsigned int sourceWidth,
const unsigned int sourceHeight,
const unsigned int sourcePaddingElements,
const unsigned int sourceLeft,
const unsigned int sourceTop, TTarget* target,
const unsigned int targetWidth,
const unsigned int targetHeight,
const unsigned int targetPaddingElements,
const TTarget multiplicationFactor,
Worker* worker)
176 FrameFilterGradientBase::filterHorizontalVerticalSubFrame<TSource, TTarget, tChannels, tNormalizeByTwo>(source, sourceWidth, sourceHeight, sourcePaddingElements, sourceLeft, sourceTop, target, targetWidth, targetHeight, targetPaddingElements, multiplicationFactor, worker);
179 template <
typename T,
typename TIntegral,
bool tAbsoluteGradient>
182 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
184 ocean_assert(source !=
nullptr);
185 ocean_assert(width >= 2u);
186 ocean_assert(height >= 1u);
187 ocean_assert(integral !=
nullptr);
203 memset(integral, 0x00, width *
sizeof(TIntegral));
206 for (
unsigned int n = 0u; n < width; ++n)
208 ocean_assert(integral[n] == TIntegral(0));
212 integral += width + integralPaddingElements;
216 const T*
const sourceFirstRowEnd = source + width - 1u;
217 const T*
const sourceEnd = source + (width + sourcePaddingElements) * height;
219 const TIntegral* integralPreviousRow = integral;
221 TIntegral previousIntegral = TIntegral(0);
223 *integral++ = TIntegral(0);
227 while (source != sourceFirstRowEnd)
229 previousIntegral += tAbsoluteGradient ? TIntegral(
NumericT<TSignedIntegral>::abs(TSignedIntegral(source[1] - source[0]))) : TIntegral(source[1] - source[0]);
232 *integral++ = previousIntegral;
235 source += sourcePaddingElements + 1u;
236 integral += integralPaddingElements;
240 while (source != sourceEnd)
242 const T*
const sourceRowEnd = source + width - 1u;
244 previousIntegral = TIntegral(0);
247 *integral++ = TIntegral(0);
249 ++integralPreviousRow;
251 while (source != sourceRowEnd)
253 previousIntegral += tAbsoluteGradient ? TIntegral(
NumericT<TSignedIntegral>::abs(TSignedIntegral(source[1] - source[0]))) : TIntegral(source[1] - source[0]);
256 *integral++ = previousIntegral + *integralPreviousRow++;
259 source += sourcePaddingElements + 1u;
260 integral += integralPaddingElements;
261 integralPreviousRow += integralPaddingElements;
265 template <
typename T,
typename TIntegral,
bool tAbsoluteGradient>
268 ocean_assert(source !=
nullptr);
269 ocean_assert(width >= 1u);
270 ocean_assert(height >= 2u);
271 ocean_assert(integral !=
nullptr);
273 const unsigned int sourceStrideElements = width + sourcePaddingElements;
289 memset(integral, 0x00, (width + 1u) *
sizeof(TIntegral));
292 for (
unsigned int n = 0u; n < width + 1u; ++n)
294 ocean_assert(integral[n] == TIntegral(0));
298 integral += width + 1u + integralPaddingElements;
302 const T*
const sourceFirstRowEnd = source + width;
303 const T*
const sourceEnd = source + sourceStrideElements * (height - 1u);
305 const TIntegral* integralPreviousRow = integral;
307 TIntegral previousIntegral = TIntegral(0);
309 *integral++ = TIntegral(0);
313 const T* sourceNextRow = source + sourceStrideElements;
315 while (source != sourceFirstRowEnd)
317 previousIntegral += tAbsoluteGradient ? TIntegral(
NumericT<TSignedIntegral>::abs(TSignedIntegral(*sourceNextRow++ - *source++))) : TIntegral(*sourceNextRow++ - *source++);
319 *integral++ = previousIntegral;
322 source += sourcePaddingElements;
323 sourceNextRow += sourcePaddingElements;
324 integral += integralPaddingElements;
328 while (source != sourceEnd)
330 const T*
const sourceRowEnd = source + width;
332 previousIntegral = TIntegral(0);
335 *integral++ = TIntegral(0);
337 ++integralPreviousRow;
339 while (source != sourceRowEnd)
341 previousIntegral += tAbsoluteGradient ? TIntegral(
NumericT<TSignedIntegral>::abs(TSignedIntegral(*sourceNextRow++ - *source++))) : TIntegral(*sourceNextRow++ - *source++);
343 *integral++ = previousIntegral + *integralPreviousRow++;
346 source += sourcePaddingElements;
347 sourceNextRow += sourcePaddingElements;
349 integral += integralPaddingElements;
350 integralPreviousRow += integralPaddingElements;
This class implements a gradient frame filter.
Definition: FrameFilterGradient.h:27
static void filterHorizontal1x2LinedIntegralImage(const T *source, const unsigned int width, const unsigned int height, TIntegral *integral, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
Determines the lined integral image of the horizontal 1x2 gradient filter when applied to a source im...
Definition: FrameFilterGradient.h:180
static void filterHorizontalVertical(const TSource *source, TTarget *target, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const TTarget multiplicationFactor=TTarget(1), Worker *worker=nullptr)
Horizontal and vertical gradient filter for a 1-plane frame with arbitrary data type and arbitrary nu...
Definition: FrameFilterGradient.h:162
static void filterHorizontalVerticalSubFrame(const TSource *source, const unsigned int sourceWidth, const unsigned int sourceHeight, const unsigned int sourcePaddingElements, const unsigned int sourceLeft, const unsigned int sourceTop, TTarget *target, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int targetPaddingElements, const TTarget multiplicationFactor=TTarget(1), Worker *worker=nullptr)
Horizontal and vertical gradient filter for sub-frame of a 1-plane frame with arbitrary data type and...
Definition: FrameFilterGradient.h:174
static void filterVertical2x1LinedIntegralImage(const T *source, const unsigned int width, const unsigned int height, TIntegral *integral, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
Determines the lined integral image of the vertical 2x1 gradient filter when applied to a source imag...
Definition: FrameFilterGradient.h:266
static void filterHorizontalVerticalMagnitudeSquared(const TSource *source, TTarget *target, const unsigned int width, const unsigned int height, const TTarget multiplicationFactor=TTarget(1), Worker *worker=nullptr)
Squared magnitude gradient filter using the horizontal and vertical gradients that can be applied to ...
Definition: FrameFilterGradient.h:168
T Type
Definition of the data type for the signed difference value.
Definition: DataType.h:176
This class provides basic numeric functionalities.
Definition: Numeric.h:57
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15