8 #ifndef META_OCEAN_CV_ADVANCED_ADVANCED_ZERO_MEAN_SUM_SQUARE_DIFFERENCES_H
9 #define META_OCEAN_CV_ADVANCED_ADVANCED_ZERO_MEAN_SUM_SQUARE_DIFFERENCES_H
51 template <
unsigned int tChannels,
unsigned int tPatchSize>
52 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);
70 template <
unsigned int tChannels,
unsigned int tPatchSize>
71 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);
85 template <
unsigned int tChannels,
unsigned int tPatchSize>
86 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);
102 template <
unsigned int tChannels,
unsigned int tPatchSize>
103 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);
106 template <
unsigned int tChannels,
unsigned int tPatchSize>
109 static_assert(tChannels >= 1u,
"Invalid channel number!");
110 static_assert(tPatchSize >= 1u && tPatchSize % 2u == 1u,
"Invalid patch size!");
112 ocean_assert(image0 !=
nullptr && image1 !=
nullptr);
114 ocean_assert(width0 >= tPatchSize + 1u);
115 ocean_assert(width1 >= tPatchSize + 1u);
117 constexpr
unsigned int tPatchSize_2 = tPatchSize / 2u;
119 ocean_assert(centerX0 >=
Scalar(tPatchSize_2) && centerX0 <
Scalar(width0 - tPatchSize_2 - 1u));
120 ocean_assert(centerX1 >=
Scalar(tPatchSize_2) && centerX1 <
Scalar(width1 - tPatchSize_2 - 1u));
122 ocean_assert_and_suppress_unused(centerY0 >=
Scalar(tPatchSize_2) && centerY1 >=
Scalar(tPatchSize_2), tPatchSize_2);
124 #if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
131 #elif defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
140 return AdvancedZeroMeanSumSquareDifferencesBase::patch8BitPerChannelTemplate<tChannels, tPatchSize>(image0, image1, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
143 template <
unsigned int tChannels,
unsigned int tPatchSize>
144 inline uint32_t
AdvancedZeroMeanSumSquareDifferences::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)
146 static_assert(tChannels >= 1u,
"Invalid channel number!");
147 static_assert(tPatchSize >= 1u && tPatchSize % 2u == 1u,
"Invalid patch size!");
149 ocean_assert(image0 !=
nullptr && image1 !=
nullptr);
151 ocean_assert(width0 >= tPatchSize + 1u);
152 ocean_assert(width1 >= tPatchSize + 1u);
154 constexpr
unsigned int tPatchSize_2 = tPatchSize / 2u;
156 ocean_assert(centerX0 >= tPatchSize_2 && centerX0 < width0 - tPatchSize_2);
157 ocean_assert(centerX1 >=
Scalar(tPatchSize_2) && centerX1 <
Scalar(width1 - tPatchSize_2 - 1u));
159 ocean_assert_and_suppress_unused(centerY0 >= tPatchSize_2 && centerY1 >=
Scalar(tPatchSize_2), tPatchSize_2);
161 #if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
168 #elif defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
177 return AdvancedZeroMeanSumSquareDifferencesBase::patch8BitPerChannelTemplate<tChannels, tPatchSize>(image0, image1, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
180 template <
unsigned int tChannels,
unsigned int tPatchSize>
183 static_assert(tChannels != 0u,
"Invalid number of image channels!");
184 static_assert(tPatchSize >= 1u && tPatchSize % 2u == 1u,
"Invalid patch size!");
186 ocean_assert(image0 !=
nullptr && buffer1 !=
nullptr);
188 ocean_assert(width0 >= tPatchSize + 1u);
190 constexpr
unsigned int tPatchSize_2 = tPatchSize / 2u;
192 ocean_assert_and_suppress_unused(centerX0 >=
Scalar(tPatchSize_2) && centerX0 <
Scalar(width0 - tPatchSize_2 - 1u), tPatchSize_2);
193 ocean_assert(centerY0 >=
Scalar(tPatchSize_2));
195 constexpr
unsigned int tPatchPixels = tPatchSize * tPatchSize;
197 uint8_t target[tPatchPixels * tChannels];
198 AdvancedFrameInterpolatorBilinear::interpolateSquarePatch8BitPerChannel<tChannels, tPatchSize>(image0, width0, image0PaddingElements, target,
Vector2(centerX0, centerY0));
199 return ZeroMeanSumSquareDifferences::buffer8BitPerChannel<tChannels, tPatchPixels>(target, buffer1);
202 template <
unsigned int tChannels,
unsigned int tPatchSize>
205 static_assert(tChannels != 0u,
"Invalid number of image channels!");
206 static_assert(tPatchSize >= 1u && tPatchSize % 2u == 1u,
"Invalid patch size!");
208 ocean_assert(image0 !=
nullptr && buffer1 !=
nullptr);
210 constexpr
unsigned int tPatchSize_2 = tPatchSize / 2u;
212 ocean_assert(width0 >= tPatchSize_2 + 1u);
213 ocean_assert_and_suppress_unused(height0 >= tPatchSize_2 + 1u, tPatchSize_2);
215 ocean_assert(centerX0 >=
Scalar(0) && centerX0 <
Scalar(width0));
216 ocean_assert(centerY0 >=
Scalar(0) && centerY0 <
Scalar(height0));
218 constexpr
unsigned int tPatchPixels = tPatchSize * tPatchSize;
220 uint8_t target[tPatchPixels * tChannels];
221 AdvancedFrameInterpolatorBilinear::interpolateSquareMirroredBorder8BitPerChannel<tChannels, tPatchSize>(image0, width0, height0, image0PaddingElements, target,
Vector2(centerX0, centerY0));
222 return ZeroMeanSumSquareDifferences::buffer8BitPerChannel<tChannels, tPatchPixels>(target, buffer1);
This class implements functions calculating the zero-mean sum of square differences.
Definition: AdvancedZeroMeanSumSquareDifferencesBase.h:31
This class implements zero-mean sum of square difference calculation functions.
Definition: AdvancedZeroMeanSumSquareDifferences.h:32
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: AdvancedZeroMeanSumSquareDifferences.h:181
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...
Definition: AdvancedZeroMeanSumSquareDifferences.h:107
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: AdvancedZeroMeanSumSquareDifferences.h:203
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