Ocean
Loading...
Searching...
No Matches
AdvancedSumSquareDifferences.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_CV_ADVANCED_ADVANCED_SUM_SQUARE_DIFFERENCES_H
9#define META_OCEAN_CV_ADVANCED_ADVANCED_SUM_SQUARE_DIFFERENCES_H
10
14
16
17#include "ocean/math/Math.h"
18
19namespace Ocean
20{
21
22namespace CV
23{
24
25namespace Advanced
26{
27
28/**
29 * This class implements sum of square difference calculation functions allowing to determine the ssd with sub-pixel accuracy.
30 * @ingroup cvadvanced
31 */
33{
34 public:
35
36 /**
37 * Returns the sum of square differences for an image patch block determined for two sub-pixel positions between two individual images.
38 * @param image0 The image in which the first patch is located, must be valid
39 * @param image1 The image in which the second patch is located, must be valid
40 * @param width0 The width of the first image, in pixels, with range [tPatchSize + 1, infinity)
41 * @param width1 The width of the second image, in pixels, with range [tPatchSize + 1, infinity)
42 * @param centerX0 Horizontal sub-pixel center position of the (tSize x tSize) block in the first frame, with range [tSize/2, width0 - tSize/2 - 1)
43 * @param centerY0 Vertical sub-pixel center position of the (tSize x tSize) block in the first frame, with range [tSize/2, height0 - tSize/2 - 1)
44 * @param centerX1 Horizontal sub-pixel center position of the (tSize x tSize) block in the second frame, with range [tSize/2, width1 - tSize/2 - 1)
45 * @param centerY1 Vertical sub-pixel center position of the (tSize x tSize) block in the second frame, with range [tSize/2, height1 - tSize/2 - 1)
46 * @param image0PaddingElements The number of padding elements at the end of each row of the first image, in elements, with range [0, infinity)
47 * @param image1PaddingElements The number of padding elements at the end of each row of the second image, in elements, with range [0, infinity)
48 * @return The resulting sum of square differences, with range [0, infinity)
49 * @tparam tChannels The number of frame channels, with range [1, infinity)
50 * @tparam tPatchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
51 */
52 template <unsigned int tChannels, unsigned int tPatchSize>
53 static inline uint32_t patch8BitPerChannel(const uint8_t* image0, const uint8_t* image1, const unsigned int width0, const unsigned int width1, const Scalar centerX0, const Scalar centerY0, const Scalar centerX1, const Scalar centerY1, const unsigned int image0PaddingElements, const unsigned int image1PaddingElements);
54
55 /**
56 * Returns the sum of square differences for an image patch block determined for one pixel and one sub-pixel position between two individual images.
57 * @param image0 The image in which the first patch is located, must be valid
58 * @param image1 The image in which the second patch is located, must be valid
59 * @param width0 The width of the first image, in pixels, with range [tPatchSize + 1, infinity)
60 * @param width1 The width of the second image, in pixels, with range [tPatchSize + 1, infinity)
61 * @param centerX0 Horizontal pixel center position of the (tSize x tSize) block in the first frame, with range [tSize/2, width0 - tSize/2)
62 * @param centerY0 Vertical pixel center position of the (tSize x tSize) block in the first frame, with range [tSize/2, height0 - tSize/2)
63 * @param centerX1 Horizontal sub-pixel center position of the (tSize x tSize) block in the second frame, with range [tSize/2, width1 - tSize/2 - 1)
64 * @param centerY1 Vertical sub-pixel center position of the (tSize x tSize) block in the second frame, with range [tSize/2, height1 - tSize/2 - 1)
65 * @param image0PaddingElements The number of padding elements at the end of each row of the first image, in elements, with range [0, infinity)
66 * @param image1PaddingElements The number of padding elements at the end of each row of the second image, in elements, with range [0, infinity)
67 * @return The resulting sum of square differences, with range [0, infinity)
68 * @tparam tChannels The number of frame channels, with range [1, infinity)
69 * @tparam tPatchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
70 */
71 template <unsigned int tChannels, unsigned int tPatchSize>
72 static inline uint32_t patch8BitPerChannel(const uint8_t* image0, const uint8_t* image1, const unsigned int width0, const unsigned int width1, const unsigned int centerX0, const unsigned int centerY0, const Scalar centerX1, const Scalar centerY1, const unsigned int image0PaddingElements, const unsigned int image1PaddingElements);
73
74 /**
75 * Determines the sum of square differences between an image patch with sub-pixel accuracy and a memory buffer.
76 * @param image0 The image in which the patch is located with sub-pixel accuracy, must be valid
77 * @param width0 The width of the image in pixel, with range [tPatchSize + 1, infinity)
78 * @param centerX0 The horizontal center position of the image patch with sub-pixel accuracy, with range [tPatchSize / 2, width0 - tPatchSize / 2 - 1]
79 * @param centerY0 The vertical center position of the image patch with sub-pixel accuracy, with range [tPatchSize / 2, height0 - tPatchSize / 2 - 1]
80 * @param image0PaddingElements The number of padding elements at the end of each image row, in elements, with range [0, infinity)
81 * @param buffer1 The memory buffer with `tChannels * tPatchSize * tPatchSize` elements, must be valid
82 * @return The resulting ssd value
83 * @tparam tChannels The number of channels for the given frames, with range [1, infinity)
84 * @tparam tPatchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
85 */
86 template <unsigned int tChannels, unsigned int tPatchSize>
87 static inline uint32_t patchBuffer8BitPerChannel(const uint8_t* image0, const unsigned int width0, const Scalar centerX0, const Scalar centerY0, const unsigned int image0PaddingElements, const uint8_t* buffer1);
88
89 /**
90 * Determines the sum of square differences between an image patch with sub-pixel accuracy and a memory buffer.
91 * Pixels in the square region pointing outside the frame are mirrored back into the frame.
92 * @param image0 The image in which the patch is located with sub-pixel accuracy, must be valid
93 * @param width0 The width of the image in pixel, with range [tPatchSize/2 + 1, infinity)
94 * @param height0 The height of the image in pixel, with range [tPatchSize/2 + 1, infinity)
95 * @param centerX0 The horizontal center position of the image patch with sub-pixel accuracy, with range [0, width0)
96 * @param centerY0 The vertical center position of the image patch with sub-pixel accuracy, with range [0, height0)
97 * @param image0PaddingElements The number of padding elements at the end of each image row, in elements, with range [0, infinity)
98 * @param buffer1 The memory buffer with `tChannels * tPatchSize * tPatchSize` elements, must be valid
99 * @return The resulting ssd value
100 * @tparam tChannels The number of channels for the given frames, with range [1, infinity)
101 * @tparam tPatchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
102 */
103 template <unsigned int tChannels, unsigned int tPatchSize>
104 static inline uint32_t patchMirroredBorderBuffer8BitPerChannel(const uint8_t* image0, const unsigned int width0, const unsigned int height0, const Scalar centerX0, const Scalar centerY0, const unsigned int image0PaddingElements, const uint8_t* buffer1);
105
106 /**
107 * Returns the sum of square differences for an image patch determined for two pixel accurate positions between two individual images .
108 * Further, each image is associated with a binary mask, only valid non-mask pixels are used during SSD calculation.
109 * @param image0 The image in which the first patch is located, must be valid
110 * @param image1 The image in which the second patch is located, must be valid
111 * @param mask0 The mask associated with the first image, must be valid
112 * @param mask1 The mask associated with the second image, must be valid
113 * @param width0 The width of the first image, in pixels, with range [patchSize / 2 + 1, infinity)
114 * @param height0 The height of the first image, in pixels, with range [patchSize / 2 + 1, infinity)
115 * @param width1 The width of the second image, in pixels, with range [patchSize / 2 + 1, infinity)
116 * @param height1 The height of the second image, in pixels, with range [patchSize / 2 + 1, infinity)
117 * @param centerX0 Horizontal sub-pixel center position of the (tSize x tSize) block in the first frame, with range [0, width0 - 1]
118 * @param centerY0 Vertical sub-pixel center position of the (tSize x tSize) block in the first frame, with range [0, height0 - 1]
119 * @param centerX1 Horizontal sub-pixel center position of the (tSize x tSize) block in the second frame, with range [0, width1 - 1]
120 * @param centerY1 Vertical sub-pixel center position of the (tSize x tSize) block in the second frame, with range [0, height1 - 1]
121 * @param image0PaddingElements The number of padding elements at the end of each row of the first image, in elements, with range [0, infinity)
122 * @param image1PaddingElements The number of padding elements at the end of each row of the second image, in elements, with range [0, infinity)
123 * @param mask0PaddingElements The number of padding elements at the end of each row of the first mask, in elements, with range [0, infinity)
124 * @param mask1PaddingElements The number of padding elements at the end of each row of the second mask, in elements, with range [0, infinity)
125 * @param maskValue The pixel value of a mask pixel which will be excluded when calculating the SSD, with range [0, 255]
126 * @return The resulting pair holding first: sum of square differences, second: number of pixels contributed to the result
127 * @tparam tChannels The number of frame channels, with range [1, infinity)
128 * @tparam tPatchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
129 */
130 template <unsigned int tChannels, unsigned int tPatchSize>
131 static inline IndexPair32 patchWithMask8BitPerChannel(const uint8_t* image0, const uint8_t* image1, const uint8_t* mask0, const uint8_t* mask1, const unsigned int width0, const unsigned int height0, const unsigned int width1, const unsigned int height1, const unsigned int centerX0, const unsigned int centerY0, const unsigned int centerX1, const unsigned int centerY1, const unsigned int image0PaddingElements, const unsigned int image1PaddingElements, const unsigned int mask0PaddingElements, const unsigned int mask1PaddingElements, const uint8_t maskValue);
132
133 /**
134 * Returns the sum of square differences for an image patch determined for two pixel accurate positions between two individual images .
135 * Further, each image is associated with a binary mask, only valid non-mask pixels in the first image are used during SSD calculation.
136 * If a valid (mask) pixel in the first image does not have a valid (mask) pixel in the second frame, -1 is returned as SSD value.
137 * @param image0 The image in which the first patch is located, must be valid
138 * @param image1 The image in which the second patch is located, must be valid
139 * @param mask0 The mask associated with the first image, must be valid
140 * @param mask1 The mask associated with the second image, must be valid
141 * @param patchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
142 * @param width0 The width of the first image, in pixels, with range [patchSize / 2 + 1, infinity)
143 * @param height0 The height of the first image, in pixels, with range [patchSize / 2 + 1, infinity)
144 * @param width1 The width of the second image, in pixels, with range [patchSize / 2 + 1, infinity)
145 * @param height1 The height of the second image, in pixels, with range [patchSize / 2 + 1, infinity)
146 * @param centerX0 Horizontal sub-pixel center position of the (tSize x tSize) block in the first frame, with range [0, width0 - 1]
147 * @param centerY0 Vertical sub-pixel center position of the (tSize x tSize) block in the first frame, with range [0, height0 - 1]
148 * @param centerX1 Horizontal sub-pixel center position of the (tSize x tSize) block in the second frame, with range [0, width1 - 1]
149 * @param centerY1 Vertical sub-pixel center position of the (tSize x tSize) block in the second frame, with range [0, height1 - 1]
150 * @param image0PaddingElements The number of padding elements at the end of each row of the first image, in elements, with range [0, infinity)
151 * @param image1PaddingElements The number of padding elements at the end of each row of the second image, in elements, with range [0, infinity)
152 * @param mask0PaddingElements The number of padding elements at the end of each row of the first mask, in elements, with range [0, infinity)
153 * @param mask1PaddingElements The number of padding elements at the end of each row of the second mask, in elements, with range [0, infinity)
154 * @param maskValue The pixel value of a mask pixel which will be excluded when calculating the SSD, with range [0, 255]
155 * @return The resulting pair holding first: sum of square differences, second: number of pixels contributed to the result
156 * @tparam tChannels The number of frame channels, with range [1, infinity)
157 */
158 template <unsigned int tChannels>
159 static inline IndexPair32 patchWithRejectingMask8BitPerChannel(const uint8_t* image0, const uint8_t* image1, const uint8_t* mask0, const uint8_t* mask1, const unsigned int patchSize, const unsigned int width0, const unsigned int height0, const unsigned int width1, const unsigned int height1, const unsigned int centerX0, const unsigned int centerY0, const unsigned int centerX1, const unsigned int centerY1, const unsigned int image0PaddingElements, const unsigned int image1PaddingElements, const unsigned int mask0PaddingElements, const unsigned int mask1PaddingElements, const uint8_t maskValue);
160};
161
162template <unsigned int tChannels, unsigned int tPatchSize>
163inline unsigned int AdvancedSumSquareDifferences::patch8BitPerChannel(const uint8_t* image0, const uint8_t* image1, const unsigned int width0, const unsigned int width1, const Scalar centerX0, const Scalar centerY0, const Scalar centerX1, const Scalar centerY1, const unsigned int image0PaddingElements, const unsigned int image1PaddingElements)
164{
165 static_assert(tChannels >= 1u, "Invalid channel number!");
166 static_assert(tPatchSize >= 1u && tPatchSize % 2u == 1u, "Invalid patch size!");
167
168 ocean_assert(image0 != nullptr && image1 != nullptr);
169
170 ocean_assert(width0 >= tPatchSize + 1u);
171 ocean_assert(width1 >= tPatchSize + 1u);
172
173 constexpr unsigned int tPatchSize_2 = tPatchSize / 2u;
174
175 ocean_assert(centerX0 >= Scalar(tPatchSize_2) && centerX0 < Scalar(width0 - tPatchSize_2 - 1u));
176 ocean_assert(centerX1 >= Scalar(tPatchSize_2) && centerX1 < Scalar(width1 - tPatchSize_2 - 1u));
177
178 ocean_assert_and_suppress_unused(centerY0 >= Scalar(tPatchSize_2) && centerY1 >= Scalar(tPatchSize_2), tPatchSize_2);
179
180#if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
181
182 if constexpr (tChannels >= 1u && tChannels <= 4u && tPatchSize == 5u)
183 {
184 return AdvancedSumSquareDifferencesSSE::patch8BitPerChannel<tChannels, tPatchSize>(image0, image1, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
185 }
186
187#elif defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
188
189 if constexpr (tPatchSize >= 5u)
190 {
191 // return AdvancedSumSquareDifferencesNEON::patch8BitPerChannel<tChannels, tPatchSize>(image0, image1, width0, width1, centeRX0, centerY0, centeRX1, centerY1, image0PaddingElements, image1PaddingElements); // **TODO**
192 }
193
194#endif // OCEAN_HARDWARE_SSE_VERSION, OCEAN_HARDWARE_NEON_VERSION
195
196 return AdvancedSumSquareDifferencesBase::patch8BitPerChannelTemplate<tChannels, tPatchSize>(image0, image1, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
197}
198
199template <unsigned int tChannels, unsigned int tPatchSize>
200inline uint32_t AdvancedSumSquareDifferences::patch8BitPerChannel(const uint8_t* image0, const uint8_t* image1, const unsigned int width0, const unsigned int width1, const unsigned int centerX0, const unsigned int centerY0, const Scalar centerX1, const Scalar centerY1, const unsigned int image0PaddingElements, const unsigned int image1PaddingElements)
201{
202 static_assert(tChannels >= 1u, "Invalid channel number!");
203 static_assert(tPatchSize >= 1u && tPatchSize % 2u == 1u, "Invalid patch size!");
204
205 ocean_assert(image0 != nullptr && image1 != nullptr);
206
207 ocean_assert(width0 >= tPatchSize + 1u);
208 ocean_assert(width1 >= tPatchSize + 1u);
209
210 constexpr unsigned int tPatchSize_2 = tPatchSize / 2u;
211
212 ocean_assert(centerX0 >= tPatchSize_2 && centerX0 < width0 - tPatchSize_2);
213 ocean_assert(centerX1 >= Scalar(tPatchSize_2) && centerX1 < Scalar(width1 - tPatchSize_2 - 1u));
214
215 ocean_assert_and_suppress_unused(centerY0 >= tPatchSize_2 && centerY1 >= Scalar(tPatchSize_2), tPatchSize_2);
216
217#if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
218
219 if constexpr (tChannels >= 1u && tChannels <= 4u && tPatchSize == 5u)
220 {
221 return AdvancedSumSquareDifferencesSSE::patch8BitPerChannel<tChannels, tPatchSize>(image0, image1, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
222 }
223
224#elif defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
225
226 /*if constexpr (tPatchSize >= 5u) // not yet implemented
227 {
228 return AdvancedSumSquareDifferencesNEON::patch8BitPerChannel<tChannels, tPatchSize>(image0, image1, width0, width1, centeRX0, centerY0, centeRX1, centerY1, image0PaddingElements, image1PaddingElements);
229 }*/
230
231#endif // OCEAN_HARDWARE_SSE_VERSION, OCEAN_HARDWARE_NEON_VERSION
232
233 return AdvancedSumSquareDifferencesBase::patch8BitPerChannelTemplate<tChannels, tPatchSize>(image0, image1, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
234}
235
236template <unsigned int tChannels, unsigned int tPatchSize>
237inline uint32_t AdvancedSumSquareDifferences::patchBuffer8BitPerChannel(const uint8_t* image0, const unsigned int width0, const Scalar centerX0, const Scalar centerY0, const unsigned int image0PaddingElements, const uint8_t* buffer1)
238{
239 static_assert(tChannels != 0u, "Invalid number of image channels!");
240 static_assert(tPatchSize >= 1u && tPatchSize % 2u == 1u, "Invalid patch size!");
241
242 ocean_assert(image0 != nullptr && buffer1 != nullptr);
243
244 ocean_assert(width0 >= tPatchSize + 1u);
245
246 constexpr unsigned int tPatchSize_2 = tPatchSize / 2u;
247
248 ocean_assert_and_suppress_unused(centerX0 >= Scalar(tPatchSize_2) && centerX0 < Scalar(width0 - tPatchSize_2 - 1u), tPatchSize_2);
249
250#if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
251
252 /*if constexpr (tChannels >= 1u && tChannels <= 4u && tPatchSize == 5u) // not yet implemented
253 {
254 return AdvancedSumSquareDifferencesSSE::patchBuffer8BitPerChannel<tChannels, tPatchSize>(image0, image1, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
255 }*/
256
257#elif defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
258
259 /*if constexpr (tPatchSize >= 5u) // not yet implemented
260 {
261 return AdvancedSumSquareDifferencesNEON::patchBuffer8BitPerChannel<tChannels, tPatchSize>(image0, image1, width0, width1, centeRX0, centerY0, centeRX1, centerY1, image0PaddingElements, image1PaddingElements);
262 }*/
263
264#endif // OCEAN_HARDWARE_SSE_VERSION, OCEAN_HARDWARE_NEON_VERSION
265
266 return AdvancedSumSquareDifferencesBase::patchBuffer8BitPerChannelTemplate<tChannels, tPatchSize>(image0, width0, centerX0, centerY0, image0PaddingElements, buffer1);
267}
268
269template <unsigned int tChannels, unsigned int tPatchSize>
270inline uint32_t AdvancedSumSquareDifferences::patchMirroredBorderBuffer8BitPerChannel(const uint8_t* image0, const unsigned int width0, const unsigned int height0, const Scalar centerX0, const Scalar centerY0, const unsigned int image0PaddingElements, const uint8_t* buffer1)
271{
272 static_assert(tChannels != 0u, "Invalid number of image channels!");
273 static_assert(tPatchSize >= 1u && tPatchSize % 2u == 1u, "Invalid patch size!");
274
275 ocean_assert(image0 != nullptr && buffer1 != nullptr);
276
277 constexpr unsigned int tPatchSize_2 = tPatchSize / 2u;
278
279 ocean_assert(width0 >= tPatchSize_2 + 1u);
280 ocean_assert_and_suppress_unused(height0 >= tPatchSize_2 + 1u, tPatchSize_2);
281
282 ocean_assert(centerX0 >= Scalar(0) && centerX0 < Scalar(width0));
283 ocean_assert(centerY0 >= Scalar(0) && centerY0 < Scalar(height0));
284
285 constexpr unsigned int tPatchPixels = tPatchSize * tPatchSize;
286
287 uint8_t target[tPatchPixels * tChannels];
288 AdvancedFrameInterpolatorBilinear::interpolateSquareMirroredBorder8BitPerChannel<tChannels, tPatchSize>(image0, width0, height0, image0PaddingElements, target, Vector2(centerX0, centerY0));
289 return SumSquareDifferences::buffer8BitPerChannel<tChannels, tPatchPixels>(target, buffer1);
290}
291
292template <unsigned int tChannels, unsigned int tPatchSize>
293inline IndexPair32 AdvancedSumSquareDifferences::patchWithMask8BitPerChannel(const uint8_t* image0, const uint8_t* image1, const uint8_t* mask0, const uint8_t* mask1, const unsigned int width0, const unsigned int height0, const unsigned int width1, const unsigned int height1, const unsigned int centerX0, const unsigned int centerY0, const unsigned int centerX1, const unsigned int centerY1, const unsigned int image0PaddingElements, const unsigned int image1PaddingElements, const unsigned int mask0PaddingElements, const unsigned int mask1PaddingElements, const uint8_t maskValue)
294{
295 static_assert(tChannels >= 1u, "Invalid channel number!");
296 static_assert(tPatchSize >= 1u && tPatchSize % 2u == 1u, "Invalid patch size!");
297
298 ocean_assert(image0 != nullptr && image1 != nullptr);
299 ocean_assert(mask0 != nullptr && mask1 != nullptr);
300
301 const unsigned int patchSize_2 = tPatchSize / 2u;
302
303 ocean_assert(width0 >= patchSize_2 + 1u && height0 >= patchSize_2 + 1u);
304 ocean_assert_and_suppress_unused(width1 >= patchSize_2 + 1u && height1 >= patchSize_2 + 1u, patchSize_2);
305
306 ocean_assert(centerX0 < width0 && centerY0 < height0);
307 ocean_assert(centerX1 < width1 && centerY1 < height1);
308
309 return AdvancedSumSquareDifferencesBase::patchWithMask8BitPerChannelTemplate<tChannels, tPatchSize>(image0, image1, mask0, mask1, width0, height0, width1, height1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements, mask0PaddingElements, mask1PaddingElements, maskValue);
310}
311
312template <unsigned int tChannels>
313inline IndexPair32 AdvancedSumSquareDifferences::patchWithRejectingMask8BitPerChannel(const uint8_t* image0, const uint8_t* image1, const uint8_t* mask0, const uint8_t* mask1, const unsigned int patchSize, const unsigned int width0, const unsigned int height0, const unsigned int width1, const unsigned int height1, const unsigned int centerX0, const unsigned int centerY0, const unsigned int centerX1, const unsigned int centerY1, const unsigned int image0PaddingElements, const unsigned int image1PaddingElements, const unsigned int mask0PaddingElements, const unsigned int mask1PaddingElements, const uint8_t maskValue)
314{
315 static_assert(tChannels >= 1u, "Invalid channel number!");
316
317 ocean_assert(image0 != nullptr && image1 != nullptr);
318 ocean_assert(mask0 != nullptr && mask1 != nullptr);
319
320 ocean_assert(patchSize >= 1u && patchSize % 2u == 1u);
321
322 const unsigned int patchSize_2 = patchSize / 2u;
323
324 ocean_assert(width0 >= patchSize_2 + 1u && height0 >= patchSize_2 + 1u);
325 ocean_assert_and_suppress_unused(width1 >= patchSize_2 + 1u && height1 >= patchSize_2 + 1u, patchSize_2);
326
327 ocean_assert(centerX0 < width0 && centerY0 < height0);
328 ocean_assert(centerX1 < width1 && centerY1 < height1);
329
330 return AdvancedSumSquareDifferencesBase::patchWithRejectingMask8BitPerChannel(image0, image1, mask0, mask1, tChannels, patchSize, width0, height0, width1, height1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements, mask0PaddingElements, mask1PaddingElements, maskValue);
331}
332
333}
334
335}
336
337}
338
339#endif // META_OCEAN_CV_ADVANCED_ADVANCED_SUM_SQUARE_DIFFERENCES_H
This class implements functions calculating the sum of square differences and omit center pixel.
Definition AdvancedSumSquareDifferencesBase.h:32
static IndexPair32 patchWithRejectingMask8BitPerChannel(const uint8_t *image0, const uint8_t *image1, const uint8_t *mask0, const uint8_t *mask1, const unsigned int channels, const unsigned int patchSize, const unsigned int width0, const unsigned int height0, const unsigned int width1, const unsigned int height1, const unsigned int centerX0, const unsigned int centerY0, const unsigned int centerX1, const unsigned int centerY1, const unsigned int image0PaddingElements, const unsigned int image1PaddingElements, const unsigned int mask0PaddingElements, const unsigned int mask1PaddingElements, const uint8_t maskValue)
Returns the sum of square differences for an image patch determined for two pixel accurate positions ...
This class implements sum of square difference calculation functions allowing to determine the ssd wi...
Definition AdvancedSumSquareDifferences.h:33
static uint32_t patch8BitPerChannel(const uint8_t *image0, const uint8_t *image1, const unsigned int width0, const unsigned int width1, const Scalar centerX0, const Scalar centerY0, const Scalar centerX1, const Scalar centerY1, const unsigned int image0PaddingElements, const unsigned int image1PaddingElements)
Returns the sum of square differences for an image patch block determined for two sub-pixel positions...
static uint32_t patchBuffer8BitPerChannel(const uint8_t *image0, const unsigned int width0, const Scalar centerX0, const Scalar centerY0, const unsigned int image0PaddingElements, const uint8_t *buffer1)
Determines the sum of square differences between an image patch with sub-pixel accuracy and a memory ...
Definition AdvancedSumSquareDifferences.h:237
static IndexPair32 patchWithMask8BitPerChannel(const uint8_t *image0, const uint8_t *image1, const uint8_t *mask0, const uint8_t *mask1, const unsigned int width0, const unsigned int height0, const unsigned int width1, const unsigned int height1, const unsigned int centerX0, const unsigned int centerY0, const unsigned int centerX1, const unsigned int centerY1, const unsigned int image0PaddingElements, const unsigned int image1PaddingElements, const unsigned int mask0PaddingElements, const unsigned int mask1PaddingElements, const uint8_t maskValue)
Returns the sum of square differences for an image patch determined for two pixel accurate positions ...
Definition AdvancedSumSquareDifferences.h:293
static uint32_t patchMirroredBorderBuffer8BitPerChannel(const uint8_t *image0, const unsigned int width0, const unsigned int height0, const Scalar centerX0, const Scalar centerY0, const unsigned int image0PaddingElements, const uint8_t *buffer1)
Determines the sum of square differences between an image patch with sub-pixel accuracy and a memory ...
Definition AdvancedSumSquareDifferences.h:270
static IndexPair32 patchWithRejectingMask8BitPerChannel(const uint8_t *image0, const uint8_t *image1, const uint8_t *mask0, const uint8_t *mask1, const unsigned int patchSize, const unsigned int width0, const unsigned int height0, const unsigned int width1, const unsigned int height1, const unsigned int centerX0, const unsigned int centerY0, const unsigned int centerX1, const unsigned int centerY1, const unsigned int image0PaddingElements, const unsigned int image1PaddingElements, const unsigned int mask0PaddingElements, const unsigned int mask1PaddingElements, const uint8_t maskValue)
Returns the sum of square differences for an image patch determined for two pixel accurate positions ...
Definition AdvancedSumSquareDifferences.h:313
std::pair< Index32, Index32 > IndexPair32
Definition of a pair holding 32 bit indices.
Definition Base.h:138
float Scalar
Definition of a scalar type.
Definition Math.h:129
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition Vector2.h:28
The namespace covering the entire Ocean framework.
Definition Accessor.h:15