Ocean
SumSquareDifferencesNoCenterBase.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_SUM_SQUARE_DIFFERENCES_NO_CENTER_BASE_H
9 #define META_OCEAN_CV_ADVANCED_SUM_SQUARE_DIFFERENCES_NO_CENTER_BASE_H
10 
12 
15 
16 namespace Ocean
17 {
18 
19 namespace CV
20 {
21 
22 namespace Advanced
23 {
24 
25 /**
26  * This class implements functions calculating the sum of square differences and omits center pixel.
27  * @ingroup cvadvanced
28  */
30 {
31  protected:
32 
33  /**
34  * Internal helper class providing access to CV::SumSquareDifferencesBase
35  */
37  {
38  // nothing to do here
39  };
40 
41  public:
42 
43  /**
44  * Returns the sum of square differences between two square patches while skipping the center pixel.
45  * @param image0 The first image in which the first patch is located, must be valid
46  * @param image1 The second image in which the second patch is located, must be valid
47  * @param width0 Width of the first frame in pixels, with range [tPatchSize, infinity)
48  * @param width1 Width of the second frame in pixels, with range [tPatchSize, infinity)
49  * @param centerX0 Horizontal center position of the (tPatchSize x tPatchSize) block in the first frame, with range [tPatchSize / 2, width0 - tPatchSize / 2 - 1]
50  * @param centerY0 Vertical center position of the (tPatchSize x tPatchSize) block in the first frame, with range [tPatchSize / 2, height0 - tPatchSize / 2 - 1]
51  * @param centerX1 Horizontal center position of the (tPatchSize x tPatchSize) block in the second frame, with range [tPatchSize / 2, width1 - tPatchSize / 2 - 1]
52  * @param centerY1 Vertical center position of the (tPatchSize x tPatchSize) block in the second frame, with range [tPatchSize / 2, height1 - tPatchSize / 2 - 1]
53  * @param image0PaddingElements The number of padding elements at the end of each first image, in elements, with range [0, infinity)
54  * @param image1PaddingElements The number of padding elements at the end of each second image, in elements, with range [0, infinity)
55  * @return The resulting sum of square differences for tPatchSize * tPatchSize * tChannels elements
56  * @tparam tChannels Specifies the number of channels for the given frames, with range [1, infinity)
57  * @tparam tPatchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
58  */
59  template <unsigned int tChannels, unsigned int tPatchSize>
60  static OCEAN_FORCE_INLINE uint32_t patch8BitPerChannelTemplate(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 
62  /**
63  * Returns the sum of square differences between two square patches.
64  * @param image0 The first image in which the first patch is located, must be valid
65  * @param image1 The second image in which the second patch is located, must be valid
66  * @param width0 Width of the first frame in pixels, with range [patchSize, infinity)
67  * @param width1 Width of the second frame in pixels, with range [patchSize, infinity)
68  * @param channels Specifies the number of channels for the given frames, with range [1, infinity)
69  * @param patchSize The size of the square patch (the edge length) in pixel, with range [1, infinity), must be odd
70  * @param centerX0 Horizontal center position of the (patchSize x patchSize) block in the first frame, with range [patchSize / 2, width0 - patchSize / 2 - 1]
71  * @param centerY0 Vertical center position of the (patchSize x patchSize) block in the first frame, with range [patchSize / 2, height0 - patchSize / 2 - 1]
72  * @param centerX1 Horizontal center position of the (patchSize x patchSize) block in the second frame, with range [patchSize / 2, width1 - patchSize / 2 - 1]
73  * @param centerY1 Vertical center position of the (patchSize x patchSize) block in the second frame, with range [patchSize / 2, height1 - patchSize / 2 - 1]
74  * @param image0PaddingElements The number of padding elements at the end of each first image, in elements, with range [0, infinity)
75  * @param image1PaddingElements The number of padding elements at the end of each second image, in elements, with range [0, infinity)
76  * @return The resulting sum of square differences for `patchSize * patchSize * channels` elements
77  */
78  static OCEAN_FORCE_INLINE uint32_t patch8BitPerChannel(const uint8_t* const image0, const uint8_t* const image1, const unsigned int channels, const unsigned int patchSize, 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);
79 };
80 
81 template <unsigned int tChannels, unsigned int tPatchSize>
82 inline uint32_t SumSquareDifferencesNoCenterBase::patch8BitPerChannelTemplate(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)
83 {
84  return SumSquareDifferencesBase::patch8BitPerChannelTemplate<tChannels, tPatchSize>(image0, image1, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements)
85  - SumSquareDifferencesBase::patch8BitPerChannelTemplate<tChannels, 1u>(image0, image1, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
86 }
87 
88 uint32_t SumSquareDifferencesNoCenterBase::patch8BitPerChannel(const uint8_t* const image0, const uint8_t* const image1, const unsigned int channels, const unsigned int patchSize, 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)
89 {
90  return SumSquareDifferencesBase::patch8BitPerChannel(image0, image1, channels, patchSize, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements)
91  - SumSquareDifferencesBase::patch8BitPerChannel(image0, image1, channels, 1u, width0, width1, centerX0, centerY0, centerX1, centerY1, image0PaddingElements, image1PaddingElements);
92 }
93 
94 }
95 
96 }
97 
98 }
99 
100 #endif // META_OCEAN_CV_ADVANCED_SUM_SQUARE_DIFFERENCES_NO_CENTER_BASE_H
Internal helper class providing access to CV::SumSquareDifferencesBase.
Definition: SumSquareDifferencesNoCenterBase.h:37
This class implements functions calculating the sum of square differences and omits center pixel.
Definition: SumSquareDifferencesNoCenterBase.h:30
static OCEAN_FORCE_INLINE uint32_t patch8BitPerChannel(const uint8_t *const image0, const uint8_t *const image1, const unsigned int channels, const unsigned int patchSize, 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 sum of square differences between two square patches.
Definition: SumSquareDifferencesNoCenterBase.h:88
static OCEAN_FORCE_INLINE uint32_t patch8BitPerChannelTemplate(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 sum of square differences between two square patches while skipping the center pixel.
This class implements several sum square differences functions based e.g., on template parameters.
Definition: SumSquareDifferencesBase.h:25
static OCEAN_FORCE_INLINE uint32_t patch8BitPerChannel(const uint8_t *const image0, const uint8_t *const image1, const unsigned int channels, const unsigned int patchSize, 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 sum of square differences between two square patches.
Definition: SumSquareDifferencesBase.h:518
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15