8 #ifndef META_OCEAN_CV_ADVANCED_ADVANCED_SUM_SQUARE_DIFFERENCES_H
9 #define META_OCEAN_CV_ADVANCED_ADVANCED_SUM_SQUARE_DIFFERENCES_H
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);
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);
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);
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);
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);
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);
162 template <
unsigned int tChannels,
unsigned int tPatchSize>
165 static_assert(tChannels >= 1u,
"Invalid channel number!");
166 static_assert(tPatchSize >= 1u && tPatchSize % 2u == 1u,
"Invalid patch size!");
168 ocean_assert(image0 !=
nullptr && image1 !=
nullptr);
170 ocean_assert(width0 >= tPatchSize + 1u);
171 ocean_assert(width1 >= tPatchSize + 1u);
173 constexpr
unsigned int tPatchSize_2 = tPatchSize / 2u;
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));
178 ocean_assert_and_suppress_unused(centerY0 >=
Scalar(tPatchSize_2) && centerY1 >=
Scalar(tPatchSize_2), tPatchSize_2);
180 #if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
182 if constexpr (tChannels >= 1u && tChannels <= 4u && tPatchSize == 5u)
184 return AdvancedSumSquareDifferencesSSE::patch8BitPerChannel<tChannels, tPatchSize>(image0, image1, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
187 #elif defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
189 if constexpr (tPatchSize >= 5u)
196 return AdvancedSumSquareDifferencesBase::patch8BitPerChannelTemplate<tChannels, tPatchSize>(image0, image1, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
199 template <
unsigned int tChannels,
unsigned int tPatchSize>
200 inline 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)
202 static_assert(tChannels >= 1u,
"Invalid channel number!");
203 static_assert(tPatchSize >= 1u && tPatchSize % 2u == 1u,
"Invalid patch size!");
205 ocean_assert(image0 !=
nullptr && image1 !=
nullptr);
207 ocean_assert(width0 >= tPatchSize + 1u);
208 ocean_assert(width1 >= tPatchSize + 1u);
210 constexpr
unsigned int tPatchSize_2 = tPatchSize / 2u;
212 ocean_assert(centerX0 >= tPatchSize_2 && centerX0 < width0 - tPatchSize_2);
213 ocean_assert(centerX1 >=
Scalar(tPatchSize_2) && centerX1 <
Scalar(width1 - tPatchSize_2 - 1u));
215 ocean_assert_and_suppress_unused(centerY0 >= tPatchSize_2 && centerY1 >=
Scalar(tPatchSize_2), tPatchSize_2);
217 #if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
219 if constexpr (tChannels >= 1u && tChannels <= 4u && tPatchSize == 5u)
221 return AdvancedSumSquareDifferencesSSE::patch8BitPerChannel<tChannels, tPatchSize>(image0, image1, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
224 #elif defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
233 return AdvancedSumSquareDifferencesBase::patch8BitPerChannelTemplate<tChannels, tPatchSize>(image0, image1, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
236 template <
unsigned int tChannels,
unsigned int tPatchSize>
239 static_assert(tChannels != 0u,
"Invalid number of image channels!");
240 static_assert(tPatchSize >= 1u && tPatchSize % 2u == 1u,
"Invalid patch size!");
242 ocean_assert(image0 !=
nullptr && buffer1 !=
nullptr);
244 ocean_assert(width0 >= tPatchSize + 1u);
246 constexpr
unsigned int tPatchSize_2 = tPatchSize / 2u;
248 ocean_assert_and_suppress_unused(centerX0 >=
Scalar(tPatchSize_2) && centerX0 <
Scalar(width0 - tPatchSize_2 - 1u), tPatchSize_2);
250 #if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
257 #elif defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
266 return AdvancedSumSquareDifferencesBase::patchBuffer8BitPerChannelTemplate<tChannels, tPatchSize>(image0, width0, centerX0, centerY0, image0PaddingElements, buffer1);
269 template <
unsigned int tChannels,
unsigned int tPatchSize>
272 static_assert(tChannels != 0u,
"Invalid number of image channels!");
273 static_assert(tPatchSize >= 1u && tPatchSize % 2u == 1u,
"Invalid patch size!");
275 ocean_assert(image0 !=
nullptr && buffer1 !=
nullptr);
277 constexpr
unsigned int tPatchSize_2 = tPatchSize / 2u;
279 ocean_assert(width0 >= tPatchSize_2 + 1u);
280 ocean_assert_and_suppress_unused(height0 >= tPatchSize_2 + 1u, tPatchSize_2);
282 ocean_assert(centerX0 >=
Scalar(0) && centerX0 <
Scalar(width0));
283 ocean_assert(centerY0 >=
Scalar(0) && centerY0 <
Scalar(height0));
285 constexpr
unsigned int tPatchPixels = tPatchSize * tPatchSize;
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);
292 template <
unsigned int tChannels,
unsigned int tPatchSize>
293 inline 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)
295 static_assert(tChannels >= 1u,
"Invalid channel number!");
296 static_assert(tPatchSize >= 1u && tPatchSize % 2u == 1u,
"Invalid patch size!");
298 ocean_assert(image0 !=
nullptr && image1 !=
nullptr);
299 ocean_assert(mask0 !=
nullptr && mask1 !=
nullptr);
301 const unsigned int patchSize_2 = tPatchSize / 2u;
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);
306 ocean_assert(centerX0 < width0 && centerY0 < height0);
307 ocean_assert(centerX1 < width1 && centerY1 < height1);
309 return AdvancedSumSquareDifferencesBase::patchWithMask8BitPerChannelTemplate<tChannels, tPatchSize>(image0, image1, mask0, mask1, width0, height0, width1, height1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements, mask0PaddingElements, mask1PaddingElements, maskValue);
312 template <
unsigned int tChannels>
313 inline 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)
315 static_assert(tChannels >= 1u,
"Invalid channel number!");
317 ocean_assert(image0 !=
nullptr && image1 !=
nullptr);
318 ocean_assert(mask0 !=
nullptr && mask1 !=
nullptr);
320 ocean_assert(patchSize >= 1u && patchSize % 2u == 1u);
322 const unsigned int patchSize_2 = patchSize / 2u;
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);
327 ocean_assert(centerX0 < width0 && centerY0 < height0);
328 ocean_assert(centerX1 < width1 && centerY1 < height1);
330 return AdvancedSumSquareDifferencesBase::patchWithRejectingMask8BitPerChannel(image0, image1, mask0, mask1, tChannels, patchSize, width0, height0, width1, height1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements, mask0PaddingElements, mask1PaddingElements, maskValue);
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:128
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition: Vector2.h:21
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15