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);
576template <
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);
587template <
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];
600template <
unsigned int tChannels>
603 static_assert(tChannels != 0u,
"Invalid channel number!");
605 for (
unsigned int n = 0u; n < tChannels; ++n)
607 objectValues_[n] = value;
611template <
unsigned int tChannels>
614 ocean_assert(threshold >= 0);
616 for (
unsigned int n = 0u; n < tChannels; ++n)
627template <
unsigned int tChannels>
632 for (
unsigned int n = 0u; n < tChannels; ++n)
640template <
unsigned int tChannels>
645 for (
unsigned int n = 0u; n < tChannels; ++n)
653template <
unsigned int tChannels>
658 for (
unsigned int n = 0u; n < tChannels; ++n)
666template <
unsigned int tChannels>
674 for (
unsigned int n = 0u; n < tChannels; ++n)
682template <
unsigned int tChannels>
685 ocean_assert(index < tChannels);
686 return objectValues_[index];
689template <
unsigned int tChannels>
692 ocean_assert(index < tChannels);
693 return objectValues_[index];
696template <
unsigned int tChannels>
697inline 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);
730template <
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()));
746template <
unsigned int tChannels,
bool tUseReferenceMask,
bool tUseFrameMask>
747inline 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()));
762template <
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()));
780template <
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()));
798template <
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()));
816template <
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()));
835template <
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()));
853template <
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()));
872template <
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()));
891template<
unsigned int tChannels>
892inline 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);
908template<
unsigned int tChannels>
909inline 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);
927 for (
unsigned int n = 0u; n < tChannels; ++n)
933 while (pixFrame != fEnd)
935 ocean_assert(pixFrame < fEnd);
936 if(*pixMask == maskValue)
938 for (
unsigned int n = 0u; n < tChannels; ++n)
940 Scalar colorTransValue = pixFrame[n];
941 colorTransValue -= frameMean[n];
942 colorTransValue *= scales[n];
943 colorTransValue += refMean[n];
944 target[n] = (uint8_t)(minmax<int>(0,
Numeric::round32(colorTransValue), 255));
949 for (
unsigned int n = 0u; n < tChannels; ++n)
951 target[n] = pixFrame[n];
956 pixFrame += tChannels;
961template <
unsigned int tChannels>
964 static_assert(tChannels != 0u,
"Invalid channel number!");
966 ocean_assert(frame !=
nullptr && mask !=
nullptr);
967 ocean_assert(!lookupTable.
isEmpty());
968 ocean_assert(minimalSamples >= 1u);
976 determineMeanFrameMaskAdvanced8BitPerChannelSubset<tChannels>(frame, mask, &lookupTable, maskValue, minimalSamples, 0u, (
unsigned int)(lookupTable.
binsY()));
980template <
unsigned int tChannels>
983 static_assert(tChannels != 0u,
"Invalid channel number!");
985 ocean_assert(frame !=
nullptr && separationMask !=
nullptr);
986 ocean_assert(!lookupTableA.
isEmpty());
987 ocean_assert(lookupTableA.
sizeX() == lookupTableB.
sizeX() && lookupTableA.
sizeY() == lookupTableB.
sizeY());
988 ocean_assert(minimalSamples >= 1u);
992 worker->
executeFunction(
Worker::Function::createStatic(&FrameColorAdjustment::determineMeanFrameMaskAdvanced8BitPerChannelSubset<tChannels>, frame, separationMask, &lookupTableA, &lookupTableB, separationMaskValue, minimalSamples, 0u, 0u), 0u, (
unsigned int)(lookupTableA.
binsY()));
996 determineMeanFrameMaskAdvanced8BitPerChannelSubset<tChannels>(frame, separationMask, &lookupTableA, &lookupTableB, separationMaskValue, minimalSamples, 0u, (
unsigned int)(lookupTableA.
binsY()));
1000template <
unsigned int tChannels>
1003 static_assert(tChannels != 0u,
"Invalid channel number!");
1005 ocean_assert(frame !=
nullptr && mask !=
nullptr && separationMask !=
nullptr);
1006 ocean_assert(!lookupTableA.
isEmpty());
1007 ocean_assert(lookupTableA.
sizeX() == lookupTableB.
sizeX() && lookupTableA.
sizeY() == lookupTableB.
sizeY());
1008 ocean_assert(minimalSamples >= 1u);
1012 worker->
executeFunction(
Worker::Function::createStatic(&FrameColorAdjustment::determineMeanFrameMaskAdvanced8BitPerChannelSubset<tChannels>, frame, mask, separationMask, &lookupTableA, &lookupTableB, maskValue, separationMaskValue, minimalSamples, 0u, 0u), 0u, (
unsigned int)(lookupTableA.
binsY()));
1016 determineMeanFrameMaskAdvanced8BitPerChannelSubset<tChannels>(frame, mask, separationMask, &lookupTableA, &lookupTableB, maskValue, separationMaskValue, minimalSamples, 0u, (
unsigned int)(lookupTableA.
binsY()));
1020template <
unsigned int tChannels>
1023 ocean_assert(reference !=
nullptr && frame !=
nullptr);
1024 ocean_assert(lookupTable !=
nullptr && !lookupTable->
isEmpty());
1026 const unsigned int widthElements = (
unsigned int)(lookupTable->
sizeX()) * tChannels;
1028 const unsigned int referenceStrideElements = widthElements + referencePaddingElements;
1029 const unsigned int frameStrideElements = widthElements + framePaddingElements;
1031 for (
unsigned int n = firstBin; n < firstBin + numberBins; ++n)
1033 const unsigned int binY = n / (
unsigned int)(lookupTable->
binsX());
1034 const unsigned int binX = n - binY * (
unsigned int)(lookupTable->
binsX());
1035 ocean_assert(binX == n % lookupTable->
binsX());
1037 const unsigned int left = (
unsigned int)(lookupTable->
binTopLeftX(binX));
1038 const unsigned int top = (
unsigned int)(lookupTable->
binTopLeftY(binY));
1040 const unsigned int right = (
unsigned int)(lookupTable->
binBottomRightX(binX));
1041 const unsigned int bottom = (
unsigned int)(lookupTable->
binBottomRightY(binY));
1045 const uint8_t* framePixel = frame + top * frameStrideElements + left * tChannels;
1046 const uint8_t* referencePixel = reference + top * referenceStrideElements + left * tChannels;
1048 const unsigned int binWidthElements = (right - left + 1u) * tChannels;
1049 ocean_assert(binWidthElements <= frameStrideElements && binWidthElements <= referenceStrideElements);
1051 const unsigned int frameRowOffset = frameStrideElements - binWidthElements;
1052 const unsigned int referenceRowOffset = referenceStrideElements - binWidthElements;
1054 for (
unsigned int y = top; y <= bottom; ++y)
1056 for (
unsigned int x = left; x <= right; ++x)
1058 for (
unsigned int i = 0u; i < tChannels; ++i)
1060 frameObject[i] += framePixel[i];
1063 for (
unsigned int i = 0u; i < tChannels; ++i)
1065 referenceObject[i] += referencePixel[i];
1068 framePixel += tChannels;
1069 referencePixel += tChannels;
1072 framePixel += frameRowOffset;
1073 referencePixel += referenceRowOffset;
1076 ocean_assert((right - left + 1u) * (bottom - top + 1u) != 0u);
1077 const Scalar normalization =
Scalar(1) /
Scalar((right - left + 1u) * (bottom - top + 1u));
1081 for (
unsigned int i = 0u; i < tChannels; ++i)
1083 object[i] = (referenceObject[i] - frameObject[i]) * normalization;
1086 if (
object.belowThreshold(threshold))
1097template <
unsigned int tChannels,
bool tUseReferenceMask,
bool tUseFrameMask>
1098inline 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)
1100 ocean_assert(reference !=
nullptr && frame !=
nullptr);
1101 ocean_assert(lookupTable !=
nullptr && !lookupTable->
isEmpty());
1103 const unsigned int widthElements = (
unsigned int)(lookupTable->
sizeX()) * tChannels;
1105 const unsigned int referenceStrideElements = widthElements + referencePaddingElements;
1106 const unsigned int referenceMaskStrideElements = (
unsigned int)(lookupTable->
sizeX()) + referenceMaskPaddingElements;
1108 const unsigned int frameStrideElements = widthElements + framePaddingElements;
1109 const unsigned int frameMaskStrideElements = (
unsigned int)(lookupTable->
sizeX()) + frameMaskPaddingElements;
1111 for (
unsigned int n = firstBin; n < firstBin + numberBins; ++n)
1113 const unsigned int binY = n / (
unsigned int)lookupTable->
binsX();
1114 const unsigned int binX = n - binY * (
unsigned int)lookupTable->
binsX();
1115 ocean_assert(binX == n % lookupTable->
binsX());
1117 const unsigned int left = (
unsigned int)lookupTable->
binTopLeftX(binX);
1118 const unsigned int top = (
unsigned int)lookupTable->
binTopLeftY(binY);
1120 const unsigned int right = (
unsigned int)lookupTable->
binBottomRightX(binX);
1121 const unsigned int bottom = (
unsigned int)lookupTable->
binBottomRightY(binY);
1125 unsigned int referenceCounter = 0u;
1126 unsigned int frameCounter = 0u;
1128 const uint8_t* framePixel = frame + top * frameStrideElements + left * tChannels;
1129 const uint8_t* frameMaskPixel = tUseFrameMask ? frameMask + top * frameMaskStrideElements + left :
nullptr;
1131 const uint8_t* referencePixel = reference + top * referenceStrideElements + left * tChannels;
1132 const uint8_t* referenceMaskPixel = tUseReferenceMask ? referenceMask + top * referenceMaskStrideElements + left :
nullptr;
1134 const unsigned int binWidthElements = (right - left + 1u) * tChannels;
1135 ocean_assert(binWidthElements <= frameStrideElements && binWidthElements <= referenceStrideElements);
1137 const unsigned int frameRowOffset = frameStrideElements - binWidthElements;
1138 const unsigned int frameMaskRowOffset = tUseFrameMask ? frameMaskStrideElements - (right - left + 1u) : 0u;
1140 const unsigned int referenceRowOffset = referenceStrideElements - binWidthElements;
1141 const unsigned int referenceMaskRowOffset = tUseReferenceMask ? referenceMaskStrideElements - (right - left + 1u) : 0u;
1143 for (
unsigned int y = top; y <= bottom; ++y)
1145 for (
unsigned int x = left; x <= right; ++x)
1147 if (!tUseFrameMask || *frameMaskPixel == maskValue)
1149 for (
unsigned int i = 0u; i < tChannels; ++i)
1151 frameObject[i] += framePixel[i];
1157 if (!tUseReferenceMask || *referenceMaskPixel == maskValue)
1159 for (
unsigned int i = 0u; i < tChannels; ++i)
1161 referenceObject[i] += referencePixel[i];
1167 framePixel += tChannels;
1168 referencePixel += tChannels;
1170 if constexpr (tUseFrameMask)
1175 if constexpr (tUseReferenceMask)
1177 ++referenceMaskPixel;
1181 framePixel += frameRowOffset;
1182 referencePixel += referenceRowOffset;
1184 if constexpr (tUseFrameMask)
1186 frameMaskPixel += frameMaskRowOffset;
1189 if constexpr (tUseReferenceMask)
1191 referenceMaskPixel += referenceMaskRowOffset;
1195 if (frameCounter != 0u && referenceCounter != 0u)
1202 for (
unsigned int i = 0u; i < tChannels; ++i)
1204 object[i] = referenceObject[i] * referenceNormalization - frameObject[i] * frameNormalization;
1207 if (
object.belowThreshold(threshold))
1219template <
unsigned int tChannels>
1222 static_assert(tChannels != 0u,
"Invalid channel number!");
1224 ocean_assert(frame !=
nullptr);
1225 ocean_assert(lookupTable !=
nullptr && !lookupTable->
isEmpty());
1226 ocean_assert(firstRow + numberRows <= lookupTable->sizeY());
1228 const unsigned int frameStrideElements = (
unsigned int)(lookupTable->
sizeX()) * tChannels + framePaddingElements;
1230 frame += firstRow * frameStrideElements;
1232 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
1234 for (
unsigned int x = 0u; x < (
unsigned int)(lookupTable->
sizeX()); ++x)
1238 for (
unsigned int n = 0u; n < tChannels; ++n)
1246 frame += framePaddingElements;
1250template <
unsigned int tChannels>
1253 static_assert(tChannels != 0u,
"Invalid channel number!");
1255 ocean_assert(frame !=
nullptr && mask !=
nullptr);
1256 ocean_assert(lookupTable !=
nullptr && !lookupTable->
isEmpty());
1257 ocean_assert(firstRow + numberRows <= lookupTable->sizeY());
1259 const unsigned int frameStrideElements = (
unsigned int)(lookupTable->
sizeX()) * tChannels + framePaddingElements;
1260 const unsigned int maskStrideElements = (
unsigned int)(lookupTable->
sizeX()) + maskPaddingElements;
1262 frame += firstRow * frameStrideElements;
1263 mask += firstRow * maskStrideElements;
1265 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
1267 for (
unsigned int x = 0u; x < (
unsigned int)lookupTable->
sizeX(); ++x)
1269 if (*mask == maskValue)
1273 for (
unsigned int n = 0u; n < tChannels; ++n)
1283 frame += framePaddingElements;
1284 mask += maskPaddingElements;
1288template <
unsigned int tChannels>
1291 static_assert(tChannels != 0u,
"Invalid channel number!");
1293 ocean_assert(frame !=
nullptr && mask !=
nullptr);
1294 ocean_assert(lookupTable !=
nullptr && !lookupTable->
isEmpty());
1295 ocean_assert(firstRow + numberRows <= lookupTable->sizeY());
1297 frame += firstRow * lookupTable->
sizeX() * tChannels;
1298 mask += firstRow * lookupTable->
sizeX();
1302 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
1304 for (
unsigned int x = 0u; x < (
unsigned int)lookupTable->
sizeX(); ++x)
1308 for (
unsigned int n = 0u; n < tChannels; ++n)
1320template <
unsigned int tChannels>
1323 static_assert(tChannels != 0u,
"Invalid channel number!");
1325 ocean_assert(frame !=
nullptr && mask !=
nullptr);
1326 ocean_assert(lookupTableA !=
nullptr && lookupTableB !=
nullptr && !lookupTableA->
isEmpty());
1327 ocean_assert(lookupTableA->
sizeX() == lookupTableB->
sizeX() && lookupTableA->
sizeY() == lookupTableB->
sizeY());
1328 ocean_assert(firstRow + numberRows <= lookupTableA->sizeY());
1330 frame += firstRow * lookupTableA->
sizeX() * tChannels;
1331 mask += firstRow * lookupTableA->
sizeX();
1335 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
1337 for (
unsigned int x = 0u; x < (
unsigned int)lookupTableA->
sizeX(); ++x)
1339 if (*mask == maskValue)
1343 for (
unsigned int n = 0u; n < tChannels; ++n)
1351 ocean_assert(*mask != maskValue);
1355 for (
unsigned int n = 0u; n < tChannels; ++n)
1368template <
unsigned int tChannels,
bool tCopyPixelForInval
idLookup>
1371 static_assert(tChannels != 0u,
"Invalid channel number!");
1373 ocean_assert(frame !=
nullptr && mask !=
nullptr && adjustedFrame !=
nullptr);
1374 ocean_assert(lookupTable !=
nullptr && !lookupTable->
isEmpty());
1375 ocean_assert(firstRow + numberRows <= lookupTable->sizeY());
1379 frame += firstRow * lookupTable->
sizeX() * tChannels;
1380 adjustedFrame += firstRow * lookupTable->
sizeX() * tChannels;
1381 mask += firstRow * lookupTable->
sizeX();
1385 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
1387 for (
unsigned int x = 0u; x < (
unsigned int)lookupTable->
sizeX(); ++x)
1389 if (*mask == maskValue)
1393 for (
unsigned int n = 0u; n < tChannels; ++n)
1400 if constexpr (tCopyPixelForInvalidLookup)
1402 *((PixelType*)adjustedFrame) = *((PixelType*)frame);
1408 adjustedFrame += tChannels;
1414template <
unsigned int tChannels,
bool tCopyPixelForInval
idLookup>
1417 static_assert(tChannels != 0u,
"Invalid channel number!");
1419 ocean_assert(frame !=
nullptr && mask !=
nullptr && adjustedFrame !=
nullptr);
1420 ocean_assert(lookupTableA !=
nullptr && lookupTableB !=
nullptr && !lookupTableA->
isEmpty());
1421 ocean_assert(lookupTableA->
sizeX() == lookupTableB->
sizeX() && lookupTableA->
sizeY() == lookupTableB->
sizeY());
1422 ocean_assert(firstRow + numberRows <= lookupTableA->sizeY());
1426 frame += firstRow * lookupTableA->
sizeX() * tChannels;
1427 adjustedFrame += firstRow * lookupTableA->
sizeX() * tChannels;
1428 mask += firstRow * lookupTableA->
sizeX();
1432 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
1434 for (
unsigned int x = 0u; x < (
unsigned int)(lookupTableA->
sizeX()); ++x)
1436 if (*mask == maskValue)
1441 for (
unsigned int n = 0u; n < tChannels; ++n)
1448 if constexpr (tCopyPixelForInvalidLookup)
1450 *((PixelType*)adjustedFrame) = *((PixelType*)frame);
1456 ocean_assert(*mask != maskValue);
1461 for (
unsigned int n = 0u; n < tChannels; ++n)
1468 if constexpr (tCopyPixelForInvalidLookup)
1470 *((PixelType*)adjustedFrame) = *((PixelType*)frame);
1476 adjustedFrame += tChannels;
1482template <
unsigned int tChannels>
1485 ocean_assert(frame !=
nullptr && mask !=
nullptr);
1486 ocean_assert(lookupTable !=
nullptr && !lookupTable->
isEmpty());
1487 ocean_assert(minimalSamples >= 1u);
1489 ocean_assert(firstBin + numberBins <= lookupTable->binsY());
1491 const unsigned int width = lookupTable->
sizeX();
1493 for (
unsigned int yBin = firstBin; yBin < firstBin + numberBins; ++yBin)
1495 for (
unsigned int xBin = 0u; xBin < lookupTable->
binsX(); ++xBin)
1497 const unsigned int left = (
unsigned int)lookupTable->
binTopLeftX(xBin);
1498 const unsigned int top = (
unsigned int)lookupTable->
binTopLeftY(yBin);
1500 const unsigned int right = (
unsigned int)lookupTable->
binBottomRightX(xBin);
1501 const unsigned int bottom = (
unsigned int)lookupTable->
binBottomRightY(yBin);
1504 unsigned int samples = 0u;
1506 for (
unsigned int y = top; y <= bottom; ++y)
1508 for (
unsigned int x = left; x <= right; ++x)
1510 if (mask[y * width + x] == maskValue)
1512 for (
unsigned int n = 0u; n < tChannels; ++n)
1514 value[n] +=
Scalar(frame[tChannels * (y * width + x) + n]);
1522 if (samples >= minimalSamples)
1534template <
unsigned int tChannels>
1537 ocean_assert(frame !=
nullptr && separationMask !=
nullptr);
1538 ocean_assert(lookupTableA !=
nullptr && !lookupTableA->
isEmpty());
1539 ocean_assert(lookupTableB !=
nullptr && lookupTableA->
sizeX() == lookupTableB->
sizeX() && lookupTableA->
sizeY() == lookupTableB->
sizeY());
1540 ocean_assert(minimalSamples >= 1u);
1542 ocean_assert(firstBin + numberBins <= lookupTableA->binsY());
1544 const unsigned int width = (
unsigned int)lookupTableA->
sizeX();
1546 for (
unsigned int yBin = firstBin; yBin < firstBin + numberBins; ++yBin)
1548 for (
unsigned int xBin = 0u; xBin < lookupTableA->
binsX(); ++xBin)
1550 const unsigned int left = (
unsigned int)lookupTableA->
binTopLeftX(xBin);
1551 const unsigned int top = (
unsigned int)lookupTableA->
binTopLeftY(yBin);
1553 const unsigned int right = (
unsigned int)lookupTableA->
binBottomRightX(xBin);
1554 const unsigned int bottom = (
unsigned int)lookupTableA->
binBottomRightY(yBin);
1558 unsigned int samplesA = 0u;
1559 unsigned int samplesB = 0u;
1561 for (
unsigned int y = top; y <= bottom; ++y)
1563 for (
unsigned int x = left; x <= right; ++x)
1565 if (separationMask[y * width + x] == separationMaskValue)
1567 for (
unsigned int n = 0u; n < tChannels; ++n)
1569 valueA[n] +=
Scalar(frame[tChannels * (y * width + x) + n]);
1576 for (
unsigned int n = 0u; n < tChannels; ++n)
1578 valueB[n] +=
Scalar(frame[tChannels * (y * width + x) + n]);
1586 if (samplesA >= minimalSamples)
1595 if (samplesB >= minimalSamples)
1607template <
unsigned int tChannels>
1610 ocean_assert(frame !=
nullptr && mask !=
nullptr && separationMask !=
nullptr);
1611 ocean_assert(lookupTableA !=
nullptr && !lookupTableA->
isEmpty());
1612 ocean_assert(lookupTableB !=
nullptr && lookupTableA->
sizeX() == lookupTableB->
sizeX() && lookupTableA->
sizeY() == lookupTableB->
sizeY());
1613 ocean_assert(minimalSamples >= 1u);
1615 ocean_assert(firstBin + numberBins <= lookupTableA->binsY());
1617 const unsigned int width = (
unsigned int)lookupTableA->
sizeX();
1619 for (
unsigned int yBin = firstBin; yBin < firstBin + numberBins; ++yBin)
1621 for (
unsigned int xBin = 0u; xBin < lookupTableA->
binsX(); ++xBin)
1623 const unsigned int left = (
unsigned int)lookupTableA->
binTopLeftX(xBin);
1624 const unsigned int top = (
unsigned int)lookupTableA->
binTopLeftY(yBin);
1626 const unsigned int right = (
unsigned int)lookupTableA->
binBottomRightX(xBin);
1627 const unsigned int bottom = (
unsigned int)lookupTableA->
binBottomRightY(yBin);
1631 unsigned int samplesA = 0u;
1632 unsigned int samplesB = 0u;
1634 for (
unsigned int y = top; y <= bottom; ++y)
1636 for (
unsigned int x = left; x <= right; ++x)
1638 if (mask[y * width + x] == maskValue)
1640 if (separationMask[y * width + x] == separationMaskValue)
1642 for (
unsigned int n = 0u; n < tChannels; ++n)
1644 valueA[n] +=
Scalar(frame[tChannels * (y * width + x) + n]);
1651 for (
unsigned int n = 0u; n < tChannels; ++n)
1653 valueB[n] +=
Scalar(frame[tChannels * (y * width + x) + n]);
1662 if (samplesA >= minimalSamples)
1671 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:1481
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:1613
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:1251
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:1021
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:1483
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:1289
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:962
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:1220
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:2877
This class implements Ocean's image class.
Definition Frame.h:1969
size_t sizeY() const
Returns the vertical dimension of this lookup object.
Definition Lookup2.h:960
size_t sizeX() const
Returns the horizontal dimension of this lookup object.
Definition Lookup2.h:954
bool isEmpty() const
Returns whether this lookup object does not hold any lookup bin.
Definition Lookup2.h:1022
size_t binsY() const
Returns the number of vertical bins of this lookup object.
Definition Lookup2.h:972
size_t binsX() const
Returns the number of horizontal bins of this lookup object.
Definition Lookup2.h:966
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:1393
size_t binTopLeftY(const size_t binY) const
Returns the vertical top left position of a specified bin with pixel accuracy.
Definition Lookup2.h:1181
size_t binBottomRightY(const size_t binY) const
Returns the vertical bottom right position of a specified bin with pixel accuracy.
Definition Lookup2.h:1205
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:1192
size_t binTopLeftX(const size_t binX) const
Returns the horizontal top left position of a specified bin with pixel accuracy.
Definition Lookup2.h:1170
T bilinearValue(const TScalar x, const TScalar y) const
Applies a lookup for a specific position in this lookup object.
Definition Lookup2.h:1273
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:2073
static constexpr T ratio(const T nominator, const T denominator, const T fallback=T(1))
Returns the ratio between two values if the denominator is not equal a small epsilon.
Definition Numeric.h:2085
static constexpr bool isNotEqualEps(const T value)
Returns whether a value is not smaller than or equal to a small epsilon.
Definition Numeric.h:2246
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:129
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition Math.h:145
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:528
AutomaticDifferentiationT< T1, TNumeric1 > operator+(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:417
AutomaticDifferentiationT< T1, TNumeric1 > operator/(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:576
AutomaticDifferentiationT< T1, TNumeric1 > operator-(const T2 &left, const AutomaticDifferentiationT< T1, TNumeric1 > &right)
Definition AutomaticDifferentiation.h:483
Default definition of a type with tBytes bytes.
Definition DataType.h:32