8 #ifndef META_OCEAN_CV_INTEGRAL_IMAGE_H
9 #define META_OCEAN_CV_INTEGRAL_IMAGE_H
18 #include <type_traits>
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_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10
606 #if defined(__aarch64__)
618 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);
631 template <
typename T,
typename TSquared>
632 static inline TSquared
sqr(
const T& value);
635 template <
typename T,
typename TIntegral,
unsigned int tChannels>
636 void IntegralImage::createImage(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements)
638 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!");
639 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
640 static_assert(tChannels >= 1u,
"Invalid channel number!");
642 ocean_assert(source !=
nullptr && integral !=
nullptr);
643 ocean_assert(width >= 1u && height >= 1u);
647 const T*
const sourceFirstRowEnd = source + width * tChannels;
648 const T*
const sourceEnd = source + (width * tChannels + sourcePaddingElements) * height;
649 const TIntegral* integralPreviousRow = integral;
651 TIntegral previousIntegral[tChannels];
652 for (
unsigned int n = 0u; n < tChannels; ++n)
654 previousIntegral[n] = TIntegral(0);
659 while (source != sourceFirstRowEnd)
661 for (
unsigned int n = 0u; n < tChannels; ++n)
663 previousIntegral[n] += TIntegral(*source++);
666 for (
unsigned int n = 0u; n < tChannels; ++n)
668 *integral++ = previousIntegral[n];
672 source += sourcePaddingElements;
673 integral += integralPaddingElements;
678 while (source != sourceEnd)
680 const T*
const sourceRowEnd = source + width * tChannels;
682 for (
unsigned int n = 0u; n < tChannels; ++n)
684 previousIntegral[n] = TIntegral(0);
687 while (source != sourceRowEnd)
689 for (
unsigned int n = 0u; n < tChannels; ++n)
691 previousIntegral[n] += TIntegral(*source++);
694 for (
unsigned int n = 0u; n < tChannels; ++n)
696 *integral++ = previousIntegral[n] + *integralPreviousRow++;
700 source += sourcePaddingElements;
701 integral += integralPaddingElements;
702 integralPreviousRow += integralPaddingElements;
706 template <
typename T,
typename TIntegral,
unsigned int tChannels>
707 void IntegralImage::createLinedImage(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements)
709 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!");
710 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
711 static_assert(tChannels >= 1u,
"Invalid channel number!");
713 ocean_assert(source !=
nullptr && integral !=
nullptr);
714 ocean_assert(width >= 1u && height >= 1u);
718 #if defined(OCEAN_HARDWARE_NEON_VERSION) && OCEAN_HARDWARE_NEON_VERSION >= 10 && defined(__aarch64__)
720 if (std::is_same<T, uint8_t>::value && std::is_same<TIntegral, uint32_t>::value && tChannels == 1u && width >= 8u)
740 memset(integral, 0x00, (width + 1u) * tChannels *
sizeof(TIntegral));
743 for (
unsigned int n = 0u; n < width + 1u; ++n)
745 ocean_assert(integral[n] == TIntegral(0));
751 const T*
const sourceFirstRowEnd = source + width * tChannels;
752 const T*
const sourceEnd = source + (width * tChannels + sourcePaddingElements) * height;
754 integral += (width + 1u) * tChannels + integralPaddingElements;
755 const TIntegral* integralPreviousRow = integral;
757 TIntegral previousIntegral[tChannels] = {TIntegral(0)};
760 for (
unsigned int n = 0u; n < tChannels; ++n)
762 *integral++ = TIntegral(0);
767 while (source != sourceFirstRowEnd)
769 for (
unsigned int n = 0u; n < tChannels; ++n)
771 previousIntegral[n] += *source++;
774 for (
unsigned int n = 0u; n < tChannels; ++n)
776 *integral++ = previousIntegral[n];
780 source += sourcePaddingElements;
781 integral += integralPaddingElements;
786 while (source != sourceEnd)
788 const T*
const sourceRowEnd = source + width * tChannels;
790 for (
unsigned int n = 0u; n < tChannels; ++n)
792 previousIntegral[n] = TIntegral(0);
796 for (
unsigned int n = 0u; n < tChannels; ++n)
798 *integral++ = TIntegral(0);
801 integralPreviousRow += tChannels;
803 while (source != sourceRowEnd)
805 for (
unsigned int n = 0u; n < tChannels; ++n)
807 previousIntegral[n] += *source++;
810 for (
unsigned int n = 0u; n < tChannels; ++n)
812 *integral++ = previousIntegral[n] + *integralPreviousRow++;
816 source += sourcePaddingElements;
817 integral += integralPaddingElements;
818 integralPreviousRow += integralPaddingElements;
822 template <
typename T,
typename TIntegral,
unsigned int tChannels>
823 void IntegralImage::createLinedImageSquared(
const T* source, TIntegral* integral,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralPaddingElements)
825 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
826 static_assert(tChannels >= 1u,
"Invalid channel number!");
828 ocean_assert(source !=
nullptr && integral !=
nullptr);
829 ocean_assert(width >= 1u && height >= 1u);
834 memset(integral, 0x00, (width + 1u) * tChannels *
sizeof(TIntegral));
837 for (
unsigned int n = 0u; n < width + 1u; ++n)
839 ocean_assert(integral[n] == TIntegral(0));
845 const T*
const sourceFirstRowEnd = source + width * tChannels;
846 const T*
const sourceEnd = source + (width * tChannels + sourcePaddingElements) * height;
848 integral += (width + 1u) * tChannels + integralPaddingElements;
849 const TIntegral* integralPreviousRow = integral;
851 TIntegral previousIntegral[tChannels] = {TIntegral(0)};
854 for (
unsigned int n = 0u; n < tChannels; ++n)
856 *integral++ = TIntegral(0);
861 while (source != sourceFirstRowEnd)
863 for (
unsigned int n = 0u; n < tChannels; ++n)
865 previousIntegral[n] += *source * *source;
869 for (
unsigned int n = 0u; n < tChannels; ++n)
871 *integral++ = previousIntegral[n];
875 source += sourcePaddingElements;
876 integral += integralPaddingElements;
881 while (source != sourceEnd)
883 const T*
const sourceRowEnd = source + width * tChannels;
885 for (
unsigned int n = 0u; n < tChannels; ++n)
887 previousIntegral[n] = TIntegral(0);
891 for (
unsigned int n = 0u; n < tChannels; ++n)
893 *integral++ = TIntegral(0);
896 integralPreviousRow += tChannels;
898 while (source != sourceRowEnd)
900 for (
unsigned int n = 0u; n < tChannels; ++n)
902 previousIntegral[n] += *source * *source;
906 for (
unsigned int n = 0u; n < tChannels; ++n)
908 *integral++ = previousIntegral[n] + *integralPreviousRow++;
912 source += sourcePaddingElements;
913 integral += integralPaddingElements;
914 integralPreviousRow += integralPaddingElements;
918 template <
typename T,
typename TIntegralAndSquared,
unsigned int tChannels>
919 void IntegralImage::createLinedImageAndSquared(
const T* source, TIntegralAndSquared* integralAndSquared,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int integralAndSquaredPaddingElements)
921 static_assert(
sizeof(T) <=
sizeof(TIntegralAndSquared),
"Invalid integral elements!");
922 static_assert(tChannels >= 1u,
"Invalid channel number!");
924 ocean_assert(source !=
nullptr && integralAndSquared !=
nullptr);
925 ocean_assert(width >= 1u && height >= 1u);
930 memset(integralAndSquared, 0x00, (width + 1u) * tChannels *
sizeof(TIntegralAndSquared) * 2u);
933 for (
unsigned int n = 0u; n < (width + 1u) * 2u; ++n)
935 ocean_assert(integralAndSquared[n] == TIntegralAndSquared(0));
941 const T*
const sourceFirstRowEnd = source + width * tChannels;
942 const T*
const sourceEnd = source + (width * tChannels + sourcePaddingElements) * height;
944 integralAndSquared += (width + 1u) * tChannels * 2u + integralAndSquaredPaddingElements;
945 const TIntegralAndSquared* integralAndSquaredPreviousRow = integralAndSquared;
947 TIntegralAndSquared previousIntegral[tChannels] = {TIntegralAndSquared(0)};
948 TIntegralAndSquared previousIntegralSquared[tChannels] = {TIntegralAndSquared(0)};
951 for (
unsigned int n = 0u; n < tChannels * 2u; ++n)
953 *integralAndSquared++ = TIntegralAndSquared(0);
958 while (source != sourceFirstRowEnd)
960 for (
unsigned int n = 0u; n < tChannels; ++n)
962 previousIntegral[n] += *source;
963 previousIntegralSquared[n] += *source * *source;
967 for (
unsigned int n = 0u; n < tChannels; ++n)
969 *integralAndSquared++ = previousIntegral[n];
972 for (
unsigned int n = 0u; n < tChannels; ++n)
974 *integralAndSquared++ = previousIntegralSquared[n];
978 source += sourcePaddingElements;
979 integralAndSquared += integralAndSquaredPaddingElements;
983 while (source != sourceEnd)
985 const T*
const sourceRowEnd = source + width * tChannels;
987 for (
unsigned int n = 0u; n < tChannels; ++n)
989 previousIntegral[n] = TIntegralAndSquared(0);
991 for (
unsigned int n = 0u; n < tChannels; ++n)
993 previousIntegralSquared[n] = TIntegralAndSquared(0);
997 for (
unsigned int n = 0u; n < tChannels * 2u; ++n)
999 *integralAndSquared++ = TIntegralAndSquared(0);
1002 integralAndSquaredPreviousRow += tChannels * 2u;
1004 while (source != sourceRowEnd)
1006 for (
unsigned int n = 0u; n < tChannels; ++n)
1008 previousIntegral[n] += *source;
1009 previousIntegralSquared[n] += *source * *source;
1013 for (
unsigned int n = 0u; n < tChannels; ++n)
1015 *integralAndSquared++ = previousIntegral[n] + *integralAndSquaredPreviousRow++;
1017 for (
unsigned int n = 0u; n < tChannels; ++n)
1019 *integralAndSquared++ = previousIntegralSquared[n] + *integralAndSquaredPreviousRow++;
1023 source += sourcePaddingElements;
1024 integralAndSquared += integralAndSquaredPaddingElements;
1025 integralAndSquaredPreviousRow += integralAndSquaredPaddingElements;
1029 template <
typename T,
typename TIntegral,
typename TIntegralSquared,
unsigned int tChannels>
1030 void 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)
1032 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
1033 static_assert(
sizeof(TIntegral) <=
sizeof(TIntegralSquared),
"Invalid integral elements!");
1034 static_assert(tChannels >= 1u,
"Invalid channel number!");
1036 ocean_assert(source !=
nullptr && integral !=
nullptr && integralSquared !=
nullptr);
1037 ocean_assert(width >= 1u && height >= 1u);
1042 memset(integral, 0x00, (width + 1u) * tChannels *
sizeof(TIntegral));
1043 memset(integralSquared, 0x00, (width + 1u) * tChannels *
sizeof(TIntegralSquared));
1046 for (
unsigned int n = 0u; n < width + 1u; ++n)
1048 ocean_assert(integral[n] == TIntegral(0));
1049 ocean_assert(integralSquared[n] == TIntegralSquared(0));
1055 const T*
const sourceFirstRowEnd = source + width * tChannels;
1056 const T*
const sourceEnd = source + (width * tChannels + sourcePaddingElements) * height;
1058 integral += (width + 1u) * tChannels + integralPaddingElements;
1059 integralSquared += (width + 1u) * tChannels + integralSquaredPaddingElements;
1060 const TIntegral* integralPreviousRow = integral;
1061 const TIntegralSquared* integralSquaredPreviousRow = integralSquared;
1063 TIntegral previousIntegral[tChannels] = {TIntegral(0)};
1064 TIntegralSquared previousIntegralSquared[tChannels] = {TIntegralSquared(0)};
1067 for (
unsigned int n = 0u; n < tChannels; ++n)
1069 *integral++ = TIntegral(0);
1072 for (
unsigned int n = 0u; n < tChannels; ++n)
1074 *integralSquared++ = TIntegralSquared(0);
1079 while (source != sourceFirstRowEnd)
1081 for (
unsigned int n = 0u; n < tChannels; ++n)
1083 previousIntegral[n] += *source;
1084 previousIntegralSquared[n] += *source * *source;
1088 for (
unsigned int n = 0u; n < tChannels; ++n)
1090 *integral++ = previousIntegral[n];
1093 for (
unsigned int n = 0u; n < tChannels; ++n)
1095 *integralSquared++ = previousIntegralSquared[n];
1099 source += sourcePaddingElements;
1100 integral += integralPaddingElements;
1101 integralSquared += integralSquaredPaddingElements;
1105 while (source != sourceEnd)
1107 const T*
const sourceRowEnd = source + width * tChannels;
1109 for (
unsigned int n = 0u; n < tChannels; ++n)
1111 previousIntegral[n] = TIntegral(0);
1113 for (
unsigned int n = 0u; n < tChannels; ++n)
1115 previousIntegralSquared[n] = TIntegralSquared(0);
1119 for (
unsigned int n = 0u; n < tChannels; ++n)
1121 *integral++ = TIntegral(0);
1124 for (
unsigned int n = 0u; n < tChannels; ++n)
1126 *integralSquared++ = TIntegralSquared(0);
1129 integralPreviousRow += tChannels;
1130 integralSquaredPreviousRow += tChannels;
1132 while (source != sourceRowEnd)
1134 for (
unsigned int n = 0u; n < tChannels; ++n)
1136 previousIntegral[n] += *source;
1137 previousIntegralSquared[n] += *source * *source;
1141 for (
unsigned int n = 0u; n < tChannels; ++n)
1143 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1145 for (
unsigned int n = 0u; n < tChannels; ++n)
1147 *integralSquared++ = previousIntegralSquared[n] + *integralSquaredPreviousRow++;
1151 source += sourcePaddingElements;
1153 integral += integralPaddingElements;
1154 integralSquared += integralSquaredPaddingElements;
1156 integralPreviousRow += integralPaddingElements;
1157 integralSquaredPreviousRow += integralSquaredPaddingElements;
1161 template <
typename T,
typename TIntegral,
unsigned int tChannels>
1162 void 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)
1164 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!");
1165 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
1166 static_assert(tChannels >= 1u,
"Invalid channel number!");
1168 ocean_assert(source !=
nullptr && integral !=
nullptr);
1169 ocean_assert(width >= 1u && height >= 1u);
1170 ocean_assert(border >= 1u);
1196 const unsigned int integralWidth = width + (border * 2u) + 1u;
1198 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
1199 const unsigned int integralStrideElements = integralWidth * tChannels + integralPaddingElements;
1203 if (integralPaddingElements == 0u)
1205 memset(integral, 0x00, integralWidth * tChannels *
sizeof(TIntegral) * (border + 1u));
1208 for (
unsigned int n = 0u; n < integralWidth; ++n)
1210 ocean_assert(integral[n] == TIntegral(0));
1214 integral += integralStrideElements * (border + 1u);
1218 for (
unsigned int y = 0u; y < border + 1u; ++y)
1220 memset(integral, 0x00, integralWidth * tChannels *
sizeof(TIntegral));
1223 for (
unsigned int n = 0u; n < integralWidth; ++n)
1225 ocean_assert(integral[n] == TIntegral(0));
1229 integral += integralStrideElements;
1236 memset(integral, 0x00, (border + 1u) * tChannels *
sizeof(TIntegral));
1237 integral += (border + 1u) * tChannels;
1239 const T*
const sourceFirstRowEnd = source + tChannels * width;
1240 const T*
const sourceEnd = source + sourceStrideElements * height;
1241 const TIntegral* integralPreviousRow = integral;
1243 TIntegral previousIntegral[tChannels] = {0u};
1245 while (source != sourceFirstRowEnd)
1247 for (
unsigned int n = 0u; n < tChannels; ++n)
1249 previousIntegral[n] += *source++;
1252 for (
unsigned int n = 0u; n < tChannels; ++n)
1254 *integral++ = previousIntegral[n];
1260 for (
unsigned int n = 0u; n < border; ++n)
1262 for (
unsigned int c = 0u; c < tChannels; ++c)
1264 *integral++ = previousIntegral[c];
1268 integral += integralPaddingElements;
1269 source += sourcePaddingElements;
1273 while (source != sourceEnd)
1275 ocean_assert(source < sourceEnd);
1278 memset(integral, 0x00, (border + 1u) * tChannels *
sizeof(TIntegral));
1279 integral += (border + 1u) * tChannels;
1281 const T*
const sourceRowEnd = source + tChannels * width;
1283 for (
unsigned int n = 0u; n < tChannels; ++n)
1285 previousIntegral[n] = TIntegral(0);
1288 while (source != sourceRowEnd)
1290 for (
unsigned int n = 0u; n < tChannels; ++n)
1292 previousIntegral[n] += *source++;
1295 for (
unsigned int n = 0u; n < tChannels; ++n)
1297 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1303 for (
unsigned int n = 0u; n < tChannels; ++n)
1305 previousIntegral[n] = *(integral - tChannels + n);
1308 for (
unsigned int n = 0u; n < border; ++n)
1310 for (
unsigned int c = 0u; c < tChannels; ++c)
1312 *integral++ = previousIntegral[c];
1316 source += sourcePaddingElements;
1317 integral += integralPaddingElements;
1318 integralPreviousRow += (border * 2u + 1u) * tChannels + integralPaddingElements;
1323 integralPreviousRow -= (border + 1u) * tChannels;
1325 for (
unsigned int n = 0u; n < border; ++n)
1327 memcpy(integral, integralPreviousRow, integralWidth * tChannels *
sizeof(TIntegral));
1328 integral += integralStrideElements;
1332 template <
typename T,
typename TIntegral,
unsigned int tChannels>
1333 void 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)
1335 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
1336 static_assert(tChannels >= 1u,
"Invalid channel number!");
1338 ocean_assert(source !=
nullptr && integral !=
nullptr);
1339 ocean_assert(width >= 1u && height >= 1u);
1340 ocean_assert(border >= 1u);
1366 const unsigned int integralWidth = width + (border * 2u) + 1u;
1368 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
1369 const unsigned int integralStrideElements = integralWidth * tChannels + integralPaddingElements;
1373 if (integralPaddingElements == 0u)
1375 memset(integral, 0x00, integralWidth * tChannels *
sizeof(TIntegral) * (border + 1u));
1378 for (
unsigned int n = 0u; n < integralWidth; ++n)
1380 ocean_assert(integral[n] == TIntegral(0));
1384 integral += integralStrideElements * (border + 1u);
1388 for (
unsigned int y = 0u; y < border + 1u; ++y)
1390 memset(integral, 0x00, integralWidth * tChannels *
sizeof(TIntegral));
1393 for (
unsigned int n = 0u; n < integralWidth; ++n)
1395 ocean_assert(integral[n] == TIntegral(0));
1399 integral += integralStrideElements;
1406 memset(integral, 0x00, (border + 1u) * tChannels *
sizeof(TIntegral));
1407 integral += (border + 1u) * tChannels;
1409 const T *
const sourceFirstRowEnd = source + tChannels * width;
1410 const T *
const sourceEnd = source + sourceStrideElements * height;
1411 const TIntegral * integralPreviousRow = integral;
1413 TIntegral previousIntegral[tChannels] = {TIntegral(0)};
1415 while (source != sourceFirstRowEnd)
1417 for (
unsigned int n = 0u; n < tChannels; ++n)
1419 previousIntegral[n] += *source * *source;
1423 for (
unsigned int n = 0u; n < tChannels; ++n)
1425 *integral++ = previousIntegral[n];
1431 for (
unsigned int n = 0u; n < border; ++n)
1433 for (
unsigned int c = 0u; c < tChannels; ++c)
1435 *integral++ = previousIntegral[c];
1439 integral += integralPaddingElements;
1440 source += sourcePaddingElements;
1444 while (source != sourceEnd)
1446 ocean_assert(source < sourceEnd);
1449 memset(integral, 0x00, (border + 1u) * tChannels *
sizeof(TIntegral));
1450 integral += (border + 1u) * tChannels;
1452 const T *
const sourceRowEnd = source + tChannels * width;
1454 for (
unsigned int n = 0u; n < tChannels; ++n)
1456 previousIntegral[n] = TIntegral(0);
1459 while (source != sourceRowEnd)
1461 for (
unsigned int n = 0u; n < tChannels; ++n)
1463 previousIntegral[n] += *source * *source;
1467 for (
unsigned int n = 0u; n < tChannels; ++n)
1469 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1475 for (
unsigned int n = 0u; n < tChannels; ++n)
1477 previousIntegral[n] = *(integral - tChannels + n);
1480 for (
unsigned int n = 0u; n < border; ++n)
1482 for (
unsigned int c = 0u; c < tChannels; ++c)
1484 *integral++ = previousIntegral[c];
1488 source += sourcePaddingElements;
1489 integral += integralPaddingElements;
1490 integralPreviousRow += (border * 2u + 1u) * tChannels + integralPaddingElements;
1495 integralPreviousRow -= (border + 1u) * tChannels;
1497 for (
unsigned int n = 0u; n < border; ++n)
1499 memcpy(integral, integralPreviousRow, integralWidth * tChannels *
sizeof(TIntegral));
1500 integral += integralStrideElements;
1504 template <
typename T,
typename TIntegral,
unsigned int tChannels>
1505 void 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)
1507 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
1508 static_assert(tChannels >= 1u,
"Invalid channel number!");
1510 ocean_assert(source !=
nullptr && integral !=
nullptr);
1511 ocean_assert(width >= 1u && height >= 1u);
1512 ocean_assert(border >= 1u && border <= min(width, height));
1536 const unsigned int integralWidth = width + border * 2u + 1u;
1538 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
1539 const unsigned int integralStrideElements = integralWidth * tChannels + integralPaddingElements;
1542 memset(integral, 0, integralWidth *
sizeof(TIntegral) * tChannels);
1543 integral += integralStrideElements;
1545 const TIntegral* integralPreviousRow = integral + tChannels;
1546 TIntegral previousIntegral[tChannels] = {TIntegral(0)};
1548 const T* sourcePtr = source + sourceStrideElements * (border - 1u);
1552 for (
unsigned int n = 0u; n < tChannels; ++n)
1554 integral[n] = TIntegral(0);
1556 integral += tChannels;
1560 for (
unsigned int x = (border - 1u); x != (
unsigned int)(-1); --x)
1562 for (
unsigned int n = 0u; n < tChannels; ++n)
1564 previousIntegral[n] += TIntegral(sourcePtr[x * tChannels + n]);
1567 for (
unsigned int n = 0u; n < tChannels; ++n)
1569 *integral++ = previousIntegral[n];
1575 const T*
const sourceRowEnd0 = sourcePtr + width * tChannels;
1576 while (sourcePtr != sourceRowEnd0)
1578 for (
unsigned int n = 0u; n < tChannels; ++n)
1580 previousIntegral[n] += TIntegral(*sourcePtr++);
1583 for (
unsigned int n = 0u; n < tChannels; ++n)
1585 *integral++ = previousIntegral[n];
1591 for (
unsigned int x = 0u; x < border; ++x)
1593 for (
unsigned int n = 0u; n < tChannels; ++n)
1595 previousIntegral[n] += TIntegral(*(sourcePtr -
int((x + 1u) * tChannels) +
int(n)));
1598 for (
unsigned int n = 0u; n < tChannels; ++n)
1600 *integral++ = previousIntegral[n];
1604 integral += integralPaddingElements;
1608 int y = -int(border) + 1;
1610 while (y !=
int(height + border))
1614 ocean_assert(-y - 1 >= 0 && -y - 1 <
int(border));
1615 sourcePtr = source + int(sourceStrideElements) * (-y - 1);
1617 else if (y <
int(height))
1619 sourcePtr = source + int(sourceStrideElements) * y;
1623 sourcePtr = source + int(sourceStrideElements) * (2 * int(height) - y - 1);
1628 for (
unsigned int n = 0u; n < tChannels; ++n)
1630 previousIntegral[n] = TIntegral(0);
1633 for (
unsigned int n = 0u; n < tChannels; ++n)
1635 *integral++ = TIntegral(0);
1640 for (
unsigned int x = border - 1u; x != (
unsigned int)(-1); --x)
1642 for (
unsigned int n = 0u; n < tChannels; ++n)
1644 previousIntegral[n] += TIntegral(sourcePtr[x * tChannels + n]);
1647 for (
unsigned int n = 0u; n < tChannels; ++n)
1649 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1655 const T*
const followingSourceRowEnd0 = sourcePtr + width * tChannels;
1656 while (sourcePtr != followingSourceRowEnd0)
1658 ocean_assert(sourcePtr < followingSourceRowEnd0);
1660 for (
unsigned int n = 0u; n < tChannels; ++n)
1662 previousIntegral[n] += TIntegral(*sourcePtr++);
1665 for (
unsigned int n = 0u; n < tChannels; ++n)
1667 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1673 for (
unsigned int x = 0u; x < border; ++x)
1675 for (
unsigned int n = 0u; n < tChannels; ++n)
1677 previousIntegral[n] += TIntegral(*(sourcePtr -
int((x + 1u) * tChannels) +
int(n)));
1680 for (
unsigned int n = 0u; n < tChannels; ++n)
1682 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1686 integral += integralPaddingElements;
1687 integralPreviousRow += tChannels + integralPaddingElements;
1693 template <
typename T,
typename TIntegral,
unsigned int tChannels>
1694 void 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)
1696 static_assert(
sizeof(T) <=
sizeof(TIntegral),
"Invalid integral elements!");
1697 static_assert(tChannels >= 1u,
"Invalid channel number!");
1699 ocean_assert(source !=
nullptr && integral !=
nullptr);
1700 ocean_assert(width >= 1u && height >= 1u);
1701 ocean_assert(border >= 1u && border <= min(width, height));
1725 const unsigned int integralWidth = width + border * 2u + 1u;
1727 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
1728 const unsigned int integralStrideElements = integralWidth * tChannels + integralPaddingElements;
1731 memset(integral, 0, integralWidth *
sizeof(TIntegral) * tChannels);
1732 integral += integralStrideElements;
1734 const TIntegral* integralPreviousRow = integral + tChannels;
1735 TIntegral previousIntegral[tChannels] = {TIntegral(0)};
1737 const T* sourcePtr = source + sourceStrideElements * (border - 1u);
1741 for (
unsigned int n = 0u; n < tChannels; ++n)
1743 integral[n] = TIntegral(0);
1745 integral += tChannels;
1749 for (
unsigned int x = (border - 1u); x != (
unsigned int)(-1); --x)
1751 for (
unsigned int n = 0u; n < tChannels; ++n)
1753 previousIntegral[n] += TIntegral(sqr<T, TIntegral>(sourcePtr[x * tChannels + n]));
1756 for (
unsigned int n = 0u; n < tChannels; ++n)
1758 *integral++ = previousIntegral[n];
1764 const T*
const sourceRowEnd0 = sourcePtr + width * tChannels;
1765 while (sourcePtr != sourceRowEnd0)
1767 for (
unsigned int n = 0u; n < tChannels; ++n)
1769 previousIntegral[n] += TIntegral(sqr<T, TIntegral>(*sourcePtr++));
1772 for (
unsigned int n = 0u; n < tChannels; ++n)
1774 *integral++ = previousIntegral[n];
1780 for (
unsigned int x = 0u; x < border; ++x)
1782 for (
unsigned int n = 0u; n < tChannels; ++n)
1784 previousIntegral[n] += TIntegral(sqr<T, TIntegral>(*(sourcePtr -
int((x + 1u) * tChannels) +
int(n))));
1787 for (
unsigned int n = 0u; n < tChannels; ++n)
1789 *integral++ = previousIntegral[n];
1793 integral += integralPaddingElements;
1797 int y = -int(border) + 1;
1799 while (y !=
int(height + border))
1803 ocean_assert(-y - 1 >= 0 && -y - 1 <
int(border));
1804 sourcePtr = source + int(sourceStrideElements) * (-y - 1);
1806 else if (y <
int(height))
1808 sourcePtr = source + int(sourceStrideElements) * y;
1812 sourcePtr = source + int(sourceStrideElements) * (2 * int(height) - y - 1);
1817 for (
unsigned int n = 0u; n < tChannels; ++n)
1819 previousIntegral[n] = TIntegral(0);
1822 for (
unsigned int n = 0u; n < tChannels; ++n)
1824 *integral++ = TIntegral(0);
1829 for (
unsigned int x = border - 1u; x != (
unsigned int)(-1); --x)
1831 for (
unsigned int n = 0u; n < tChannels; ++n)
1833 previousIntegral[n] += TIntegral(sqr<T, TIntegral>(sourcePtr[x * tChannels + n]));
1836 for (
unsigned int n = 0u; n < tChannels; ++n)
1838 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1844 const T*
const followingSourceRowEnd0 = sourcePtr + width * tChannels;
1845 while (sourcePtr != followingSourceRowEnd0)
1847 ocean_assert(sourcePtr < followingSourceRowEnd0);
1849 for (
unsigned int n = 0u; n < tChannels; ++n)
1851 previousIntegral[n] += TIntegral(sqr<T, TIntegral>(*sourcePtr++));
1854 for (
unsigned int n = 0u; n < tChannels; ++n)
1856 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1862 for (
unsigned int x = 0u; x < border; ++x)
1864 for (
unsigned int n = 0u; n < tChannels; ++n)
1866 previousIntegral[n] += TIntegral(sqr<T, TIntegral>(*(sourcePtr -
int((x + 1u) * tChannels) +
int(n))));
1869 for (
unsigned int n = 0u; n < tChannels; ++n)
1871 *integral++ = previousIntegral[n] + *integralPreviousRow++;
1875 integral += integralPaddingElements;
1876 integralPreviousRow += tChannels + integralPaddingElements;
1882 template <
typename TIntegral>
1883 inline 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)
1885 ocean_assert(linedIntegral !=
nullptr);
1886 ocean_assert(windowLeft + windowWidth < linedIntegralStrideElements);
1887 ocean_assert(windowWidth != 0u);
1888 ocean_assert(windowHeight != 0u);
1890 const unsigned int windowRight = windowLeft + windowWidth;
1891 const unsigned int windowBottom = windowTop + windowHeight;
1893 return linedIntegral[windowTop * linedIntegralStrideElements + windowLeft] - linedIntegral[windowTop * linedIntegralStrideElements + windowRight]
1894 - linedIntegral[windowBottom * linedIntegralStrideElements + windowLeft] + linedIntegral[windowBottom * linedIntegralStrideElements + windowRight];
1897 template <
typename TIntegral,
typename TIntegralSquared,
typename TVariance,
bool tReturnMean>
1898 inline 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)
1900 static_assert(std::is_floating_point<TVariance>::value,
"Invalid TVariance must be a floating point data type!");
1902 ocean_assert(linedIntegral !=
nullptr);
1903 ocean_assert(windowLeft + windowWidth < integralStrideElements);
1905 ocean_assert(linedIntegralSquared !=
nullptr);
1906 ocean_assert(windowLeft + windowWidth < integralStrideSquaredElements);
1908 ocean_assert(windowWidth != 0u);
1909 ocean_assert(windowHeight != 0u);
1911 if (windowWidth == 1u && windowHeight == 1u)
1913 return TVariance(0);
1916 const TIntegral sum = linedIntegralSum<TIntegral>(linedIntegral, integralStrideElements, windowLeft, windowTop, windowWidth, windowHeight);
1917 const TIntegralSquared squaredSum = linedIntegralSum<TIntegralSquared>(linedIntegralSquared, integralStrideSquaredElements, windowLeft, windowTop, windowWidth, windowHeight);
1919 const TVariance size = TVariance(windowWidth * windowHeight);
1921 if constexpr (tReturnMean)
1923 ocean_assert(mean !=
nullptr);
1924 *mean = TVariance(sum) / size;
1928 ocean_assert(mean ==
nullptr);
1931 const TVariance variance = (TVariance(squaredSum) - TVariance(TIntegralSquared(sum) * TIntegralSquared(sum)) / size) / size;
1933 return std::max(TVariance(0), variance);
1936 template <
typename TIntegral,
typename TIntegralSquared,
typename TVariance,
bool tReturnMean>
1937 inline 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)
1939 static_assert(std::is_floating_point<TVariance>::value,
"Invalid TVariance must be a floating point data type!");
1941 ocean_assert(linedIntegral !=
nullptr);
1942 ocean_assert(windowALeft + windowAWidth < integralStrideElements);
1943 ocean_assert(windowBLeft + windowBWidth < integralStrideElements);
1945 ocean_assert(linedIntegralSquared !=
nullptr);
1946 ocean_assert(windowALeft + windowAWidth < integralStrideSquaredElements);
1947 ocean_assert(windowBLeft + windowBWidth < integralStrideSquaredElements);
1949 ocean_assert(windowAWidth != 0u && windowAHeight != 0u);
1950 ocean_assert(windowBWidth != 0u && windowBHeight != 0u);
1952 const TIntegral sumA = linedIntegralSum<TIntegral>(linedIntegral, integralStrideElements, windowALeft, windowATop, windowAWidth, windowAHeight);
1953 const TIntegral sumB = linedIntegralSum<TIntegral>(linedIntegral, integralStrideElements, windowBLeft, windowBTop, windowBWidth, windowBHeight);
1955 const TIntegralSquared squaredSumA = linedIntegralSum<TIntegralSquared>(linedIntegralSquared, integralStrideSquaredElements, windowALeft, windowATop, windowAWidth, windowAHeight);
1956 const TIntegralSquared squaredSumB = linedIntegralSum<TIntegralSquared>(linedIntegralSquared, integralStrideSquaredElements, windowBLeft, windowBTop, windowBWidth, windowBHeight);
1958 const unsigned int sizeA = windowAWidth * windowAHeight;
1959 const unsigned int sizeB = windowBWidth * windowBHeight;
1960 const TVariance size = TVariance(sizeA + sizeB);
1962 const TVariance squaredSum = TVariance(squaredSumA + squaredSumB);
1963 const TIntegralSquared sum = TIntegralSquared(sumA + sumB);
1965 if constexpr (tReturnMean)
1967 ocean_assert(mean !=
nullptr);
1968 *mean = TVariance(sum) / size;
1972 ocean_assert(mean ==
nullptr);
1975 const TVariance variance = (squaredSum - TVariance(sum * sum) / size) / size;
1977 return std::max(TVariance(0), variance);
1980 template <
typename TIntegral,
typename TIntegralSquared,
typename TVariance,
bool tReturnMean>
1981 inline 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)
1983 static_assert(std::is_floating_point<TVariance>::value,
"Invalid TVariance must be a floating point data type!");
1985 ocean_assert(linedIntegral !=
nullptr);
1986 ocean_assert(windowALeft + windowAWidth < integralStrideElements);
1987 ocean_assert(windowBLeft + windowBWidth < integralStrideElements);
1988 ocean_assert(windowCLeft + windowCWidth < integralStrideElements);
1990 ocean_assert(linedIntegralSquared !=
nullptr);
1991 ocean_assert(windowALeft + windowAWidth < integralStrideSquaredElements);
1992 ocean_assert(windowBLeft + windowBWidth < integralStrideSquaredElements);
1993 ocean_assert(windowCLeft + windowCWidth < integralStrideSquaredElements);
1995 ocean_assert(windowAWidth != 0u && windowAHeight != 0u);
1996 ocean_assert(windowBWidth != 0u && windowBHeight != 0u);
1997 ocean_assert(windowCWidth != 0u && windowCHeight != 0u);
1999 const TIntegral sumA = CV::IntegralImage::linedIntegralSum<TIntegral>(linedIntegral, integralStrideElements, windowALeft, windowATop, windowAWidth, windowAHeight);
2000 const TIntegral sumB = CV::IntegralImage::linedIntegralSum<TIntegral>(linedIntegral, integralStrideElements, windowBLeft, windowBTop, windowBWidth, windowBHeight);
2001 const TIntegral sumC = CV::IntegralImage::linedIntegralSum<TIntegral>(linedIntegral, integralStrideElements, windowCLeft, windowCTop, windowCWidth, windowCHeight);
2003 const TIntegralSquared squaredSumA = CV::IntegralImage::linedIntegralSum<TIntegralSquared>(linedIntegralSquared, integralStrideSquaredElements, windowALeft, windowATop, windowAWidth, windowAHeight);
2004 const TIntegralSquared squaredSumB = CV::IntegralImage::linedIntegralSum<TIntegralSquared>(linedIntegralSquared, integralStrideSquaredElements, windowBLeft, windowBTop, windowBWidth, windowBHeight);
2005 const TIntegralSquared squaredSumC = CV::IntegralImage::linedIntegralSum<TIntegralSquared>(linedIntegralSquared, integralStrideSquaredElements, windowCLeft, windowCTop, windowCWidth, windowCHeight);
2007 const unsigned int sizeA = windowAWidth * windowAHeight;
2008 const unsigned int sizeB = windowBWidth * windowBHeight;
2009 const unsigned int sizeC = windowCWidth * windowCHeight;
2010 const TVariance size = TVariance(sizeA + sizeB + sizeC);
2012 const TVariance squaredSum = TVariance(squaredSumA + squaredSumB + squaredSumC);
2013 const TIntegralSquared sum = TIntegralSquared(sumA + sumB + sumC);
2015 if constexpr (tReturnMean)
2017 ocean_assert(mean !=
nullptr);
2018 *mean = TVariance(sum) / size;
2022 ocean_assert(mean ==
nullptr);
2025 const TVariance variance = (squaredSum - TVariance(sum * sum) / size) / size;
2027 return std::max(TVariance(0), variance);
2030 template <
typename T,
typename TSquared>
2033 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:1505
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 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:823
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:1898
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:636
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:1694
static TSquared sqr(const T &value)
Returns the square value of the given parameter.
Definition: IntegralImage.h:2031
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:1162
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:919
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:1333
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:707
This class implements Ocean's image class.
Definition: Frame.h:1792
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:1495
unsigned int sqr(const char value)
Returns the square value of a given value.
Definition: base/Utilities.h:1029
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15