8#ifndef META_OCEAN_CV_INTEGRAL_IMAGE_H
9#define META_OCEAN_CV_INTEGRAL_IMAGE_H
106 template <
typename T,
typename TIntegral>
117 template <
typename T,
typename TIntegral>
147 template <
typename T,
typename TIntegral,
unsigned int tChannels>
148 static void createImage(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements);
175 template <
typename T,
typename TIntegral,
unsigned int tChannels>
176 static void createLinedImage(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements);
203 template <
typename T,
typename TIntegral,
unsigned int tChannels>
204 static void createLinedImageSquared(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements);
238 template <
typename T,
typename TIntegralAndSquared,
unsigned int tChannels>
239 static void createLinedImageAndSquared(
const T* source, TIntegralAndSquared* integralAndSquared,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralAndSquaredPaddingElements);
274 template <
typename T,
typename TIntegral,
typename TIntegralSquared,
unsigned int tChannels>
275 static void createLinedImageAndSquared(
const T* source, TIntegral* integral, TIntegralSquared* integralSquared,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements,
const unsigned int integralSquaredPaddingElements);
319 template <
typename T,
typename TIntegral,
unsigned int tChannels>
320 static void createBorderedImage(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int border,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements);
364 template <
typename T,
typename TIntegral,
unsigned int tChannels>
365 static void createBorderedImageSquared(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int border,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements);
404 template <
typename T,
typename TIntegral,
unsigned int tChannels>
405 static void createBorderedImageMirror(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int border,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements);
444 template <
typename T,
typename TIntegral,
unsigned int tChannels>
445 static void createBorderedImageSquaredMirror(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int border,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements);
477 template <
typename TIntegral>
478 static OCEAN_FORCE_INLINE TIntegral
linedIntegralSum(
const TIntegral*
const linedIntegral,
const unsigned int linedIntegralStrideElements,
const unsigned int windowLeft,
const unsigned int windowTop,
const unsigned int windowWidth,
const unsigned int windowHeight);
521 template <
typename TIntegral,
typename TIntegralSquared,
typename TVariance,
bool tReturnMean = false>
522 static inline TVariance linedIntegralVariance(
const TIntegral* linedIntegral,
const TIntegralSquared* linedIntegralSquared,
const unsigned int integralStrideElements,
const unsigned int integralStrideSquaredElements,
const unsigned int windowLeft,
const unsigned int windowTop,
const unsigned int windowWidth,
const unsigned int windowHeight, TVariance* mean =
nullptr);
570 template <
typename TIntegral,
typename TIntegralSquared,
typename TVariance,
bool tReturnMean = false>
571 static inline TVariance linedIntegralVariance(
const TIntegral* linedIntegral,
const TIntegralSquared* linedIntegralSquared,
const unsigned int integralStrideElements,
const unsigned int integralStrideSquaredElements,
const unsigned int windowALeft,
const unsigned int windowATop,
const unsigned int windowAWidth,
const unsigned int windowAHeight,
const unsigned int windowBLeft,
const unsigned int windowBTop,
const unsigned int windowBWidth,
const unsigned int windowBHeight, TVariance* mean =
nullptr);
599 template <
typename TIntegral,
typename TIntegralSquared,
typename TVariance,
bool tReturnMean = false>
600 static inline TVariance linedIntegralVariance(
const TIntegral* linedIntegral,
const TIntegralSquared* linedIntegralSquared,
const unsigned int integralStrideElements,
const unsigned int integralStrideSquaredElements,
const unsigned int windowALeft,
const unsigned int windowATop,
const unsigned int windowAWidth,
const unsigned int windowAHeight,
const unsigned int windowBLeft,
const unsigned int windowBTop,
const unsigned int windowBWidth,
const unsigned int windowBHeight,
const unsigned int windowCLeft,
const unsigned int windowCTop,
const unsigned int windowCWidth,
const unsigned int windowCHeight, TVariance* mean =
nullptr);
604#if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
616 static void createLinedImage1Channel8BitSSE(
const uint8_t* source, uint32_t* integral,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements);
620#if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
622#if defined(__aarch64__)
634 static void createLinedImage1Channel8BitNEON(
const uint8_t* source, uint32_t* integral,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements);
647 template <
typename T,
typename TSquared>
648 static inline TSquared
sqr(
const T& value);
651template <
typename T,
typename TIntegral,
unsigned int tChannels>
652void IntegralImage::createImage(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements)
654 static_assert(std::is_signed<T>::value == std::is_signed<TIntegral>::value,
"The integral image must have the same sign-properties as the source image!");
655 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
656 static_assert(tChannels >= 1u,
"Invalid channel number!");
658 ocean_assert(source !=
nullptr && integral !=
nullptr);
659 ocean_assert(width >= 1u && height >= 1u);
663 const T*
const sourceFirstRowEnd = source + width * tChannels;
664 const T*
const sourceEnd = source + (width * tChannels + sourcePaddingElements) * height;
665 const TIntegral* integralPreviousRow = integral;
667 TIntegral previousIntegral[tChannels];
668 for (
unsigned int n = 0u; n < tChannels; ++n)
670 previousIntegral[n] = TIntegral(0);
675 while (source != sourceFirstRowEnd)
677 for (
unsigned int n = 0u; n < tChannels; ++n)
679 previousIntegral[n] += TIntegral(*source++);
682 for (
unsigned int n = 0u; n < tChannels; ++n)
684 *integral++ = previousIntegral[n];
688 source += sourcePaddingElements;
689 integral += integralPaddingElements;
694 while (source != sourceEnd)
696 const T*
const sourceRowEnd = source + width * tChannels;
698 for (
unsigned int n = 0u; n < tChannels; ++n)
700 previousIntegral[n] = TIntegral(0);
703 while (source != sourceRowEnd)
705 for (
unsigned int n = 0u; n < tChannels; ++n)
707 previousIntegral[n] += TIntegral(*source++);
710 for (
unsigned int n = 0u; n < tChannels; ++n)
712 *integral++ = previousIntegral[n] + *integralPreviousRow++;
716 source += sourcePaddingElements;
717 integral += integralPaddingElements;
718 integralPreviousRow += integralPaddingElements;
722template <
typename T,
typename TIntegral,
unsigned int tChannels>
723void IntegralImage::createLinedImage(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements)
725 static_assert(std::is_signed<T>::value == std::is_signed<TIntegral>::value,
"The integral image must have the same sign-properties as the source image!");
726 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
727 static_assert(tChannels >= 1u,
"Invalid channel number!");
729 ocean_assert(source !=
nullptr && integral !=
nullptr);
730 ocean_assert(width >= 1u && height >= 1u);
734#if defined(OCEAN_HARDWARE_SSE_VERSION) && OCEAN_HARDWARE_SSE_VERSION >= 41
736 if (std::is_same<T, uint8_t>::value && std::is_same<TIntegral, uint32_t>::value && tChannels == 1u && width >= 8u)
744#if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10 && defined(__aarch64__)
746 if (std::is_same<T, uint8_t>::value && std::is_same<TIntegral, uint32_t>::value && tChannels == 1u && width >= 8u)
766 memset(integral, 0x00, (width + 1u) * tChannels *
sizeof(TIntegral));
769 for (
unsigned int n = 0u; n < width + 1u; ++n)
771 ocean_assert(integral[n] == TIntegral(0));
777 const T*
const sourceFirstRowEnd = source + width * tChannels;
778 const T*
const sourceEnd = source + (width * tChannels + sourcePaddingElements) * height;
780 integral += (width + 1u) * tChannels + integralPaddingElements;
781 const TIntegral* integralPreviousRow = integral;
783 TIntegral previousIntegral[tChannels] = {TIntegral(0)};
786 for (
unsigned int n = 0u; n < tChannels; ++n)
788 *integral++ = TIntegral(0);
793 while (source != sourceFirstRowEnd)
795 for (
unsigned int n = 0u; n < tChannels; ++n)
797 previousIntegral[n] += *source++;
800 for (
unsigned int n = 0u; n < tChannels; ++n)
802 *integral++ = previousIntegral[n];
806 source += sourcePaddingElements;
807 integral += integralPaddingElements;
812 while (source != sourceEnd)
814 const T*
const sourceRowEnd = source + width * tChannels;
816 for (
unsigned int n = 0u; n < tChannels; ++n)
818 previousIntegral[n] = TIntegral(0);
822 for (
unsigned int n = 0u; n < tChannels; ++n)
824 *integral++ = TIntegral(0);
827 integralPreviousRow += tChannels;
829 while (source != sourceRowEnd)
831 for (
unsigned int n = 0u; n < tChannels; ++n)
833 previousIntegral[n] += *source++;
836 for (
unsigned int n = 0u; n < tChannels; ++n)
838 *integral++ = previousIntegral[n] + *integralPreviousRow++;
842 source += sourcePaddingElements;
843 integral += integralPaddingElements;
844 integralPreviousRow += integralPaddingElements;
848template <
typename T,
typename TIntegral,
unsigned int tChannels>
849void IntegralImage::createLinedImageSquared(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements)
851 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
852 static_assert(tChannels >= 1u,
"Invalid channel number!");
854 ocean_assert(source !=
nullptr && integral !=
nullptr);
855 ocean_assert(width >= 1u && height >= 1u);
860 memset(integral, 0x00, (width + 1u) * tChannels *
sizeof(TIntegral));
863 for (
unsigned int n = 0u; n < width + 1u; ++n)
865 ocean_assert(integral[n] == TIntegral(0));
871 const T*
const sourceFirstRowEnd = source + width * tChannels;
872 const T*
const sourceEnd = source + (width * tChannels + sourcePaddingElements) * height;
874 integral += (width + 1u) * tChannels + integralPaddingElements;
875 const TIntegral* integralPreviousRow = integral;
877 TIntegral previousIntegral[tChannels] = {TIntegral(0)};
880 for (
unsigned int n = 0u; n < tChannels; ++n)
882 *integral++ = TIntegral(0);
887 while (source != sourceFirstRowEnd)
889 for (
unsigned int n = 0u; n < tChannels; ++n)
891 previousIntegral[n] += *source * *source;
895 for (
unsigned int n = 0u; n < tChannels; ++n)
897 *integral++ = previousIntegral[n];
901 source += sourcePaddingElements;
902 integral += integralPaddingElements;
907 while (source != sourceEnd)
909 const T*
const sourceRowEnd = source + width * tChannels;
911 for (
unsigned int n = 0u; n < tChannels; ++n)
913 previousIntegral[n] = TIntegral(0);
917 for (
unsigned int n = 0u; n < tChannels; ++n)
919 *integral++ = TIntegral(0);
922 integralPreviousRow += tChannels;
924 while (source != sourceRowEnd)
926 for (
unsigned int n = 0u; n < tChannels; ++n)
928 previousIntegral[n] += *source * *source;
932 for (
unsigned int n = 0u; n < tChannels; ++n)
934 *integral++ = previousIntegral[n] + *integralPreviousRow++;
938 source += sourcePaddingElements;
939 integral += integralPaddingElements;
940 integralPreviousRow += integralPaddingElements;
944template <
typename T,
typename TIntegralAndSquared,
unsigned int tChannels>
945void IntegralImage::createLinedImageAndSquared(
const T* source, TIntegralAndSquared* integralAndSquared,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralAndSquaredPaddingElements)
947 static_assert(
sizeof(T) <=
sizeof(TIntegralAndSquared),
"Invalid integral elements!");
948 static_assert(tChannels >= 1u,
"Invalid channel number!");
950 ocean_assert(source !=
nullptr && integralAndSquared !=
nullptr);
951 ocean_assert(width >= 1u && height >= 1u);
956 memset(integralAndSquared, 0x00, (width + 1u) * tChannels *
sizeof(TIntegralAndSquared) * 2u);
959 for (
unsigned int n = 0u; n < (width + 1u) * 2u; ++n)
961 ocean_assert(integralAndSquared[n] == TIntegralAndSquared(0));
967 const T*
const sourceFirstRowEnd = source + width * tChannels;
968 const T*
const sourceEnd = source + (width * tChannels + sourcePaddingElements) * height;
970 integralAndSquared += (width + 1u) * tChannels * 2u + integralAndSquaredPaddingElements;
971 const TIntegralAndSquared* integralAndSquaredPreviousRow = integralAndSquared;
973 TIntegralAndSquared previousIntegral[tChannels] = {TIntegralAndSquared(0)};
974 TIntegralAndSquared previousIntegralSquared[tChannels] = {TIntegralAndSquared(0)};
977 for (
unsigned int n = 0u; n < tChannels * 2u; ++n)
979 *integralAndSquared++ = TIntegralAndSquared(0);
984 while (source != sourceFirstRowEnd)
986 for (
unsigned int n = 0u; n < tChannels; ++n)
988 previousIntegral[n] += *source;
989 previousIntegralSquared[n] += *source * *source;
993 for (
unsigned int n = 0u; n < tChannels; ++n)
995 *integralAndSquared++ = previousIntegral[n];
998 for (
unsigned int n = 0u; n < tChannels; ++n)
1000 *integralAndSquared++ = previousIntegralSquared[n];
1004 source += sourcePaddingElements;
1005 integralAndSquared += integralAndSquaredPaddingElements;
1009 while (source != sourceEnd)
1011 const T*
const sourceRowEnd = source + width * tChannels;
1013 for (
unsigned int n = 0u; n < tChannels; ++n)
1015 previousIntegral[n] = TIntegralAndSquared(0);
1017 for (
unsigned int n = 0u; n < tChannels; ++n)
1019 previousIntegralSquared[n] = TIntegralAndSquared(0);
1023 for (
unsigned int n = 0u; n < tChannels * 2u; ++n)
1025 *integralAndSquared++ = TIntegralAndSquared(0);
1028 integralAndSquaredPreviousRow += tChannels * 2u;
1030 while (source != sourceRowEnd)
1032 for (
unsigned int n = 0u; n < tChannels; ++n)
1034 previousIntegral[n] += *source;
1035 previousIntegralSquared[n] += *source * *source;
1039 for (
unsigned int n = 0u; n < tChannels; ++n)
1041 *integralAndSquared++ = previousIntegral[n] + *integralAndSquaredPreviousRow++;
1043 for (
unsigned int n = 0u; n < tChannels; ++n)
1045 *integralAndSquared++ = previousIntegralSquared[n] + *integralAndSquaredPreviousRow++;
1049 source += sourcePaddingElements;
1050 integralAndSquared += integralAndSquaredPaddingElements;
1051 integralAndSquaredPreviousRow += integralAndSquaredPaddingElements;
1055template <
typename T,
typename TIntegral,
typename TIntegralSquared,
unsigned int tChannels>
1056void IntegralImage::createLinedImageAndSquared(
const T* source, TIntegral* integral, TIntegralSquared* integralSquared,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements,
const unsigned int integralSquaredPaddingElements)
1058 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
1059 static_assert(
sizeof(TIntegral) <=
sizeof(TIntegralSquared),
"Invalid integral elements!");
1060 static_assert(tChannels >= 1u,
"Invalid channel number!");
1062 ocean_assert(source !=
nullptr && integral !=
nullptr && integralSquared !=
nullptr);
1063 ocean_assert(width >= 1u && height >= 1u);
1068 memset(integral, 0x00, (width + 1u) * tChannels *
sizeof(TIntegral));
1069 memset(integralSquared, 0x00, (width + 1u) * tChannels *
sizeof(TIntegralSquared));
1072 for (
unsigned int n = 0u; n < width + 1u; ++n)
1074 ocean_assert(integral[n] == TIntegral(0));
1075 ocean_assert(integralSquared[n] == TIntegralSquared(0));
1081 const T*
const sourceFirstRowEnd = source + width * tChannels;
1082 const T*
const sourceEnd = source + (width * tChannels + sourcePaddingElements) * height;
1084 integral += (width + 1u) * tChannels + integralPaddingElements;
1085 integralSquared += (width + 1u) * tChannels + integralSquaredPaddingElements;
1086 const TIntegral* integralPreviousRow = integral;
1087 const TIntegralSquared* integralSquaredPreviousRow = integralSquared;
1089 TIntegral previousIntegral[tChannels] = {TIntegral(0)};
1090 TIntegralSquared previousIntegralSquared[tChannels] = {TIntegralSquared(0)};
1093 for (
unsigned int n = 0u; n < tChannels; ++n)
1095 *integral++ = TIntegral(0);
1098 for (
unsigned int n = 0u; n < tChannels; ++n)
1100 *integralSquared++ = TIntegralSquared(0);
1105 while (source != sourceFirstRowEnd)
1107 for (
unsigned int n = 0u; n < tChannels; ++n)
1109 previousIntegral[n] += *source;
1110 previousIntegralSquared[n] += *source * *source;
1114 for (
unsigned int n = 0u; n < tChannels; ++n)
1116 *integral++ = previousIntegral[n];
1119 for (
unsigned int n = 0u; n < tChannels; ++n)
1121 *integralSquared++ = previousIntegralSquared[n];
1125 source += sourcePaddingElements;
1126 integral += integralPaddingElements;
1127 integralSquared += integralSquaredPaddingElements;
1131 while (source != sourceEnd)
1133 const T*
const sourceRowEnd = source + width * tChannels;
1135 for (
unsigned int n = 0u; n < tChannels; ++n)
1137 previousIntegral[n] = TIntegral(0);
1139 for (
unsigned int n = 0u; n < tChannels; ++n)
1141 previousIntegralSquared[n] = TIntegralSquared(0);
1145 for (
unsigned int n = 0u; n < tChannels; ++n)
1147 *integral++ = TIntegral(0);
1150 for (
unsigned int n = 0u; n < tChannels; ++n)
1152 *integralSquared++ = TIntegralSquared(0);
1155 integralPreviousRow += tChannels;
1156 integralSquaredPreviousRow += tChannels;
1158 while (source != sourceRowEnd)
1160 for (
unsigned int n = 0u; n < tChannels; ++n)
1162 previousIntegral[n] += *source;
1163 previousIntegralSquared[n] += *source * *source;
1167 for (
unsigned int n = 0u; n < tChannels; ++n)
1169 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1171 for (
unsigned int n = 0u; n < tChannels; ++n)
1173 *integralSquared++ = previousIntegralSquared[n] + *integralSquaredPreviousRow++;
1177 source += sourcePaddingElements;
1179 integral += integralPaddingElements;
1180 integralSquared += integralSquaredPaddingElements;
1182 integralPreviousRow += integralPaddingElements;
1183 integralSquaredPreviousRow += integralSquaredPaddingElements;
1187template <
typename T,
typename TIntegral,
unsigned int tChannels>
1188void IntegralImage::createBorderedImage(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int border,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements)
1190 static_assert(std::is_signed<T>::value == std::is_signed<TIntegral>::value,
"The integral image must have the same sign-properties as the source image!");
1191 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
1192 static_assert(tChannels >= 1u,
"Invalid channel number!");
1194 ocean_assert(source !=
nullptr && integral !=
nullptr);
1195 ocean_assert(width >= 1u && height >= 1u);
1196 ocean_assert(border >= 1u);
1222 const unsigned int integralWidth = width + (border * 2u) + 1u;
1224 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
1225 const unsigned int integralStrideElements = integralWidth * tChannels + integralPaddingElements;
1229 if (integralPaddingElements == 0u)
1231 memset(integral, 0x00, integralWidth * tChannels *
sizeof(TIntegral) * (border + 1u));
1234 for (
unsigned int n = 0u; n < integralWidth; ++n)
1236 ocean_assert(integral[n] == TIntegral(0));
1240 integral += integralStrideElements * (border + 1u);
1244 for (
unsigned int y = 0u; y < border + 1u; ++y)
1246 memset(integral, 0x00, integralWidth * tChannels *
sizeof(TIntegral));
1249 for (
unsigned int n = 0u; n < integralWidth; ++n)
1251 ocean_assert(integral[n] == TIntegral(0));
1255 integral += integralStrideElements;
1262 memset(integral, 0x00, (border + 1u) * tChannels *
sizeof(TIntegral));
1263 integral += (border + 1u) * tChannels;
1265 const T*
const sourceFirstRowEnd = source + tChannels * width;
1266 const T*
const sourceEnd = source + sourceStrideElements * height;
1267 const TIntegral* integralPreviousRow = integral;
1269 TIntegral previousIntegral[tChannels] = {0u};
1271 while (source != sourceFirstRowEnd)
1273 for (
unsigned int n = 0u; n < tChannels; ++n)
1275 previousIntegral[n] += *source++;
1278 for (
unsigned int n = 0u; n < tChannels; ++n)
1280 *integral++ = previousIntegral[n];
1286 for (
unsigned int n = 0u; n < border; ++n)
1288 for (
unsigned int c = 0u; c < tChannels; ++c)
1290 *integral++ = previousIntegral[c];
1294 integral += integralPaddingElements;
1295 source += sourcePaddingElements;
1299 while (source != sourceEnd)
1301 ocean_assert(source < sourceEnd);
1304 memset(integral, 0x00, (border + 1u) * tChannels *
sizeof(TIntegral));
1305 integral += (border + 1u) * tChannels;
1307 const T*
const sourceRowEnd = source + tChannels * width;
1309 for (
unsigned int n = 0u; n < tChannels; ++n)
1311 previousIntegral[n] = TIntegral(0);
1314 while (source != sourceRowEnd)
1316 for (
unsigned int n = 0u; n < tChannels; ++n)
1318 previousIntegral[n] += *source++;
1321 for (
unsigned int n = 0u; n < tChannels; ++n)
1323 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1329 for (
unsigned int n = 0u; n < tChannels; ++n)
1331 previousIntegral[n] = *(integral - tChannels + n);
1334 for (
unsigned int n = 0u; n < border; ++n)
1336 for (
unsigned int c = 0u; c < tChannels; ++c)
1338 *integral++ = previousIntegral[c];
1342 source += sourcePaddingElements;
1343 integral += integralPaddingElements;
1344 integralPreviousRow += (border * 2u + 1u) * tChannels + integralPaddingElements;
1349 integralPreviousRow -= (border + 1u) * tChannels;
1351 for (
unsigned int n = 0u; n < border; ++n)
1353 memcpy(integral, integralPreviousRow, integralWidth * tChannels *
sizeof(TIntegral));
1354 integral += integralStrideElements;
1358template <
typename T,
typename TIntegral,
unsigned int tChannels>
1359void IntegralImage::createBorderedImageSquared(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int border,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements)
1361 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
1362 static_assert(tChannels >= 1u,
"Invalid channel number!");
1364 ocean_assert(source !=
nullptr && integral !=
nullptr);
1365 ocean_assert(width >= 1u && height >= 1u);
1366 ocean_assert(border >= 1u);
1392 const unsigned int integralWidth = width + (border * 2u) + 1u;
1394 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
1395 const unsigned int integralStrideElements = integralWidth * tChannels + integralPaddingElements;
1399 if (integralPaddingElements == 0u)
1401 memset(integral, 0x00, integralWidth * tChannels *
sizeof(TIntegral) * (border + 1u));
1404 for (
unsigned int n = 0u; n < integralWidth; ++n)
1406 ocean_assert(integral[n] == TIntegral(0));
1410 integral += integralStrideElements * (border + 1u);
1414 for (
unsigned int y = 0u; y < border + 1u; ++y)
1416 memset(integral, 0x00, integralWidth * tChannels *
sizeof(TIntegral));
1419 for (
unsigned int n = 0u; n < integralWidth; ++n)
1421 ocean_assert(integral[n] == TIntegral(0));
1425 integral += integralStrideElements;
1432 memset(integral, 0x00, (border + 1u) * tChannels *
sizeof(TIntegral));
1433 integral += (border + 1u) * tChannels;
1435 const T *
const sourceFirstRowEnd = source + tChannels * width;
1436 const T *
const sourceEnd = source + sourceStrideElements * height;
1437 const TIntegral * integralPreviousRow = integral;
1439 TIntegral previousIntegral[tChannels] = {TIntegral(0)};
1441 while (source != sourceFirstRowEnd)
1443 for (
unsigned int n = 0u; n < tChannels; ++n)
1445 previousIntegral[n] += *source * *source;
1449 for (
unsigned int n = 0u; n < tChannels; ++n)
1451 *integral++ = previousIntegral[n];
1457 for (
unsigned int n = 0u; n < border; ++n)
1459 for (
unsigned int c = 0u; c < tChannels; ++c)
1461 *integral++ = previousIntegral[c];
1465 integral += integralPaddingElements;
1466 source += sourcePaddingElements;
1470 while (source != sourceEnd)
1472 ocean_assert(source < sourceEnd);
1475 memset(integral, 0x00, (border + 1u) * tChannels *
sizeof(TIntegral));
1476 integral += (border + 1u) * tChannels;
1478 const T *
const sourceRowEnd = source + tChannels * width;
1480 for (
unsigned int n = 0u; n < tChannels; ++n)
1482 previousIntegral[n] = TIntegral(0);
1485 while (source != sourceRowEnd)
1487 for (
unsigned int n = 0u; n < tChannels; ++n)
1489 previousIntegral[n] += *source * *source;
1493 for (
unsigned int n = 0u; n < tChannels; ++n)
1495 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1501 for (
unsigned int n = 0u; n < tChannels; ++n)
1503 previousIntegral[n] = *(integral - tChannels + n);
1506 for (
unsigned int n = 0u; n < border; ++n)
1508 for (
unsigned int c = 0u; c < tChannels; ++c)
1510 *integral++ = previousIntegral[c];
1514 source += sourcePaddingElements;
1515 integral += integralPaddingElements;
1516 integralPreviousRow += (border * 2u + 1u) * tChannels + integralPaddingElements;
1521 integralPreviousRow -= (border + 1u) * tChannels;
1523 for (
unsigned int n = 0u; n < border; ++n)
1525 memcpy(integral, integralPreviousRow, integralWidth * tChannels *
sizeof(TIntegral));
1526 integral += integralStrideElements;
1530template <
typename T,
typename TIntegral,
unsigned int tChannels>
1531void IntegralImage::createBorderedImageMirror(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int border,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements)
1533 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
1534 static_assert(tChannels >= 1u,
"Invalid channel number!");
1536 ocean_assert(source !=
nullptr && integral !=
nullptr);
1537 ocean_assert(width >= 1u && height >= 1u);
1538 ocean_assert(border >= 1u && border <= min(width, height));
1562 const unsigned int integralWidth = width + border * 2u + 1u;
1564 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
1565 const unsigned int integralStrideElements = integralWidth * tChannels + integralPaddingElements;
1568 memset(integral, 0, integralWidth *
sizeof(TIntegral) * tChannels);
1569 integral += integralStrideElements;
1571 const TIntegral* integralPreviousRow = integral + tChannels;
1572 TIntegral previousIntegral[tChannels] = {TIntegral(0)};
1574 const T* sourcePtr = source + sourceStrideElements * (border - 1u);
1578 for (
unsigned int n = 0u; n < tChannels; ++n)
1580 integral[n] = TIntegral(0);
1582 integral += tChannels;
1586 for (
unsigned int x = (border - 1u); x != (
unsigned int)(-1); --x)
1588 for (
unsigned int n = 0u; n < tChannels; ++n)
1590 previousIntegral[n] += TIntegral(sourcePtr[x * tChannels + n]);
1593 for (
unsigned int n = 0u; n < tChannels; ++n)
1595 *integral++ = previousIntegral[n];
1601 const T*
const sourceRowEnd0 = sourcePtr + width * tChannels;
1602 while (sourcePtr != sourceRowEnd0)
1604 for (
unsigned int n = 0u; n < tChannels; ++n)
1606 previousIntegral[n] += TIntegral(*sourcePtr++);
1609 for (
unsigned int n = 0u; n < tChannels; ++n)
1611 *integral++ = previousIntegral[n];
1617 for (
unsigned int x = 0u; x < border; ++x)
1619 for (
unsigned int n = 0u; n < tChannels; ++n)
1621 previousIntegral[n] += TIntegral(*(sourcePtr -
int((x + 1u) * tChannels) +
int(n)));
1624 for (
unsigned int n = 0u; n < tChannels; ++n)
1626 *integral++ = previousIntegral[n];
1630 integral += integralPaddingElements;
1634 int y = -int(border) + 1;
1636 while (y !=
int(height + border))
1640 ocean_assert(-y - 1 >= 0 && -y - 1 <
int(border));
1641 sourcePtr = source + int(sourceStrideElements) * (-y - 1);
1643 else if (y <
int(height))
1645 sourcePtr = source + int(sourceStrideElements) * y;
1649 sourcePtr = source + int(sourceStrideElements) * (2 * int(height) - y - 1);
1654 for (
unsigned int n = 0u; n < tChannels; ++n)
1656 previousIntegral[n] = TIntegral(0);
1659 for (
unsigned int n = 0u; n < tChannels; ++n)
1661 *integral++ = TIntegral(0);
1666 for (
unsigned int x = border - 1u; x != (
unsigned int)(-1); --x)
1668 for (
unsigned int n = 0u; n < tChannels; ++n)
1670 previousIntegral[n] += TIntegral(sourcePtr[x * tChannels + n]);
1673 for (
unsigned int n = 0u; n < tChannels; ++n)
1675 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1681 const T*
const followingSourceRowEnd0 = sourcePtr + width * tChannels;
1682 while (sourcePtr != followingSourceRowEnd0)
1684 ocean_assert(sourcePtr < followingSourceRowEnd0);
1686 for (
unsigned int n = 0u; n < tChannels; ++n)
1688 previousIntegral[n] += TIntegral(*sourcePtr++);
1691 for (
unsigned int n = 0u; n < tChannels; ++n)
1693 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1699 for (
unsigned int x = 0u; x < border; ++x)
1701 for (
unsigned int n = 0u; n < tChannels; ++n)
1703 previousIntegral[n] += TIntegral(*(sourcePtr -
int((x + 1u) * tChannels) +
int(n)));
1706 for (
unsigned int n = 0u; n < tChannels; ++n)
1708 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1712 integral += integralPaddingElements;
1713 integralPreviousRow += tChannels + integralPaddingElements;
1719template <
typename T,
typename TIntegral,
unsigned int tChannels>
1720void IntegralImage::createBorderedImageSquaredMirror(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int border,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements)
1722 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
1723 static_assert(tChannels >= 1u,
"Invalid channel number!");
1725 ocean_assert(source !=
nullptr && integral !=
nullptr);
1726 ocean_assert(width >= 1u && height >= 1u);
1727 ocean_assert(border >= 1u && border <= min(width, height));
1751 const unsigned int integralWidth = width + border * 2u + 1u;
1753 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
1754 const unsigned int integralStrideElements = integralWidth * tChannels + integralPaddingElements;
1757 memset(integral, 0, integralWidth *
sizeof(TIntegral) * tChannels);
1758 integral += integralStrideElements;
1760 const TIntegral* integralPreviousRow = integral + tChannels;
1761 TIntegral previousIntegral[tChannels] = {TIntegral(0)};
1763 const T* sourcePtr = source + sourceStrideElements * (border - 1u);
1767 for (
unsigned int n = 0u; n < tChannels; ++n)
1769 integral[n] = TIntegral(0);
1771 integral += tChannels;
1775 for (
unsigned int x = (border - 1u); x != (
unsigned int)(-1); --x)
1777 for (
unsigned int n = 0u; n < tChannels; ++n)
1779 previousIntegral[n] += TIntegral(sqr<T, TIntegral>(sourcePtr[x * tChannels + n]));
1782 for (
unsigned int n = 0u; n < tChannels; ++n)
1784 *integral++ = previousIntegral[n];
1790 const T*
const sourceRowEnd0 = sourcePtr + width * tChannels;
1791 while (sourcePtr != sourceRowEnd0)
1793 for (
unsigned int n = 0u; n < tChannels; ++n)
1795 previousIntegral[n] += TIntegral(sqr<T, TIntegral>(*sourcePtr++));
1798 for (
unsigned int n = 0u; n < tChannels; ++n)
1800 *integral++ = previousIntegral[n];
1806 for (
unsigned int x = 0u; x < border; ++x)
1808 for (
unsigned int n = 0u; n < tChannels; ++n)
1810 previousIntegral[n] += TIntegral(sqr<T, TIntegral>(*(sourcePtr -
int((x + 1u) * tChannels) +
int(n))));
1813 for (
unsigned int n = 0u; n < tChannels; ++n)
1815 *integral++ = previousIntegral[n];
1819 integral += integralPaddingElements;
1823 int y = -int(border) + 1;
1825 while (y !=
int(height + border))
1829 ocean_assert(-y - 1 >= 0 && -y - 1 <
int(border));
1830 sourcePtr = source + int(sourceStrideElements) * (-y - 1);
1832 else if (y <
int(height))
1834 sourcePtr = source + int(sourceStrideElements) * y;
1838 sourcePtr = source + int(sourceStrideElements) * (2 * int(height) - y - 1);
1843 for (
unsigned int n = 0u; n < tChannels; ++n)
1845 previousIntegral[n] = TIntegral(0);
1848 for (
unsigned int n = 0u; n < tChannels; ++n)
1850 *integral++ = TIntegral(0);
1855 for (
unsigned int x = border - 1u; x != (
unsigned int)(-1); --x)
1857 for (
unsigned int n = 0u; n < tChannels; ++n)
1859 previousIntegral[n] += TIntegral(sqr<T, TIntegral>(sourcePtr[x * tChannels + n]));
1862 for (
unsigned int n = 0u; n < tChannels; ++n)
1864 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1870 const T*
const followingSourceRowEnd0 = sourcePtr + width * tChannels;
1871 while (sourcePtr != followingSourceRowEnd0)
1873 ocean_assert(sourcePtr < followingSourceRowEnd0);
1875 for (
unsigned int n = 0u; n < tChannels; ++n)
1877 previousIntegral[n] += TIntegral(sqr<T, TIntegral>(*sourcePtr++));
1880 for (
unsigned int n = 0u; n < tChannels; ++n)
1882 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1888 for (
unsigned int x = 0u; x < border; ++x)
1890 for (
unsigned int n = 0u; n < tChannels; ++n)
1892 previousIntegral[n] += TIntegral(sqr<T, TIntegral>(*(sourcePtr -
int((x + 1u) * tChannels) +
int(n))));
1895 for (
unsigned int n = 0u; n < tChannels; ++n)
1897 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1901 integral += integralPaddingElements;
1902 integralPreviousRow += tChannels + integralPaddingElements;
1908template <
typename TIntegral>
1909inline TIntegral
IntegralImage::linedIntegralSum(
const TIntegral*
const linedIntegral,
const unsigned int linedIntegralStrideElements,
const unsigned int windowLeft,
const unsigned int windowTop,
const unsigned int windowWidth,
const unsigned int windowHeight)
1911 ocean_assert(linedIntegral !=
nullptr);
1912 ocean_assert(windowLeft + windowWidth < linedIntegralStrideElements);
1913 ocean_assert(windowWidth != 0u);
1914 ocean_assert(windowHeight != 0u);
1916 const unsigned int windowRight = windowLeft + windowWidth;
1917 const unsigned int windowBottom = windowTop + windowHeight;
1919 return linedIntegral[windowTop * linedIntegralStrideElements + windowLeft] - linedIntegral[windowTop * linedIntegralStrideElements + windowRight]
1920 - linedIntegral[windowBottom * linedIntegralStrideElements + windowLeft] + linedIntegral[windowBottom * linedIntegralStrideElements + windowRight];
1923template <
typename TIntegral,
typename TIntegralSquared,
typename TVariance,
bool tReturnMean>
1924inline TVariance
IntegralImage::linedIntegralVariance(
const TIntegral* linedIntegral,
const TIntegralSquared* linedIntegralSquared,
const unsigned int integralStrideElements,
const unsigned int integralStrideSquaredElements,
const unsigned int windowLeft,
const unsigned int windowTop,
const unsigned int windowWidth,
const unsigned int windowHeight, TVariance* mean)
1926 static_assert(std::is_floating_point<TVariance>::value,
"Invalid TVariance must be a floating point data type!");
1928 ocean_assert(linedIntegral !=
nullptr);
1929 ocean_assert(windowLeft + windowWidth < integralStrideElements);
1931 ocean_assert(linedIntegralSquared !=
nullptr);
1932 ocean_assert(windowLeft + windowWidth < integralStrideSquaredElements);
1934 ocean_assert(windowWidth != 0u);
1935 ocean_assert(windowHeight != 0u);
1937 if (windowWidth == 1u && windowHeight == 1u)
1939 return TVariance(0);
1942 const TIntegral sum = linedIntegralSum<TIntegral>(linedIntegral, integralStrideElements, windowLeft, windowTop, windowWidth, windowHeight);
1943 const TIntegralSquared squaredSum = linedIntegralSum<TIntegralSquared>(linedIntegralSquared, integralStrideSquaredElements, windowLeft, windowTop, windowWidth, windowHeight);
1945 const TVariance size = TVariance(windowWidth * windowHeight);
1947 if constexpr (tReturnMean)
1949 ocean_assert(mean !=
nullptr);
1950 *mean = TVariance(sum) / size;
1954 ocean_assert(mean ==
nullptr);
1957 const TVariance variance = (TVariance(squaredSum) - TVariance(TIntegralSquared(sum) * TIntegralSquared(sum)) / size) / size;
1959 return std::max(TVariance(0), variance);
1962template <
typename TIntegral,
typename TIntegralSquared,
typename TVariance,
bool tReturnMean>
1963inline TVariance
IntegralImage::linedIntegralVariance(
const TIntegral* linedIntegral,
const TIntegralSquared* linedIntegralSquared,
const unsigned int integralStrideElements,
const unsigned int integralStrideSquaredElements,
const unsigned int windowALeft,
const unsigned int windowATop,
const unsigned int windowAWidth,
const unsigned int windowAHeight,
const unsigned int windowBLeft,
const unsigned int windowBTop,
const unsigned int windowBWidth,
const unsigned int windowBHeight, TVariance* mean)
1965 static_assert(std::is_floating_point<TVariance>::value,
"Invalid TVariance must be a floating point data type!");
1967 ocean_assert(linedIntegral !=
nullptr);
1968 ocean_assert(windowALeft + windowAWidth < integralStrideElements);
1969 ocean_assert(windowBLeft + windowBWidth < integralStrideElements);
1971 ocean_assert(linedIntegralSquared !=
nullptr);
1972 ocean_assert(windowALeft + windowAWidth < integralStrideSquaredElements);
1973 ocean_assert(windowBLeft + windowBWidth < integralStrideSquaredElements);
1975 ocean_assert(windowAWidth != 0u && windowAHeight != 0u);
1976 ocean_assert(windowBWidth != 0u && windowBHeight != 0u);
1978 const TIntegral sumA = linedIntegralSum<TIntegral>(linedIntegral, integralStrideElements, windowALeft, windowATop, windowAWidth, windowAHeight);
1979 const TIntegral sumB = linedIntegralSum<TIntegral>(linedIntegral, integralStrideElements, windowBLeft, windowBTop, windowBWidth, windowBHeight);
1981 const TIntegralSquared squaredSumA = linedIntegralSum<TIntegralSquared>(linedIntegralSquared, integralStrideSquaredElements, windowALeft, windowATop, windowAWidth, windowAHeight);
1982 const TIntegralSquared squaredSumB = linedIntegralSum<TIntegralSquared>(linedIntegralSquared, integralStrideSquaredElements, windowBLeft, windowBTop, windowBWidth, windowBHeight);
1984 const unsigned int sizeA = windowAWidth * windowAHeight;
1985 const unsigned int sizeB = windowBWidth * windowBHeight;
1986 const TVariance size = TVariance(sizeA + sizeB);
1988 const TVariance squaredSum = TVariance(squaredSumA + squaredSumB);
1989 const TIntegralSquared sum = TIntegralSquared(sumA + sumB);
1991 if constexpr (tReturnMean)
1993 ocean_assert(mean !=
nullptr);
1994 *mean = TVariance(sum) / size;
1998 ocean_assert(mean ==
nullptr);
2001 const TVariance variance = (squaredSum - TVariance(sum * sum) / size) / size;
2003 return std::max(TVariance(0), variance);
2006template <
typename TIntegral,
typename TIntegralSquared,
typename TVariance,
bool tReturnMean>
2007inline TVariance
IntegralImage::linedIntegralVariance(
const TIntegral* linedIntegral,
const TIntegralSquared* linedIntegralSquared,
const unsigned int integralStrideElements,
const unsigned int integralStrideSquaredElements,
const unsigned int windowALeft,
const unsigned int windowATop,
const unsigned int windowAWidth,
const unsigned int windowAHeight,
const unsigned int windowBLeft,
const unsigned int windowBTop,
const unsigned int windowBWidth,
const unsigned int windowBHeight,
const unsigned int windowCLeft,
const unsigned int windowCTop,
const unsigned int windowCWidth,
const unsigned int windowCHeight, TVariance* mean)
2009 static_assert(std::is_floating_point<TVariance>::value,
"Invalid TVariance must be a floating point data type!");
2011 ocean_assert(linedIntegral !=
nullptr);
2012 ocean_assert(windowALeft + windowAWidth < integralStrideElements);
2013 ocean_assert(windowBLeft + windowBWidth < integralStrideElements);
2014 ocean_assert(windowCLeft + windowCWidth < integralStrideElements);
2016 ocean_assert(linedIntegralSquared !=
nullptr);
2017 ocean_assert(windowALeft + windowAWidth < integralStrideSquaredElements);
2018 ocean_assert(windowBLeft + windowBWidth < integralStrideSquaredElements);
2019 ocean_assert(windowCLeft + windowCWidth < integralStrideSquaredElements);
2021 ocean_assert(windowAWidth != 0u && windowAHeight != 0u);
2022 ocean_assert(windowBWidth != 0u && windowBHeight != 0u);
2023 ocean_assert(windowCWidth != 0u && windowCHeight != 0u);
2025 const TIntegral sumA = CV::IntegralImage::linedIntegralSum<TIntegral>(linedIntegral, integralStrideElements, windowALeft, windowATop, windowAWidth, windowAHeight);
2026 const TIntegral sumB = CV::IntegralImage::linedIntegralSum<TIntegral>(linedIntegral, integralStrideElements, windowBLeft, windowBTop, windowBWidth, windowBHeight);
2027 const TIntegral sumC = CV::IntegralImage::linedIntegralSum<TIntegral>(linedIntegral, integralStrideElements, windowCLeft, windowCTop, windowCWidth, windowCHeight);
2029 const TIntegralSquared squaredSumA = CV::IntegralImage::linedIntegralSum<TIntegralSquared>(linedIntegralSquared, integralStrideSquaredElements, windowALeft, windowATop, windowAWidth, windowAHeight);
2030 const TIntegralSquared squaredSumB = CV::IntegralImage::linedIntegralSum<TIntegralSquared>(linedIntegralSquared, integralStrideSquaredElements, windowBLeft, windowBTop, windowBWidth, windowBHeight);
2031 const TIntegralSquared squaredSumC = CV::IntegralImage::linedIntegralSum<TIntegralSquared>(linedIntegralSquared, integralStrideSquaredElements, windowCLeft, windowCTop, windowCWidth, windowCHeight);
2033 const unsigned int sizeA = windowAWidth * windowAHeight;
2034 const unsigned int sizeB = windowBWidth * windowBHeight;
2035 const unsigned int sizeC = windowCWidth * windowCHeight;
2036 const TVariance size = TVariance(sizeA + sizeB + sizeC);
2038 const TVariance squaredSum = TVariance(squaredSumA + squaredSumB + squaredSumC);
2039 const TIntegralSquared sum = TIntegralSquared(sumA + sumB + sumC);
2041 if constexpr (tReturnMean)
2043 ocean_assert(mean !=
nullptr);
2044 *mean = TVariance(sum) / size;
2048 ocean_assert(mean ==
nullptr);
2051 const TVariance variance = (squaredSum - TVariance(sum * sum) / size) / size;
2053 return std::max(TVariance(0), variance);
2056template <
typename T,
typename TSquared>
2059 return TSquared(value * value);
The following comfort class provides comfortable functions simplifying prototyping applications but a...
Definition IntegralImage.h:40
static Frame createBorderedImage(const Frame &frame, const unsigned int border)
Creates a bordered integral image from a given 1-plane image and adds an extra border to the resultin...
static Frame createBorderedImage(const Frame &frame, const unsigned int border)
Creates a bordered integral image from a given 1-plane image and adds an extra border to the resultin...
static Frame createLinedImage(const Frame &frame)
Creates an integral image from a given 1-plane image and adds an extra line (one column and one row) ...
static Frame createLinedImage(const Frame &frame)
Creates an integral image from a given 1-plane image and adds an extra line (one column and one row) ...
This class provides functions to create an integral image from a gray scale image.
Definition IntegralImage.h:31
static void createBorderedImageMirror(const T *source, TIntegral *integral, const unsigned int width, const unsigned int height, const unsigned int border, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
Creates a bordered integral image from a given 1-plane image and adds an extra border with mirrored i...
Definition IntegralImage.h:1531
static void createLinedImage1Channel8BitNEON(const uint8_t *source, uint32_t *integral, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
Creates an integral image from 8 bit images with 1 channel and adds an extra line with zeros to the l...
static void createLinedImage1Channel8BitSSE(const uint8_t *source, uint32_t *integral, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
Creates an integral image from 8 bit images with 1 channel and adds an extra line with zeros to the l...
static void createLinedImageSquared(const T *source, TIntegral *integral, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
Creates an integral image with squared pixel intensities from a given 1-plane image and adds an extra...
Definition IntegralImage.h:849
static TVariance linedIntegralVariance(const TIntegral *linedIntegral, const TIntegralSquared *linedIntegralSquared, const unsigned int integralStrideElements, const unsigned int integralStrideSquaredElements, const unsigned int windowLeft, const unsigned int windowTop, const unsigned int windowWidth, const unsigned int windowHeight, TVariance *mean=nullptr)
Determines the variance of elements within a window from two integral images.
Definition IntegralImage.h:1924
static void createImage(const T *source, TIntegral *integral, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
Creates an integral image from a given 1-plane image.
Definition IntegralImage.h:652
static void createBorderedImageSquaredMirror(const T *source, TIntegral *integral, const unsigned int width, const unsigned int height, const unsigned int border, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
Creates a bordered squared integral image from a given 1-plane image and adds an extra border with mi...
Definition IntegralImage.h:1720
static TSquared sqr(const T &value)
Returns the square value of the given parameter.
Definition IntegralImage.h:2057
static void createBorderedImage(const T *source, TIntegral *integral, const unsigned int width, const unsigned int height, const unsigned int border, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
Creates a bordered integral image from a given 1-plane image and adds an extra border to the resultin...
Definition IntegralImage.h:1188
static void createLinedImageAndSquared(const T *source, TIntegralAndSquared *integralAndSquared, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int integralAndSquaredPaddingElements)
Creates an integral image and squared integral image from a given 1-plane image and adds an extra lin...
Definition IntegralImage.h:945
static OCEAN_FORCE_INLINE TIntegral linedIntegralSum(const TIntegral *const linedIntegral, const unsigned int linedIntegralStrideElements, const unsigned int windowLeft, const unsigned int windowTop, const unsigned int windowWidth, const unsigned int windowHeight)
Determines the sum of elements within a window from an integral image.
static void createBorderedImageSquared(const T *source, TIntegral *integral, const unsigned int width, const unsigned int height, const unsigned int border, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
Creates a bordered squared integral image from a given 1-plane image and adds an extra border to the ...
Definition IntegralImage.h:1359
static void createLinedImage(const T *source, TIntegral *integral, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int integralPaddingElements)
Creates an integral image from a given 1-plane image and adds an extra line (one column and one row) ...
Definition IntegralImage.h:723
This class implements Ocean's image class.
Definition Frame.h:1879
This class provides basic numeric functionalities.
Definition Numeric.h:57
static constexpr T sqr(const T value)
Returns the square of a given value.
Definition Numeric.h:1499
unsigned int sqr(const char value)
Returns the square value of a given value.
Definition base/Utilities.h:1099
The namespace covering the entire Ocean framework.
Definition Accessor.h:15