8 #ifndef META_OCEAN_CV_ADVANCED_FRAME_COLOR_ADJUSTMENT_H
9 #define META_OCEAN_CV_ADVANCED_FRAME_COLOR_ADJUSTMENT_H
39 template <
unsigned int tChannels>
66 inline bool belowThreshold(
const Scalar threshold)
const;
101 inline Scalar operator[](
const unsigned int index)
const;
108 inline Scalar& operator[](
const unsigned int index);
120 template <
unsigned int tChannels>
127 template <
unsigned int tChannels>
173 template <
unsigned int tChannels>
174 static inline void adjustFrameBilinear8BitPerChannel(
const uint8_t* reference,
const uint8_t* referenceMask, uint8_t* frame,
const uint8_t* frameMask,
const unsigned int width,
const unsigned int height,
const unsigned int referencePaddingElements,
const unsigned int referenceMaskPaddingElements,
const unsigned int framePaddingElements,
const unsigned int frameMaskPaddingElements,
const unsigned int horizontalBins,
const unsigned int verticalBins,
const Scalar threshold =
Scalar(20),
const uint8_t maskValue = 0xFF,
Worker* worker =
nullptr);
187 template <
unsigned int tChannels>
188 static inline void determineAdjustmentLookupTable8BitPerChannel(
const uint8_t* reference,
const uint8_t* frame,
const unsigned int referencePaddingElements,
const unsigned int framePaddingElements,
const Scalar threshold,
LookupTable<tChannels>& lookupTable,
Worker* worker =
nullptr);
208 template <
unsigned int tChannels,
bool tUseReferenceMask,
bool tUseFrameMask>
209 static inline void determineAdjustmentLookupTable8BitPerChannel(
const uint8_t* reference,
const uint8_t* referenceMask,
const uint8_t* frame,
const uint8_t* frameMask,
const unsigned int referencePaddingElements,
const unsigned int referenceMaskPaddingElements,
const unsigned int framePaddingElements,
const unsigned int frameMaskPaddingElements,
const Scalar threshold,
LookupTable<tChannels>& lookupTable,
const uint8_t maskValue,
Worker* worker =
nullptr);
219 template <
unsigned int tChannels>
220 static inline void adjustFrameBilinear8BitPerChannel(uint8_t* frame,
const unsigned int framePaddingElements,
const LookupTable<tChannels>& lookupTable,
Worker* worker =
nullptr);
233 template <
unsigned int tChannels>
234 static inline void adjustFrameMaskBilinear8BitPerChannel(uint8_t* frame,
const uint8_t* mask,
const unsigned int framePaddingElements,
const unsigned int maskPaddingElements,
const LookupTable<tChannels>& lookupTable,
const uint8_t maskValue,
Worker* worker =
nullptr);
247 template <
unsigned int tChannels>
248 static inline void adjustFrameMaskBilinearAdvanced8BitPerChannel(uint8_t* frame,
const uint8_t* mask,
const unsigned int framePaddingElements,
const unsigned int maskPaddingElements,
const AdvancedLookupTable<tChannels>& lookupTable,
const uint8_t maskValue,
Worker* worker =
nullptr);
262 template <
unsigned int tChannels>
263 static inline void adjustFrameMaskBilinearAdvanced8BitPerChannel(uint8_t* frame,
const uint8_t* mask,
const unsigned int framePaddingElements,
const unsigned int maskPaddingElements,
const AdvancedLookupTable<tChannels>& lookupTableA,
const AdvancedLookupTable<tChannels>& lookupTableB,
const uint8_t maskValue,
Worker* worker =
nullptr);
276 template <
unsigned int tChannels,
bool tCopyPixelForInval
idLookup>
277 static inline void adjustFrameMaskBilinearAdvanced8BitPerChannel(
const uint8_t* frame,
const uint8_t* mask, uint8_t* adjustedFrame,
const AdvancedLookupTable<tChannels>& lookupTable,
const uint8_t maskValue,
Worker* worker =
nullptr);
291 template <
unsigned int tChannels,
bool tCopyPixelForInval
idLookup>
308 template <
unsigned int tChannels,
bool tCopyPixelForInval
idLookup>
309 static inline void adjustFrameMaskBilinearFilterAdvanced8BitPerChannel(
const uint8_t* frame,
const uint8_t* filterFrame,
const uint8_t* mask,
const uint8_t* filterMask, uint8_t* adjustedFrame,
const AdvancedLookupTable<tChannels>& lookupTableA,
const AdvancedLookupTable<tChannels>& lookupTableB,
const uint8_t maskValue,
Worker* worker =
nullptr);
326 template <
unsigned int tChannels>
327 static inline void colorMatchingTransfer(
const uint8_t* frame,
const uint8_t* mask, uint8_t* target,
const unsigned int width,
const unsigned int height,
const std::vector<Scalar>& frameMean,
const std::vector<Scalar>& frameStd,
const std::vector<Scalar>& refMean,
const std::vector<Scalar>& refStd,
const uint8_t maskValue,
Worker* worker =
nullptr);
345 template<
unsigned int tChannels>
346 static inline void colorMatchingTransfer8BitPerChannelSubset(
const uint8_t* frame,
const uint8_t* mask, uint8_t* target,
const unsigned int width,
const unsigned int height,
const Scalar* frameMean,
const Scalar* frameStd,
const Scalar* refMean,
const Scalar* refStd,
const unsigned int firstRow,
const unsigned int numberRows,
const uint8_t maskValue);
360 template <
unsigned int tChannels>
361 static inline void determineMeanFrameMaskAdvanced8BitPerChannel(
const uint8_t* frame,
const uint8_t* mask,
AdvancedLookupTable<tChannels>& lookupTable,
const uint8_t maskValue,
const unsigned int minimalSamples,
Worker* worker =
nullptr);
376 template <
unsigned int tChannels>
395 template <
unsigned int tChannels>
396 static inline void determineMeanFrameMaskAdvanced8BitPerChannel(
const uint8_t* frame,
const uint8_t* mask,
const uint8_t* separationMask,
AdvancedLookupTable<tChannels>& lookupTableA,
AdvancedLookupTable<tChannels>& lookupTableB,
const uint8_t maskValue,
const uint8_t separationMaskValue,
const unsigned int minimalSamples,
Worker* worker =
nullptr);
412 template <
unsigned int tChannels>
413 static void determineAdjustmentLookupTable8BitPerChannelSubset(
const uint8_t* reference,
const uint8_t* frame,
const unsigned int referencePaddingElements,
const unsigned int framePaddingElements,
const Scalar threshold,
LookupTable<tChannels>* lookupTable,
unsigned int firstBin,
const unsigned int numberBins);
434 template <
unsigned int tChannels,
bool tUseReferenceMask,
bool tUseFrameMask>
435 static void determineAdjustmentLookupTable8BitPerChannelSubset(
const uint8_t* reference,
const uint8_t* referenceMask,
const uint8_t* frame,
const uint8_t* frameMask,
const unsigned int referencePaddingElements,
const unsigned int referenceMaskPaddingElements,
const unsigned int framePaddingElements,
const unsigned int frameMaskPaddingElements,
const Scalar threshold,
LookupTable<tChannels>* lookupTable,
const uint8_t maskValue,
unsigned int firstBin,
const unsigned int numberBins);
446 template <
unsigned int tChannels>
447 static void adjustFrameBilinear8BitPerChannelSubset(uint8_t* frame,
const unsigned int framePaddingElements,
const LookupTable<tChannels>* lookupTable,
const unsigned int firstRow,
const unsigned int numberRows);
461 template <
unsigned int tChannels>
462 static void adjustFrameMaskBilinear8BitPerChannelSubset(uint8_t* frame,
const uint8_t* mask,
const unsigned int framePaddingElements,
const unsigned int maskPaddingElements,
const LookupTable<tChannels>* lookupTable,
const uint8_t maskValue,
const unsigned int firstRow,
const unsigned int numberRows);
474 template <
unsigned int tChannels>
475 static void adjustFrameMaskBilinearAdvanced8BitPerChannelSubset(uint8_t* frame,
const uint8_t* mask,
const AdvancedLookupTable<tChannels>* lookupTable,
const uint8_t maskValue,
const unsigned int firstRow,
const unsigned int numberRows);
488 template <
unsigned int tChannels>
503 template <
unsigned int tChannels,
bool tCopyPixelForInval
idLookup>
504 static void adjustFrameMaskBilinearAdvanced8BitPerChannelSubset(
const uint8_t* frame,
const uint8_t* mask, uint8_t* adjustedFrame,
const AdvancedLookupTable<tChannels>* lookupTable,
const uint8_t maskValue,
const unsigned int firstRow,
const unsigned int numberRows);
519 template <
unsigned int tChannels,
bool tCopyPixelForInval
idLookup>
520 static void adjustFrameMaskBilinearAdvanced8BitPerChannelSubset(
const uint8_t* frame,
const uint8_t* mask, uint8_t* adjustedFrame,
const AdvancedLookupTable<tChannels>* lookupTableA,
const AdvancedLookupTable<tChannels>* lookupTableB,
const uint8_t maskValue,
const unsigned int firstRow,
const unsigned int numberRows);
535 template <
unsigned int tChannels>
536 static inline void determineMeanFrameMaskAdvanced8BitPerChannelSubset(
const uint8_t* frame,
const uint8_t* mask,
AdvancedLookupTable<tChannels>* lookupTable,
const uint8_t maskValue,
const unsigned int minimalSamples,
const unsigned int firstBin,
const unsigned int numberBins);
552 template <
unsigned int tChannels>
553 static inline void determineMeanFrameMaskAdvanced8BitPerChannelSubset(
const uint8_t* frame,
const uint8_t* mask,
AdvancedLookupTable<tChannels>* lookupTableA,
AdvancedLookupTable<tChannels>* lookupTableB,
const uint8_t maskValue,
const unsigned int minimalSamples,
const unsigned int firstBin,
const unsigned int numberBins);
572 template <
unsigned int tChannels>
573 static inline void determineMeanFrameMaskAdvanced8BitPerChannelSubset(
const uint8_t* frame,
const uint8_t* mask,
const uint8_t* separationMask,
AdvancedLookupTable<tChannels>* lookupTableA,
AdvancedLookupTable<tChannels>* lookupTableB,
const uint8_t maskValue,
const uint8_t separationMaskValue,
const unsigned int minimalSamples,
const unsigned int firstBin,
const unsigned int numberBins);
576 template <
unsigned int tChannels>
579 static_assert(tChannels != 0u,
"Invalid channel number!");
581 for (
unsigned int n = 0u; n < tChannels; ++n)
583 objectValues_[n] =
Scalar(0);
587 template <
unsigned int tChannels>
590 static_assert(tChannels != 0u,
"Invalid channel number!");
592 ocean_assert(values !=
nullptr);
594 for (
unsigned int n = 0u; n < tChannels; ++n)
596 objectValues_[n] = values[n];
600 template <
unsigned int tChannels>
603 static_assert(tChannels != 0u,
"Invalid channel number!");
605 for (
unsigned int n = 0u; n < tChannels; ++n)
607 objectValues_[n] = value;
611 template <
unsigned int tChannels>
614 ocean_assert(threshold >= 0);
616 for (
unsigned int n = 0u; n < tChannels; ++n)
627 template <
unsigned int tChannels>
632 for (
unsigned int n = 0u; n < tChannels; ++n)
640 template <
unsigned int tChannels>
645 for (
unsigned int n = 0u; n < tChannels; ++n)
653 template <
unsigned int tChannels>
658 for (
unsigned int n = 0u; n < tChannels; ++n)
666 template <
unsigned int tChannels>
674 for (
unsigned int n = 0u; n < tChannels; ++n)
682 template <
unsigned int tChannels>
685 ocean_assert(index < tChannels);
686 return objectValues_[index];
689 template <
unsigned int tChannels>
692 ocean_assert(index < tChannels);
693 return objectValues_[index];
696 template <
unsigned int tChannels>
697 inline void FrameColorAdjustment::adjustFrameBilinear8BitPerChannel(
const uint8_t* reference,
const uint8_t* referenceMask, uint8_t* frame,
const uint8_t* frameMask,
const unsigned int width,
const unsigned int height,
const unsigned int referencePaddingElements,
const unsigned int referenceMaskPaddingElements,
const unsigned int framePaddingElements,
const unsigned int frameMaskPaddingElements,
const unsigned int horizontalBins,
const unsigned int verticalBins,
const Scalar threshold,
const uint8_t maskValue,
Worker* worker)
699 ocean_assert(reference !=
nullptr && frame !=
nullptr);
703 if (referenceMask !=
nullptr && frameMask !=
nullptr)
705 determineAdjustmentLookupTable8BitPerChannel<tChannels, true, true>(reference, referenceMask, frame, frameMask, referencePaddingElements, referenceMaskPaddingElements, framePaddingElements, frameMaskPaddingElements, threshold, lookupTable, maskValue, worker);
707 else if (referenceMask !=
nullptr)
709 determineAdjustmentLookupTable8BitPerChannel<tChannels, true, false>(reference, referenceMask, frame,
nullptr, referencePaddingElements, referenceMaskPaddingElements, framePaddingElements, 0u , threshold, lookupTable, maskValue, worker);
713 determineAdjustmentLookupTable8BitPerChannel<tChannels, false, true>(reference,
nullptr, frame, frameMask, referencePaddingElements, 0u , framePaddingElements, frameMaskPaddingElements, threshold, lookupTable, maskValue, worker);
717 determineAdjustmentLookupTable8BitPerChannel<tChannels>(reference, frame, referencePaddingElements, framePaddingElements, threshold, lookupTable, worker);
722 adjustFrameMaskBilinear8BitPerChannel<tChannels>(frame, frameMask, framePaddingElements, frameMaskPaddingElements, lookupTable, maskValue, worker);
726 adjustFrameBilinear8BitPerChannel<tChannels>(frame, framePaddingElements, lookupTable, worker);
730 template <
unsigned int tChannels>
733 ocean_assert(reference !=
nullptr && frame !=
nullptr);
734 ocean_assert(!lookupTable.
isEmpty());
738 worker->
executeFunction(
Worker::Function::createStatic(&FrameColorAdjustment::determineAdjustmentLookupTable8BitPerChannelSubset<tChannels>, reference, frame, referencePaddingElements, framePaddingElements, threshold, &lookupTable, 0u, 0u), 0u, (
unsigned int)(lookupTable.
binsX() * lookupTable.
binsY()));
742 determineAdjustmentLookupTable8BitPerChannelSubset<tChannels>(reference, frame, referencePaddingElements, framePaddingElements, threshold, &lookupTable, 0u, (
unsigned int)(lookupTable.
binsX() * lookupTable.
binsY()));
746 template <
unsigned int tChannels,
bool tUseReferenceMask,
bool tUseFrameMask>
747 inline void FrameColorAdjustment::determineAdjustmentLookupTable8BitPerChannel(
const uint8_t* reference,
const uint8_t* referenceMask,
const uint8_t* frame,
const uint8_t* frameMask,
const unsigned int referencePaddingElements,
const unsigned int referenceMaskPaddingElements,
const unsigned int framePaddingElements,
const unsigned int frameMaskPaddingElements,
const Scalar threshold,
LookupTable<tChannels>& lookupTable,
const uint8_t maskValue,
Worker* worker)
749 ocean_assert(reference !=
nullptr && frame !=
nullptr);
750 ocean_assert(!lookupTable.
isEmpty());
754 worker->
executeFunction(
Worker::Function::createStatic(&FrameColorAdjustment::determineAdjustmentLookupTable8BitPerChannelSubset<tChannels, tUseReferenceMask, tUseFrameMask>, reference, referenceMask, frame, frameMask, referencePaddingElements, referenceMaskPaddingElements, framePaddingElements, frameMaskPaddingElements, threshold, &lookupTable, maskValue, 0u, 0u), 0u, (
unsigned int)(lookupTable.
binsX() * lookupTable.
binsY()));
758 determineAdjustmentLookupTable8BitPerChannelSubset<tChannels, tUseReferenceMask, tUseFrameMask>(reference, referenceMask, frame, frameMask, referencePaddingElements, referenceMaskPaddingElements, framePaddingElements, frameMaskPaddingElements, threshold, &lookupTable, maskValue, 0u, (
unsigned int)(lookupTable.
binsX() * lookupTable.
binsY()));
762 template <
unsigned int tChannels>
765 static_assert(tChannels != 0u,
"Invalid channel number!");
767 ocean_assert(frame !=
nullptr);
768 ocean_assert(!lookupTable.
isEmpty());
776 adjustFrameBilinear8BitPerChannelSubset<tChannels>(frame, framePaddingElements, &lookupTable, 0u, (
unsigned int)(lookupTable.
sizeY()));
780 template <
unsigned int tChannels>
783 static_assert(tChannels != 0u,
"Invalid channel number!");
785 ocean_assert(frame !=
nullptr && mask !=
nullptr);
786 ocean_assert(!lookupTable.
isEmpty());
790 worker->
executeFunction(
Worker::Function::createStatic(&FrameColorAdjustment::adjustFrameMaskBilinear8BitPerChannelSubset<tChannels>, frame, mask, framePaddingElements, maskPaddingElements, &lookupTable, maskValue, 0u, 0u), 0u, (
unsigned int)(lookupTable.
sizeY()));
794 adjustFrameMaskBilinear8BitPerChannelSubset<tChannels>(frame, mask, framePaddingElements, maskPaddingElements, &lookupTable, maskValue, 0u, (
unsigned int)(lookupTable.
sizeY()));
798 template <
unsigned int tChannels>
801 static_assert(tChannels != 0u,
"Invalid channel number!");
803 ocean_assert(frame !=
nullptr && mask !=
nullptr);
804 ocean_assert(!lookupTable.
isEmpty());
808 worker->
executeFunction(
Worker::Function::createStatic(&FrameColorAdjustment::adjustFrameMaskBilinear8BitPerChannelSubset<tChannels>, frame, mask, framePaddingElements, maskPaddingElements, &lookupTable, maskValue, 0u, 0u), 0u, (
unsigned int)(lookupTable.
sizeY()));
812 adjustFrameMaskBilinear8BitPerChannelSubset<tChannels>(frame, mask, framePaddingElements, maskPaddingElements, &lookupTable, maskValue, 0u, (
unsigned int)(lookupTable.
sizeY()));
816 template <
unsigned int tChannels>
819 static_assert(tChannels != 0u,
"Invalid channel number!");
821 ocean_assert(frame !=
nullptr && mask !=
nullptr);
822 ocean_assert(!lookupTableA.
isEmpty());
823 ocean_assert(lookupTableA.
sizeX() == lookupTableB.
sizeX() && lookupTableA.
sizeY() == lookupTableB.
sizeY());
827 worker->
executeFunction(
Worker::Function::createStatic(&FrameColorAdjustment::adjustFrameMaskBilinear8BitPerChannelSubset<tChannels>, frame, mask, framePaddingElements, maskPaddingElements, &lookupTableA, &lookupTableB, maskValue, 0u, 0u), 0u, (
unsigned int)(lookupTableA.
sizeY()));
831 adjustFrameMaskBilinear8BitPerChannelSubset<tChannels>(frame, mask, framePaddingElements, maskPaddingElements, &lookupTableA, &lookupTableB, maskValue, 0u, (
unsigned int)(lookupTableA.
sizeY()));
835 template <
unsigned int tChannels,
bool tCopyPixelForInval
idLookup>
838 static_assert(tChannels != 0u,
"Invalid channel number!");
840 ocean_assert(frame !=
nullptr && mask !=
nullptr && adjustedFrame !=
nullptr);
841 ocean_assert(!lookupTable.
isEmpty());
845 worker->
executeFunction(
Worker::Function::createStatic(&FrameColorAdjustment::adjustFrameMaskBilinearAdvanced8BitPerChannelSubset<tChannels, tCopyPixelForInvalidLookup>, frame, mask, adjustedFrame, &lookupTable, maskValue, 0u, 0u), 0u, (
unsigned int)(lookupTable.
sizeY()));
849 adjustFrameMaskBilinearAdvanced8BitPerChannelSubset<tChannels, tCopyPixelForInvalidLookup>(frame, mask, adjustedFrame, &lookupTable, maskValue, 0u, (
unsigned int)(lookupTable.
sizeY()));
853 template <
unsigned int tChannels,
bool tCopyPixelForInval
idLookup>
856 static_assert(tChannels != 0u,
"Invalid channel number!");
858 ocean_assert(frame !=
nullptr && mask !=
nullptr && adjustedFrame !=
nullptr);
859 ocean_assert(!lookupTableA.
isEmpty());
860 ocean_assert(lookupTableA.
sizeX() == lookupTableB.
sizeX() && lookupTableA.
sizeY() == lookupTableB.
sizeY());
864 worker->
executeFunction(
Worker::Function::createStatic(&FrameColorAdjustment::adjustFrameMaskBilinearAdvanced8BitPerChannelSubset<tChannels, tCopyPixelForInvalidLookup>, frame, mask, adjustedFrame, &lookupTableA, &lookupTableB, maskValue, 0u, 0u), 0u, (
unsigned int)(lookupTableA.
sizeY()));
868 adjustFrameMaskBilinearAdvanced8BitPerChannelSubset<tChannels, tCopyPixelForInvalidLookup>(frame, mask, adjustedFrame, &lookupTableA, &lookupTableB, maskValue, 0u, (
unsigned int)(lookupTableA.
sizeY()));
872 template <
unsigned int tChannels,
bool tCopyPixelForInval
idLookup>
875 static_assert(tChannels != 0u,
"Invalid channel number!");
877 ocean_assert(frame !=
nullptr && mask !=
nullptr && adjustedFrame !=
nullptr);
878 ocean_assert(!lookupTableA.
isEmpty());
879 ocean_assert(lookupTableA.
sizeX() == lookupTableB.
sizeX() && lookupTableA.
sizeY() == lookupTableB.
sizeY());
883 worker->
executeFunction(
Worker::Function::createStatic(&FrameColorAdjustment::adjustFrameMaskBilinearAdvanced8BitPerChannelSubset<tChannels, tCopyPixelForInvalidLookup>, frame, filterFrame, mask, filterMask, adjustedFrame, &lookupTableA, &lookupTableB, maskValue, 0u, 0u), 0u, (
unsigned int)(lookupTableA.
sizeY()));
887 adjustFrameMaskBilinearAdvanced8BitPerChannelSubset<tChannels, tCopyPixelForInvalidLookup>(frame, filterFrame, mask, filterMask, adjustedFrame, &lookupTableA, &lookupTableB, maskValue, 0u, (
unsigned int)(lookupTableA.
sizeY()));
891 template<
unsigned int tChannels>
892 inline void FrameColorAdjustment::colorMatchingTransfer(
const uint8_t* frame,
const uint8_t* mask, uint8_t* target,
const unsigned int width,
const unsigned int height,
const Scalars& frameMean,
const Scalars& frameStd,
const Scalars& refMean,
const Scalars& refStd,
const uint8_t maskValue,
Worker* worker)
894 static_assert(tChannels != 0u,
"Invalid channel number!");
895 ocean_assert(frame !=
nullptr && mask !=
nullptr && target !=
nullptr);
896 ocean_assert(width != 0u && height != 0u);
900 worker->
executeFunction(
Worker::Function::createStatic(&FrameColorAdjustment::colorMatchingTransfer8BitPerChannelSubset<tChannels>, frame, mask, target, width, height, frameMean.data(), frameStd.data(), refMean.data(), refStd.data(), 0u, 0u, maskValue), 0u, height, 9u, 10u, 20u);
904 colorMatchingTransfer8BitPerChannelSubset<tChannels>(frame, mask, target, width, height, frameMean.data(), frameStd.data(), refMean.data(), refStd.data(), 0u, height, maskValue);
908 template<
unsigned int tChannels>
909 inline void FrameColorAdjustment::colorMatchingTransfer8BitPerChannelSubset(
const uint8_t* frame,
const uint8_t* mask, uint8_t* target,
const unsigned int width,
const unsigned int height,
const Scalar* frameMean,
const Scalar* frameStd,
const Scalar* refMean,
const Scalar* refStd,
const unsigned int firstRow,
const unsigned int numberRows,
const uint8_t maskValue)
911 ocean_assert(frame !=
nullptr && mask !=
nullptr && target !=
nullptr);
912 ocean_assert(width != 0u && height != 0u);
914 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
916 const uint8_t* pixFrame = frame;
917 const uint8_t* pixMask = mask;
919 pixFrame += firstRow * width * tChannels;
920 pixMask += firstRow * width;
921 target += firstRow * width * tChannels;
923 const uint8_t*
const fEnd = pixFrame + (width * numberRows * tChannels);
925 while (pixFrame != fEnd)
927 ocean_assert(pixFrame < fEnd);
928 if(*pixMask == maskValue)
930 for (
unsigned int n = 0u; n < tChannels; ++n)
932 Scalar colorTransValue = pixFrame[n];
933 colorTransValue -= refMean[n];
934 colorTransValue *= (refStd[n] / frameStd[n]);
935 colorTransValue += frameMean[n];
936 target[n] = (uint8_t)(minmax<int>(0,
Numeric::round32(colorTransValue), 255));
941 for (
unsigned int n = 0u; n < tChannels; ++n)
943 target[n] = pixFrame[n];
948 pixFrame += tChannels;
953 template <
unsigned int tChannels>
956 static_assert(tChannels != 0u,
"Invalid channel number!");
958 ocean_assert(frame !=
nullptr && mask !=
nullptr);
959 ocean_assert(!lookupTable.
isEmpty());
960 ocean_assert(minimalSamples >= 1u);
968 determineMeanFrameMaskAdvanced8BitPerChannelSubset<tChannels>(frame, mask, &lookupTable, maskValue, minimalSamples, 0u, (
unsigned int)(lookupTable.
binsY()));
972 template <
unsigned int tChannels>
975 static_assert(tChannels != 0u,
"Invalid channel number!");
977 ocean_assert(frame !=
nullptr && separationMask !=
nullptr);
978 ocean_assert(!lookupTableA.
isEmpty());
979 ocean_assert(lookupTableA.
sizeX() == lookupTableB.
sizeX() && lookupTableA.
sizeY() == lookupTableB.
sizeY());
980 ocean_assert(minimalSamples >= 1u);
984 worker->
executeFunction(
Worker::Function::createStatic(&FrameColorAdjustment::determineMeanFrameMaskAdvanced8BitPerChannelSubset<tChannels>, frame, separationMask, &lookupTableA, &lookupTableB, separationMaskValue, minimalSamples, 0u, 0u), 0u, (
unsigned int)(lookupTableA.
binsY()));
988 determineMeanFrameMaskAdvanced8BitPerChannelSubset<tChannels>(frame, separationMask, &lookupTableA, &lookupTableB, separationMaskValue, minimalSamples, 0u, (
unsigned int)(lookupTableA.
binsY()));
992 template <
unsigned int tChannels>
995 static_assert(tChannels != 0u,
"Invalid channel number!");
997 ocean_assert(frame !=
nullptr && mask !=
nullptr && separationMask !=
nullptr);
998 ocean_assert(!lookupTableA.
isEmpty());
999 ocean_assert(lookupTableA.
sizeX() == lookupTableB.
sizeX() && lookupTableA.
sizeY() == lookupTableB.
sizeY());
1000 ocean_assert(minimalSamples >= 1u);
1004 worker->
executeFunction(
Worker::Function::createStatic(&FrameColorAdjustment::determineMeanFrameMaskAdvanced8BitPerChannelSubset<tChannels>, frame, mask, separationMask, &lookupTableA, &lookupTableB, maskValue, separationMaskValue, minimalSamples, 0u, 0u), 0u, (
unsigned int)(lookupTableA.
binsY()));
1008 determineMeanFrameMaskAdvanced8BitPerChannelSubset<tChannels>(frame, mask, separationMask, &lookupTableA, &lookupTableB, maskValue, separationMaskValue, minimalSamples, 0u, (
unsigned int)(lookupTableA.
binsY()));
1012 template <
unsigned int tChannels>
1015 ocean_assert(reference !=
nullptr && frame !=
nullptr);
1016 ocean_assert(lookupTable !=
nullptr && !lookupTable->
isEmpty());
1018 const unsigned int widthElements = (
unsigned int)(lookupTable->
sizeX()) * tChannels;
1020 const unsigned int referenceStrideElements = widthElements + referencePaddingElements;
1021 const unsigned int frameStrideElements = widthElements + framePaddingElements;
1023 for (
unsigned int n = firstBin; n < firstBin + numberBins; ++n)
1025 const unsigned int binY = n / (
unsigned int)(lookupTable->
binsX());
1026 const unsigned int binX = n - binY * (
unsigned int)(lookupTable->
binsX());
1027 ocean_assert(binX == n % lookupTable->
binsX());
1029 const unsigned int left = (
unsigned int)(lookupTable->
binTopLeftX(binX));
1030 const unsigned int top = (
unsigned int)(lookupTable->
binTopLeftY(binY));
1032 const unsigned int right = (
unsigned int)(lookupTable->
binBottomRightX(binX));
1033 const unsigned int bottom = (
unsigned int)(lookupTable->
binBottomRightY(binY));
1037 const uint8_t* framePixel = frame + top * frameStrideElements + left * tChannels;
1038 const uint8_t* referencePixel = reference + top * referenceStrideElements + left * tChannels;
1040 const unsigned int binWidthElements = (right - left + 1u) * tChannels;
1041 ocean_assert(binWidthElements <= frameStrideElements && binWidthElements <= referenceStrideElements);
1043 const unsigned int frameRowOffset = frameStrideElements - binWidthElements;
1044 const unsigned int referenceRowOffset = referenceStrideElements - binWidthElements;
1046 for (
unsigned int y = top; y <= bottom; ++y)
1048 for (
unsigned int x = left; x <= right; ++x)
1050 for (
unsigned int i = 0u; i < tChannels; ++i)
1052 frameObject[i] += framePixel[i];
1055 for (
unsigned int i = 0u; i < tChannels; ++i)
1057 referenceObject[i] += referencePixel[i];
1060 framePixel += tChannels;
1061 referencePixel += tChannels;
1064 framePixel += frameRowOffset;
1065 referencePixel += referenceRowOffset;
1068 ocean_assert((right - left + 1u) * (bottom - top + 1u) != 0u);
1069 const Scalar normalization =
Scalar(1) /
Scalar((right - left + 1u) * (bottom - top + 1u));
1073 for (
unsigned int i = 0u; i < tChannels; ++i)
1075 object[i] = (referenceObject[i] - frameObject[i]) * normalization;
1078 if (
object.belowThreshold(threshold))
1089 template <
unsigned int tChannels,
bool tUseReferenceMask,
bool tUseFrameMask>
1090 inline void FrameColorAdjustment::determineAdjustmentLookupTable8BitPerChannelSubset(
const uint8_t* reference,
const uint8_t* referenceMask,
const uint8_t* frame,
const uint8_t* frameMask,
const unsigned int referencePaddingElements,
const unsigned int referenceMaskPaddingElements,
const unsigned int framePaddingElements,
const unsigned int frameMaskPaddingElements,
const Scalar threshold,
LookupTable<tChannels>* lookupTable,
const uint8_t maskValue,
unsigned int firstBin,
const unsigned int numberBins)
1092 ocean_assert(reference !=
nullptr && frame !=
nullptr);
1093 ocean_assert(lookupTable !=
nullptr && !lookupTable->
isEmpty());
1095 const unsigned int widthElements = (
unsigned int)(lookupTable->
sizeX()) * tChannels;
1097 const unsigned int referenceStrideElements = widthElements + referencePaddingElements;
1098 const unsigned int referenceMaskStrideElements = (
unsigned int)(lookupTable->
sizeX()) + referenceMaskPaddingElements;
1100 const unsigned int frameStrideElements = widthElements + framePaddingElements;
1101 const unsigned int frameMaskStrideElements = (
unsigned int)(lookupTable->
sizeX()) + frameMaskPaddingElements;
1103 for (
unsigned int n = firstBin; n < firstBin + numberBins; ++n)
1105 const unsigned int binY = n / (
unsigned int)lookupTable->
binsX();
1106 const unsigned int binX = n - binY * (
unsigned int)lookupTable->
binsX();
1107 ocean_assert(binX == n % lookupTable->
binsX());
1109 const unsigned int left = (
unsigned int)lookupTable->
binTopLeftX(binX);
1110 const unsigned int top = (
unsigned int)lookupTable->
binTopLeftY(binY);
1112 const unsigned int right = (
unsigned int)lookupTable->
binBottomRightX(binX);
1113 const unsigned int bottom = (
unsigned int)lookupTable->
binBottomRightY(binY);
1117 unsigned int referenceCounter = 0u;
1118 unsigned int frameCounter = 0u;
1120 const uint8_t* framePixel = frame + top * frameStrideElements + left * tChannels;
1121 const uint8_t* frameMaskPixel = tUseFrameMask ? frameMask + top * frameMaskStrideElements + left :
nullptr;
1123 const uint8_t* referencePixel = reference + top * referenceStrideElements + left * tChannels;
1124 const uint8_t* referenceMaskPixel = tUseReferenceMask ? referenceMask + top * referenceMaskStrideElements + left :
nullptr;
1126 const unsigned int binWidthElements = (right - left + 1u) * tChannels;
1127 ocean_assert(binWidthElements <= frameStrideElements && binWidthElements <= referenceStrideElements);
1129 const unsigned int frameRowOffset = frameStrideElements - binWidthElements;
1130 const unsigned int frameMaskRowOffset = tUseFrameMask ? frameMaskStrideElements - (right - left + 1u) : 0u;
1132 const unsigned int referenceRowOffset = referenceStrideElements - binWidthElements;
1133 const unsigned int referenceMaskRowOffset = tUseReferenceMask ? referenceMaskStrideElements - (right - left + 1u) : 0u;
1135 for (
unsigned int y = top; y <= bottom; ++y)
1137 for (
unsigned int x = left; x <= right; ++x)
1139 if (!tUseFrameMask || *frameMaskPixel == maskValue)
1141 for (
unsigned int i = 0u; i < tChannels; ++i)
1143 frameObject[i] += framePixel[i];
1149 if (!tUseReferenceMask || *referenceMaskPixel == maskValue)
1151 for (
unsigned int i = 0u; i < tChannels; ++i)
1153 referenceObject[i] += referencePixel[i];
1159 framePixel += tChannels;
1160 referencePixel += tChannels;
1162 if constexpr (tUseFrameMask)
1167 if constexpr (tUseReferenceMask)
1169 ++referenceMaskPixel;
1173 framePixel += frameRowOffset;
1174 referencePixel += referenceRowOffset;
1176 if constexpr (tUseFrameMask)
1178 frameMaskPixel += frameMaskRowOffset;
1181 if constexpr (tUseReferenceMask)
1183 referenceMaskPixel += referenceMaskRowOffset;
1187 if (frameCounter != 0u && referenceCounter != 0u)
1194 for (
unsigned int i = 0u; i < tChannels; ++i)
1196 object[i] = referenceObject[i] * referenceNormalization - frameObject[i] * frameNormalization;
1199 if (
object.belowThreshold(threshold))
1211 template <
unsigned int tChannels>
1214 static_assert(tChannels != 0u,
"Invalid channel number!");
1216 ocean_assert(frame !=
nullptr);
1217 ocean_assert(lookupTable !=
nullptr && !lookupTable->
isEmpty());
1218 ocean_assert(firstRow + numberRows <= lookupTable->sizeY());
1220 const unsigned int frameStrideElements = (
unsigned int)(lookupTable->
sizeX()) * tChannels + framePaddingElements;
1222 frame += firstRow * frameStrideElements;
1224 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
1226 for (
unsigned int x = 0u; x < (
unsigned int)(lookupTable->
sizeX()); ++x)
1230 for (
unsigned int n = 0u; n < tChannels; ++n)
1238 frame += framePaddingElements;
1242 template <
unsigned int tChannels>
1245 static_assert(tChannels != 0u,
"Invalid channel number!");
1247 ocean_assert(frame !=
nullptr && mask !=
nullptr);
1248 ocean_assert(lookupTable !=
nullptr && !lookupTable->
isEmpty());
1249 ocean_assert(firstRow + numberRows <= lookupTable->sizeY());
1251 const unsigned int frameStrideElements = (
unsigned int)(lookupTable->
sizeX()) * tChannels + framePaddingElements;
1252 const unsigned int maskStrideElements = (
unsigned int)(lookupTable->
sizeX()) + maskPaddingElements;
1254 frame += firstRow * frameStrideElements;
1255 mask += firstRow * maskStrideElements;
1257 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
1259 for (
unsigned int x = 0u; x < (
unsigned int)lookupTable->
sizeX(); ++x)
1261 if (*mask == maskValue)
1265 for (
unsigned int n = 0u; n < tChannels; ++n)
1275 frame += framePaddingElements;
1276 mask += maskPaddingElements;
1280 template <
unsigned int tChannels>
1283 static_assert(tChannels != 0u,
"Invalid channel number!");
1285 ocean_assert(frame !=
nullptr && mask !=
nullptr);
1286 ocean_assert(lookupTable !=
nullptr && !lookupTable->
isEmpty());
1287 ocean_assert(firstRow + numberRows <= lookupTable->sizeY());
1289 frame += firstRow * lookupTable->
sizeX() * tChannels;
1290 mask += firstRow * lookupTable->
sizeX();
1294 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
1296 for (
unsigned int x = 0u; x < (
unsigned int)lookupTable->
sizeX(); ++x)
1300 for (
unsigned int n = 0u; n < tChannels; ++n)
1310 template <
unsigned int tChannels>
1313 static_assert(tChannels != 0u,
"Invalid channel number!");
1315 ocean_assert(frame !=
nullptr && mask !=
nullptr);
1316 ocean_assert(lookupTableA !=
nullptr && lookupTableB !=
nullptr && !lookupTableA->
isEmpty());
1317 ocean_assert(lookupTableA->
sizeX() == lookupTableB->
sizeX() && lookupTableA->
sizeY() == lookupTableB->
sizeY());
1318 ocean_assert(firstRow + numberRows <= lookupTableA->sizeY());
1320 frame += firstRow * lookupTableA->
sizeX() * tChannels;
1321 mask += firstRow * lookupTableA->
sizeX();
1325 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
1327 for (
unsigned int x = 0u; x < (
unsigned int)lookupTableA->
sizeX(); ++x)
1329 if (*mask == maskValue)
1333 for (
unsigned int n = 0u; n < tChannels; ++n)
1339 ocean_assert(*mask != maskValue);
1343 for (
unsigned int n = 0u; n < tChannels; ++n)
1354 template <
unsigned int tChannels,
bool tCopyPixelForInval
idLookup>
1357 static_assert(tChannels != 0u,
"Invalid channel number!");
1359 ocean_assert(frame !=
nullptr && mask !=
nullptr && adjustedFrame !=
nullptr);
1360 ocean_assert(lookupTable !=
nullptr && !lookupTable->
isEmpty());
1361 ocean_assert(firstRow + numberRows <= lookupTable->sizeY());
1365 frame += firstRow * lookupTable->
sizeX() * tChannels;
1366 adjustedFrame += firstRow * lookupTable->
sizeX() * tChannels;
1367 mask += firstRow * lookupTable->
sizeX();
1371 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
1373 for (
unsigned int x = 0u; x < (
unsigned int)lookupTable->
sizeX(); ++x)
1375 if (*mask == maskValue)
1379 for (
unsigned int n = 0u; n < tChannels; ++n)
1386 if constexpr (tCopyPixelForInvalidLookup)
1388 *((PixelType*)adjustedFrame) = *((PixelType*)frame);
1394 adjustedFrame += tChannels;
1400 template <
unsigned int tChannels,
bool tCopyPixelForInval
idLookup>
1403 static_assert(tChannels != 0u,
"Invalid channel number!");
1405 ocean_assert(frame !=
nullptr && mask !=
nullptr && adjustedFrame !=
nullptr);
1406 ocean_assert(lookupTableA !=
nullptr && lookupTableB !=
nullptr && !lookupTableA->
isEmpty());
1407 ocean_assert(lookupTableA->
sizeX() == lookupTableB->
sizeX() && lookupTableA->
sizeY() == lookupTableB->
sizeY());
1408 ocean_assert(firstRow + numberRows <= lookupTableA->sizeY());
1412 frame += firstRow * lookupTableA->
sizeX() * tChannels;
1413 adjustedFrame += firstRow * lookupTableA->
sizeX() * tChannels;
1414 mask += firstRow * lookupTableA->
sizeX();
1418 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
1420 for (
unsigned int x = 0u; x < (
unsigned int)(lookupTableA->
sizeX()); ++x)
1422 if (*mask == maskValue)
1427 for (
unsigned int n = 0u; n < tChannels; ++n)
1434 if constexpr (tCopyPixelForInvalidLookup)
1436 *((PixelType*)adjustedFrame) = *((PixelType*)frame);
1442 ocean_assert(*mask != maskValue);
1447 for (
unsigned int n = 0u; n < tChannels; ++n)
1454 if constexpr (tCopyPixelForInvalidLookup)
1456 *((PixelType*)adjustedFrame) = *((PixelType*)frame);
1462 adjustedFrame += tChannels;
1468 template <
unsigned int tChannels>
1471 ocean_assert(frame !=
nullptr && mask !=
nullptr);
1472 ocean_assert(lookupTable !=
nullptr && !lookupTable->
isEmpty());
1473 ocean_assert(minimalSamples >= 1u);
1475 ocean_assert(firstBin + numberBins <= lookupTable->binsY());
1477 const unsigned int width = lookupTable->
sizeX();
1479 for (
unsigned int yBin = firstBin; yBin < firstBin + numberBins; ++yBin)
1481 for (
unsigned int xBin = 0u; xBin < lookupTable->
binsX(); ++xBin)
1483 const unsigned int left = (
unsigned int)lookupTable->
binTopLeftX(xBin);
1484 const unsigned int top = (
unsigned int)lookupTable->
binTopLeftY(yBin);
1486 const unsigned int right = (
unsigned int)lookupTable->
binBottomRightX(xBin);
1487 const unsigned int bottom = (
unsigned int)lookupTable->
binBottomRightY(yBin);
1490 unsigned int samples = 0u;
1492 for (
unsigned int y = top; y <= bottom; ++y)
1494 for (
unsigned int x = left; x <= right; ++x)
1496 if (mask[y * width + x] == maskValue)
1498 for (
unsigned int n = 0u; n < tChannels; ++n)
1500 value[n] +=
Scalar(frame[tChannels * (y * width + x) + n]);
1508 if (samples >= minimalSamples)
1520 template <
unsigned int tChannels>
1523 ocean_assert(frame !=
nullptr && separationMask !=
nullptr);
1524 ocean_assert(lookupTableA !=
nullptr && !lookupTableA->
isEmpty());
1525 ocean_assert(lookupTableB !=
nullptr && lookupTableA->
sizeX() == lookupTableB->
sizeX() && lookupTableA->
sizeY() == lookupTableB->
sizeY());
1526 ocean_assert(minimalSamples >= 1u);
1528 ocean_assert(firstBin + numberBins <= lookupTableA->binsY());
1530 const unsigned int width = (
unsigned int)lookupTableA->
sizeX();
1532 for (
unsigned int yBin = firstBin; yBin < firstBin + numberBins; ++yBin)
1534 for (
unsigned int xBin = 0u; xBin < lookupTableA->
binsX(); ++xBin)
1536 const unsigned int left = (
unsigned int)lookupTableA->
binTopLeftX(xBin);
1537 const unsigned int top = (
unsigned int)lookupTableA->
binTopLeftY(yBin);
1539 const unsigned int right = (
unsigned int)lookupTableA->
binBottomRightX(xBin);
1540 const unsigned int bottom = (
unsigned int)lookupTableA->
binBottomRightY(yBin);
1544 unsigned int samplesA = 0u;
1545 unsigned int samplesB = 0u;
1547 for (
unsigned int y = top; y <= bottom; ++y)
1549 for (
unsigned int x = left; x <= right; ++x)
1551 if (separationMask[y * width + x] == separationMaskValue)
1553 for (
unsigned int n = 0u; n < tChannels; ++n)
1555 valueA[n] +=
Scalar(frame[tChannels * (y * width + x) + n]);
1562 for (
unsigned int n = 0u; n < tChannels; ++n)
1564 valueB[n] +=
Scalar(frame[tChannels * (y * width + x) + n]);
1572 if (samplesA >= minimalSamples)
1581 if (samplesB >= minimalSamples)
1593 template <
unsigned int tChannels>
1596 ocean_assert(frame !=
nullptr && mask !=
nullptr && separationMask !=
nullptr);
1597 ocean_assert(lookupTableA !=
nullptr && !lookupTableA->
isEmpty());
1598 ocean_assert(lookupTableB !=
nullptr && lookupTableA->
sizeX() == lookupTableB->
sizeX() && lookupTableA->
sizeY() == lookupTableB->
sizeY());
1599 ocean_assert(minimalSamples >= 1u);
1601 ocean_assert(firstBin + numberBins <= lookupTableA->binsY());
1603 const unsigned int width = (
unsigned int)lookupTableA->
sizeX();
1605 for (
unsigned int yBin = firstBin; yBin < firstBin + numberBins; ++yBin)
1607 for (
unsigned int xBin = 0u; xBin < lookupTableA->
binsX(); ++xBin)
1609 const unsigned int left = (
unsigned int)lookupTableA->
binTopLeftX(xBin);
1610 const unsigned int top = (
unsigned int)lookupTableA->
binTopLeftY(yBin);
1612 const unsigned int right = (
unsigned int)lookupTableA->
binBottomRightX(xBin);
1613 const unsigned int bottom = (
unsigned int)lookupTableA->
binBottomRightY(yBin);
1617 unsigned int samplesA = 0u;
1618 unsigned int samplesB = 0u;
1620 for (
unsigned int y = top; y <= bottom; ++y)
1622 for (
unsigned int x = left; x <= right; ++x)
1624 if (mask[y * width + x] == maskValue)
1626 if (separationMask[y * width + x] == separationMaskValue)
1628 for (
unsigned int n = 0u; n < tChannels; ++n)
1629 valueA[n] +=
Scalar(frame[tChannels * (y * width + x) + n]);
1635 for (
unsigned int n = 0u; n < tChannels; ++n)
1636 valueB[n] +=
Scalar(frame[tChannels * (y * width + x) + n]);
1644 if (samplesA >= minimalSamples)
1653 if (samplesB >= minimalSamples)
This class implements an advanced 2D lookup object with values at the bins' center positions defining...
Definition: Lookup2.h:424
bool bilinearValue(const TScalar x, const TScalar y, T &value) const
Applies a lookup for a specific position in this lookup object.
Definition: Lookup2.h:1468
void setBinCenterValue(const size_t binX, const size_t binY, const T &value, const bool isValid)
Sets the value of one specific lookup bin's center and defines whether this bin is valid.
Definition: Lookup2.h:1600
This class implements an bin adjustment object supporting an arbitrary number of data channels.
Definition: FrameColorAdjustment.h:41
Object operator-(const Object &object) const
Subtract operator subtracting two objects element by element.
Definition: FrameColorAdjustment.h:641
Scalar operator[](const unsigned int index) const
Index operator returning one element of this object.
Definition: FrameColorAdjustment.h:683
Object operator/(const Scalar value) const
Division operator dividing all elements of this object by a scalar.
Definition: FrameColorAdjustment.h:667
Object operator+(const Object &object) const
Add operator adding two objects element by element.
Definition: FrameColorAdjustment.h:628
Scalar objectValues_[tChannels]
The object's elements.
Definition: FrameColorAdjustment.h:113
Object operator*(const Scalar value) const
Multiplication operator multiplying all elements of this object by a scalar.
Definition: FrameColorAdjustment.h:654
Object()
Creates a new object with values set to zero.
Definition: FrameColorAdjustment.h:577
bool belowThreshold(const Scalar threshold) const
Returns whether the absolute value of each element of this object is below or equal to a specified th...
Definition: FrameColorAdjustment.h:612
This class implements color adjustment functions between frames.
Definition: FrameColorAdjustment.h:32
static void adjustFrameMaskBilinear8BitPerChannel(uint8_t *frame, const uint8_t *mask, const unsigned int framePaddingElements, const unsigned int maskPaddingElements, const LookupTable< tChannels > &lookupTable, const uint8_t maskValue, Worker *worker=nullptr)
Adjusts a frame by a given color adjustment lookup table while a mask specifies valid and invalid pix...
Definition: FrameColorAdjustment.h:781
static void determineAdjustmentLookupTable8BitPerChannel(const uint8_t *reference, const uint8_t *frame, const unsigned int referencePaddingElements, const unsigned int framePaddingElements, const Scalar threshold, LookupTable< tChannels > &lookupTable, Worker *worker=nullptr)
Determines the adjustment lookup table between two frames.
Definition: FrameColorAdjustment.h:731
static void adjustFrameMaskBilinearAdvanced8BitPerChannel(uint8_t *frame, const uint8_t *mask, const unsigned int framePaddingElements, const unsigned int maskPaddingElements, const AdvancedLookupTable< tChannels > &lookupTable, const uint8_t maskValue, Worker *worker=nullptr)
Adjusts a frame by a given color adjustment lookup table holding valid and invalid lookup bins while ...
Definition: FrameColorAdjustment.h:799
static bool adjustFrameBilinear(const Frame &reference, const Frame &referenceMask, Frame &frame, const Frame &frameMask, const unsigned int horizontalBins, const unsigned int verticalBins, const Scalar threshold=Scalar(20), const uint8_t maskValue=0xFF, Worker *worker=nullptr)
Adjusts the color values of one frame with respect to a given reference frame both showing almost the...
static void adjustFrameMaskBilinear8BitPerChannelSubset(uint8_t *frame, const uint8_t *mask, const unsigned int framePaddingElements, const unsigned int maskPaddingElements, const LookupTable< tChannels > *lookupTable, const uint8_t maskValue, const unsigned int firstRow, const unsigned int numberRows)
Adjusts a subset of a frame by a given color adjustment lookup table while a mask specifies valid and...
Definition: FrameColorAdjustment.h:1243
static void adjustFrameBilinear8BitPerChannel(const uint8_t *reference, const uint8_t *referenceMask, uint8_t *frame, const uint8_t *frameMask, const unsigned int width, const unsigned int height, const unsigned int referencePaddingElements, const unsigned int referenceMaskPaddingElements, const unsigned int framePaddingElements, const unsigned int frameMaskPaddingElements, const unsigned int horizontalBins, const unsigned int verticalBins, const Scalar threshold=Scalar(20), const uint8_t maskValue=0xFF, Worker *worker=nullptr)
Adjusts the color values of one frame with respect to a given reference frame both showing almost the...
Definition: FrameColorAdjustment.h:697
static void determineAdjustmentLookupTable8BitPerChannelSubset(const uint8_t *reference, const uint8_t *frame, const unsigned int referencePaddingElements, const unsigned int framePaddingElements, const Scalar threshold, LookupTable< tChannels > *lookupTable, unsigned int firstBin, const unsigned int numberBins)
Determines a subset of an adjustment lookup table between two frames.
Definition: FrameColorAdjustment.h:1013
static void determineMeanFrameMaskAdvanced8BitPerChannelSubset(const uint8_t *frame, const uint8_t *mask, AdvancedLookupTable< tChannels > *lookupTable, const uint8_t maskValue, const unsigned int minimalSamples, const unsigned int firstBin, const unsigned int numberBins)
Determines the mean color values for a subset of a given frame which may have valid and invalid pixel...
Definition: FrameColorAdjustment.h:1469
static void colorMatchingTransfer8BitPerChannelSubset(const uint8_t *frame, const uint8_t *mask, uint8_t *target, const unsigned int width, const unsigned int height, const Scalar *frameMean, const Scalar *frameStd, const Scalar *refMean, const Scalar *refStd, const unsigned int firstRow, const unsigned int numberRows, const uint8_t maskValue)
Compute color statistics for the source and target images.
Definition: FrameColorAdjustment.h:909
static void adjustFrameMaskBilinearAdvanced8BitPerChannelSubset(uint8_t *frame, const uint8_t *mask, const AdvancedLookupTable< tChannels > *lookupTable, const uint8_t maskValue, const unsigned int firstRow, const unsigned int numberRows)
Adjusts a subset of a frame by a given color adjustment lookup table while a mask specifies valid and...
Definition: FrameColorAdjustment.h:1281
static void adjustFrameMaskBilinearFilterAdvanced8BitPerChannel(const uint8_t *frame, const uint8_t *filterFrame, const uint8_t *mask, const uint8_t *filterMask, uint8_t *adjustedFrame, const AdvancedLookupTable< tChannels > &lookupTableA, const AdvancedLookupTable< tChannels > &lookupTableB, const uint8_t maskValue, Worker *worker=nullptr)
Adjusts a frame by two given color adjustment lookup table each holding valid and invalid lookup bins...
Definition: FrameColorAdjustment.h:873
static void colorMatchingTransfer(const uint8_t *frame, const uint8_t *mask, uint8_t *target, const unsigned int width, const unsigned int height, const std::vector< Scalar > &frameMean, const std::vector< Scalar > &frameStd, const std::vector< Scalar > &refMean, const std::vector< Scalar > &refStd, const uint8_t maskValue, Worker *worker=nullptr)
Adjust a color transfer algorithm that uses the mean and standard deviation of the image channels.
static void determineMeanFrameMaskAdvanced8BitPerChannel(const uint8_t *frame, const uint8_t *mask, AdvancedLookupTable< tChannels > &lookupTable, const uint8_t maskValue, const unsigned int minimalSamples, Worker *worker=nullptr)
Determines the mean color values of a given frame which may have valid and invalid pixels (specified ...
Definition: FrameColorAdjustment.h:954
static void adjustFrameBilinear8BitPerChannelSubset(uint8_t *frame, const unsigned int framePaddingElements, const LookupTable< tChannels > *lookupTable, const unsigned int firstRow, const unsigned int numberRows)
Adjusts a subset of a frame by a given color adjustment lookup table.
Definition: FrameColorAdjustment.h:1212
static Caller< void > createStatic(typename StaticFunctionPointerMaker< void, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass >::Type function)
Creates a new caller container for a static function with no function parameter.
Definition: Caller.h:2876
Template class allowing to define an array of data types.
Definition: DataType.h:27
This class implements Ocean's image class.
Definition: Frame.h:1792
size_t sizeY() const
Returns the vertical dimension of this lookup object.
Definition: Lookup2.h:947
size_t sizeX() const
Returns the horizontal dimension of this lookup object.
Definition: Lookup2.h:941
bool isEmpty() const
Returns whether this lookup object does not hold any lookup bin.
Definition: Lookup2.h:1009
size_t binsY() const
Returns the number of vertical bins of this lookup object.
Definition: Lookup2.h:959
size_t binsX() const
Returns the number of horizontal bins of this lookup object.
Definition: Lookup2.h:953
This class implements a 2D lookup object with values at the bins' center positions defining the indiv...
Definition: Lookup2.h:198
void setBinCenterValue(const size_t binX, const size_t binY, const T &value)
Sets the value of one specific lookup bin's center.
Definition: Lookup2.h:1380
size_t binTopLeftY(const size_t binY) const
Returns the vertical top left position of a specified bin with pixel accuracy.
Definition: Lookup2.h:1168
size_t binBottomRightY(const size_t binY) const
Returns the vertical bottom right position of a specified bin with pixel accuracy.
Definition: Lookup2.h:1192
size_t binBottomRightX(const size_t binX) const
Returns the horizontal bottom right position (including) of a specified bin with pixel accuracy.
Definition: Lookup2.h:1179
size_t binTopLeftX(const size_t binX) const
Returns the horizontal top left position of a specified bin with pixel accuracy.
Definition: Lookup2.h:1157
T bilinearValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object.
Definition: Lookup2.h:1260
static T abs(const T value)
Returns the absolute value of a given value.
Definition: Numeric.h:1220
static constexpr int32_t round32(const T value)
Returns the rounded 32 bit integer value of a given value.
Definition: Numeric.h:2064
static constexpr bool isNotEqualEps(const T value)
Returns whether a value is not smaller than or equal to a small epsilon.
Definition: Numeric.h:2237
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
bool executeFunction(const Function &function, const unsigned int first, const unsigned int size, const unsigned int firstIndex=(unsigned int)(-1), const unsigned int sizeIndex=(unsigned int)(-1), const unsigned int minimalIterations=1u, const unsigned int threadIndex=(unsigned int)(-1))
Executes a callback function separable by two function parameters.
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition: Math.h:144
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15
AutomaticDifferentiationT< T1, TNumeric1 > operator-(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition: AutomaticDifferentiation.h:484
AutomaticDifferentiationT< T1, TNumeric1 > operator/(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition: AutomaticDifferentiation.h:572
AutomaticDifferentiationT< T1, TNumeric1 > operator*(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition: AutomaticDifferentiation.h:524
AutomaticDifferentiationT< T1, TNumeric1 > operator+(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition: AutomaticDifferentiation.h:418