8 #ifndef META_OCEAN_CV_ZERO_MEAN_SUM_SQUARE_DIFFERENCES_H
9 #define META_OCEAN_CV_ZERO_MEAN_SUM_SQUARE_DIFFERENCES_H
46 template <
unsigned int tChannels,
unsigned int tPatchSize>
47 static inline uint32_t
patch8BitPerChannel(
const uint8_t*
const image0,
const uint8_t*
const image1,
const unsigned int width0,
const unsigned int width1,
const unsigned int centerX0,
const unsigned int centerY0,
const unsigned int centerX1,
const unsigned int centerY1,
const unsigned int image0PaddingElements,
const unsigned int image1PaddingElements);
61 template <
unsigned int tChannels,
unsigned int tPatchSize>
62 static inline unsigned int patchBuffer8BitPerChannel(
const uint8_t*
const image0,
const unsigned int width0,
const unsigned int centerX0,
const unsigned int centerY0,
const unsigned int image0PaddingElements,
const uint8_t*
const buffer1);
72 template <
unsigned int tChannels,
unsigned int tPixels>
73 static inline uint32_t
buffer8BitPerChannel(
const uint8_t*
const buffer0,
const uint8_t*
const buffer1);
93 template <
unsigned int tChannels,
unsigned int tPatchSize>
94 static uint32_t
patchMirroredBorder8BitPerChannel(
const uint8_t* image0,
const uint8_t* image1,
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);
97 template <
unsigned int tChannels,
unsigned int tPatchSize>
98 inline uint32_t
ZeroMeanSumSquareDifferences::patch8BitPerChannel(
const uint8_t*
const image0,
const uint8_t*
const image1,
const unsigned int width0,
const unsigned int width1,
const unsigned int centerX0,
const unsigned int centerY0,
const unsigned int centerX1,
const unsigned int centerY1,
const unsigned int image0PaddingElements,
const unsigned int image1PaddingElements)
100 static_assert(tChannels >= 1u,
"Invalid channel number!");
101 static_assert(tPatchSize >= 1u,
"Invalid patch size!");
103 ocean_assert(image0 !=
nullptr && image1 !=
nullptr);
105 ocean_assert(width0 >= tPatchSize);
106 ocean_assert(width1 >= tPatchSize);
108 constexpr
unsigned int tPatchSize_2 = tPatchSize / 2u;
110 ocean_assert(centerX0 >= tPatchSize_2 && centerY0 >= tPatchSize_2);
111 ocean_assert(centerX1 >= tPatchSize_2 && centerY1 >= tPatchSize_2);
113 ocean_assert(centerX0 < width0 - tPatchSize_2);
114 ocean_assert(centerX1 < width1 - tPatchSize_2);
116 const unsigned int image0StrideElements = width0 * tChannels + image0PaddingElements;
117 const unsigned int image1StrideElements = width1 * tChannels + image1PaddingElements;
119 const uint8_t*
const patch0 = image0 + (centerY0 - tPatchSize_2) * image0StrideElements + (centerX0 - tPatchSize_2) * tChannels;
120 const uint8_t*
const patch1 = image1 + (centerY1 - tPatchSize_2) * image1StrideElements + (centerX1 - tPatchSize_2) * tChannels;
122 #if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
124 if constexpr ((tChannels == 1u || tChannels == 3u) && tPatchSize >= 5u)
126 return ZeroMeanSumSquareDifferencesSSE::patch8BitPerChannel<tChannels, tPatchSize>(patch0, patch1, image0StrideElements, image1StrideElements);
129 #elif defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
131 if constexpr ((tChannels == 1u || tChannels == 3u) && tPatchSize >= 5u)
133 return ZeroMeanSumSquareDifferencesNEON::patch8BitPerChannel<tChannels, tPatchSize>(patch0, patch1, image0StrideElements, image1StrideElements);
138 return ZeroMeanSumSquareDifferencesBase::patch8BitPerChannelTemplate<tChannels, tPatchSize>(patch0, patch1, image0StrideElements, image1StrideElements);
141 template <
unsigned int tChannels,
unsigned int tPatchSize>
144 static_assert(tChannels >= 1u,
"Invalid channel number!");
145 static_assert(tPatchSize % 2u == 1u,
"Invalid patch size!");
147 ocean_assert(image0 !=
nullptr && buffer1 !=
nullptr);
149 ocean_assert(width0 >= tPatchSize);
151 constexpr
unsigned int tPatchSize_2 = tPatchSize / 2u;
153 ocean_assert(centerX0 >= tPatchSize_2 && centerY0 >= tPatchSize_2);
155 ocean_assert(centerX0 < width0 - tPatchSize_2);
157 const unsigned int image0StrideElements = width0 * tChannels + image0PaddingElements;
159 const uint8_t*
const patch0 = image0 + (centerY0 - tPatchSize_2) * image0StrideElements + (centerX0 - tPatchSize_2) * tChannels;
161 #if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
163 if constexpr ((tChannels == 1u || tChannels == 3u) && tPatchSize >= 5u)
165 return ZeroMeanSumSquareDifferencesSSE::patchBuffer8BitPerChannel<tChannels, tPatchSize>(patch0, buffer1, image0StrideElements);
168 #elif defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
170 if constexpr ((tChannels == 1u || tChannels == 3u) && tPatchSize >= 5u)
172 return ZeroMeanSumSquareDifferencesNEON::patchBuffer8BitPerChannel<tChannels, tPatchSize>(patch0, buffer1, image0StrideElements);
177 return ZeroMeanSumSquareDifferencesBase::patchBuffer8BitPerChannelTemplate<tChannels, tPatchSize>(patch0, buffer1, image0StrideElements);
180 template <
unsigned int tChannels,
unsigned int tPixels>
183 static_assert(tChannels >= 1u,
"Invalid channel number!");
184 static_assert(tPixels >= 1u,
"Invalid pixel number!");
186 #if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
188 if constexpr ((tChannels == 1u || tChannels == 3u) && tPixels >= 8u)
190 return ZeroMeanSumSquareDifferencesSSE::buffer8BitPerChannel<tChannels, tPixels>(buffer0, buffer1);
193 #elif defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
195 if constexpr ((tChannels == 1u || tChannels == 3u) && tPixels >= 8u)
197 return ZeroMeanSumSquareDifferencesNEON::buffer8BitPerChannel<tChannels, tPixels>(buffer0, buffer1);
202 return ZeroMeanSumSquareDifferencesBase::buffer8BitPerChannelTemplate<tChannels, tPixels>(buffer0, buffer1);
205 template <
unsigned int tChannels,
unsigned int tPatchSize>
206 uint32_t
ZeroMeanSumSquareDifferences::patchMirroredBorder8BitPerChannel(
const uint8_t* image0,
const uint8_t* image1,
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)
208 static_assert(tChannels >= 1u,
"Invalid channel number!");
209 static_assert(tPatchSize % 2u == 1u,
"Invalid patch size!");
211 #if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
213 if constexpr (tChannels == 1u && tPatchSize >= 5u)
215 return ZeroMeanSumSquareDifferencesNEON::patchMirroredBorder8BitPerChannel<tChannels, tPatchSize>(image0, image1, width0, height0, width1, height1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
220 return ZeroMeanSumSquareDifferencesBase::patchMirroredBorder8BitPerChannel<tChannels>(image0, image1, tPatchSize, width0, height0, width1, height1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
This class implements several zero-mean sum square differences functions based e.g....
Definition: ZeroMeanSumSquareDifferencesBase.h:25
This class implements functions calculating the zero-mean sum of square differences.
Definition: ZeroMeanSumSquareDifferences.h:27
static uint32_t patch8BitPerChannel(const uint8_t *const image0, const uint8_t *const image1, const unsigned int width0, const unsigned int width1, const unsigned int centerX0, const unsigned int centerY0, const unsigned int centerX1, const unsigned int centerY1, const unsigned int image0PaddingElements, const unsigned int image1PaddingElements)
Returns the zero-mean sum of square differences between two square image patches.
Definition: ZeroMeanSumSquareDifferences.h:98
static uint32_t buffer8BitPerChannel(const uint8_t *const buffer0, const uint8_t *const buffer1)
Returns the zero-mean sum of square differences between two memory buffers.
Definition: ZeroMeanSumSquareDifferences.h:181
static uint32_t patchMirroredBorder8BitPerChannel(const uint8_t *image0, const uint8_t *image1, 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)
Returns the sum of zero-mean square differences between two patches within an image,...
Definition: ZeroMeanSumSquareDifferences.h:206
static unsigned int patchBuffer8BitPerChannel(const uint8_t *const image0, const unsigned int width0, const unsigned int centerX0, const unsigned int centerY0, const unsigned int image0PaddingElements, const uint8_t *const buffer1)
Returns the zero-mean sum of square differences between an image patch and a memory buffer.
Definition: ZeroMeanSumSquareDifferences.h:142
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15