8 #ifndef META_OCEAN_CV_FRAME_NORMALIZER_H
9 #define META_OCEAN_CV_FRAME_NORMALIZER_H
194 template <
typename T>
195 static void normalize1ChannelToUint8(
const T* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
221 template <
typename TSource,
typename TTarget,
unsigned int tChannels>
222 static void normalizeToFloat(
const TSource* source, TTarget* target,
const unsigned int width,
const unsigned int height,
const TTarget* bias,
const TTarget* scale,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
237 template <
typename T>
238 static void normalizeLogarithm1ChannelToUint8(
const T* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const Scalar octaves,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
253 template <
typename TSource,
typename TTarget>
254 static void normalizeLogarithm1ChannelToFloat(
const TSource* source, TTarget* target,
const unsigned int width,
const unsigned int height,
const Scalar octaves,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
269 template <
typename T>
270 static inline void normalize1ChannelIntegerToUint8(
const T* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
283 template <
typename T>
284 static inline void normalize1ChannelFloatToUint8(
const T* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
311 template <
typename TSource,
typename TTarget>
312 static bool normalizeToFloat(
const TSource* source, TTarget* target,
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const TTarget* bias,
const TTarget* scale,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker =
nullptr);
328 template <
typename T>
329 static void normalize1ChannelIntegerToUint8Subset(
const T* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const T minimalValue,
const typename UnsignedTyper<T>::Type range,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows);
346 template <
typename T,
typename TRange>
347 static void normalize1ChannelFloatToUint8Subset(
const T* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const T minimalValue,
const TRange range,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows);
365 template <
typename TSource,
typename TTarget,
unsigned int tChannels>
366 static void normalizeToFloatSubset(
const TSource* source, TTarget* target,
const unsigned int width,
const unsigned int height,
const TTarget* bias,
const TTarget* scale,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows);
384 template <
typename T,
typename TRange>
385 static void normalizeLogarithm1ChannelToUint8Subset(
const T* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const Scalar octaves,
const T minimalValue,
const TRange range,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows);
403 template <
typename TSource,
typename TTarget>
404 static void normalizeLogarithm1ChannelToFloatSubset(
const TSource* source, TTarget* target,
const unsigned int width,
const unsigned int height,
const Scalar octaves,
const TTarget minimalValue,
const TTarget range,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows);
411 template <
typename T>
412 static inline T epsilon();
436 template <
typename T>
439 normalize1ChannelIntegerToUint8<T>(source, target, width, height, sourcePaddingElements, targetPaddingElements, worker);
442 template <
typename TSource,
typename TTarget,
unsigned int tChannels>
443 void FrameNormalizer::normalizeToFloat(
const TSource* source, TTarget* target,
const unsigned int width,
const unsigned int height,
const TTarget* bias,
const TTarget* scale,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker)
445 static_assert(std::is_floating_point<TTarget>::value,
"Invalid data type!");
446 static_assert(tChannels != 0u,
"Invalid number of channels");
448 ocean_assert(source !=
nullptr && target !=
nullptr);
449 ocean_assert(width >= 1u && height >= 1u);
451 TTarget localBias[tChannels];
452 TTarget localScale[tChannels];
454 const TTarget* biasPtr =
nullptr;
455 const TTarget* scalePtr =
nullptr;
457 if (bias !=
nullptr && scale !=
nullptr)
464 TSource minimalValues[tChannels];
465 TSource maximalValues[tChannels];
469 for (
unsigned int c = 0u; c < tChannels; ++c)
471 localBias[c] = -TTarget(minimalValues[c]);
472 localScale[c] = TTarget(1) / max(epsilon<TTarget>(), TTarget(maximalValues[c]) - TTarget(minimalValues[c]));
476 scalePtr = localScale;
479 ocean_assert(biasPtr !=
nullptr && scalePtr !=
nullptr);
481 if (worker !=
nullptr)
483 worker->
executeFunction(
Worker::Function::createStatic(normalizeToFloatSubset<TSource, TTarget, tChannels>, source, target, width, height, biasPtr, scalePtr, sourcePaddingElements, targetPaddingElements, 0u, 0u), 0u, height, 8u, 9u, 20u);
487 normalizeToFloatSubset<TSource, TTarget, tChannels>(source, target, width, height, biasPtr, scalePtr, sourcePaddingElements, targetPaddingElements, 0u, height);
492 inline void FrameNormalizer::normalize1ChannelToUint8<float>(
const float* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker)
494 normalize1ChannelFloatToUint8<float>(source, target, width, height, sourcePaddingElements, targetPaddingElements, worker);
498 inline void FrameNormalizer::normalize1ChannelToUint8<double>(
const double* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker)
500 normalize1ChannelFloatToUint8<double>(source, target, width, height, sourcePaddingElements, targetPaddingElements, worker);
503 template <
typename T>
506 ocean_assert(source !=
nullptr && target !=
nullptr);
507 ocean_assert(octaves > 0 && octaves <= 10);
514 if (std::is_same<T, double>::value ||
double(maximalValue) - double(minimalValue) >= 1.0e6)
516 const double range = max(epsilon<double>(),
double(maximalValue) -
double(minimalValue));
518 if (worker !=
nullptr)
520 worker->
executeFunction(
Worker::Function::createStatic(normalizeLogarithm1ChannelToUint8Subset<T, double>, source, target, width, height,
minmax(
Numeric::eps(), octaves,
Scalar(10)), minimalValue, range, sourcePaddingElements, targetPaddingElements, 0u, 0u), 0u, height, 9u, 10u, 20u);
524 normalizeLogarithm1ChannelToUint8Subset<T, double>(source, target, width, height,
minmax(
Numeric::eps(), octaves,
Scalar(10)), minimalValue, range, sourcePaddingElements, targetPaddingElements, 0u, height);
529 const T range = max(epsilon<T>(), T(maximalValue - minimalValue));
531 if (worker !=
nullptr)
533 worker->
executeFunction(
Worker::Function::createStatic(normalizeLogarithm1ChannelToUint8Subset<T, T>, source, target, width, height,
minmax(
Numeric::eps(), octaves,
Scalar(10)), minimalValue, range, sourcePaddingElements, targetPaddingElements, 0u, 0u), 0u, height, 9u, 10u, 20u);
537 normalizeLogarithm1ChannelToUint8Subset<T, T>(source, target, width, height,
minmax(
Numeric::eps(), octaves,
Scalar(10)), minimalValue, range, sourcePaddingElements, targetPaddingElements, 0u, height);
542 template <
typename TSource,
typename TTarget>
545 static_assert(std::is_floating_point<TTarget>::value,
"Invalid data type!");
547 ocean_assert(source !=
nullptr && target !=
nullptr);
548 ocean_assert(octaves > 0 && octaves <= 10);
555 const TTarget range = max(epsilon<TTarget>(), TTarget(maximalValue) - TTarget(minimalValue));
557 if (worker !=
nullptr)
559 worker->
executeFunction(
Worker::Function::createStatic(normalizeLogarithm1ChannelToFloatSubset<TSource, TTarget>, source, target, width, height,
minmax(
Numeric::eps(), octaves,
Scalar(10)), TTarget(minimalValue), range, sourcePaddingElements, targetPaddingElements, 0u, 0u), 0u, height, 9u, 10u, 20u);
563 normalizeLogarithm1ChannelToFloatSubset<TSource, TTarget>(source, target, width, height,
minmax(
Numeric::eps(), octaves,
Scalar(10)), TTarget(minimalValue), range, sourcePaddingElements, targetPaddingElements, 0u, height);
567 template <
typename T>
570 static_assert(!std::is_floating_point<T>::value,
"Invalid data type!");
572 ocean_assert(source !=
nullptr && target !=
nullptr);
573 ocean_assert(width >= 1u && height >= 1u);
578 FrameMinMax::determineMinMaxValues<T, 1u>(source, width, height, sourcePaddingElements, &minimalValue, &maximalValue, worker);
589 if (worker !=
nullptr)
591 worker->
executeFunction(
Worker::Function::createStatic(normalize1ChannelIntegerToUint8Subset<T>, source, target, width, height, minimalValue, range, sourcePaddingElements, targetPaddingElements, 0u, 0u), 0u, height, 8u, 9u, 20u);
595 normalize1ChannelIntegerToUint8Subset<T>(source, target, width, height, minimalValue, range, sourcePaddingElements, targetPaddingElements, 0u, height);
600 template <
typename T>
603 static_assert(std::is_floating_point<T>::value,
"Invalid data type!");
605 ocean_assert(source !=
nullptr && target !=
nullptr);
606 ocean_assert(width >= 1u && height >= 1u);
613 if (std::is_same<T, double>::value ||
double(maximalValue) - double(minimalValue) >= 1.0e6)
615 const double range = max(epsilon<double>(),
double(maximalValue) -
double(minimalValue));
617 if (worker !=
nullptr)
619 worker->
executeFunction(
Worker::Function::createStatic(normalize1ChannelFloatToUint8Subset<T, double>, source, target, width, height, minimalValue, range, sourcePaddingElements, targetPaddingElements, 0u, 0u), 0u, height, 8u, 9u, 20u);
623 normalize1ChannelFloatToUint8Subset<T, double>(source, target, width, height, minimalValue, range, sourcePaddingElements, targetPaddingElements, 0u, height);
628 const T range = max(epsilon<T>(), T(maximalValue - minimalValue));
630 if (worker !=
nullptr)
632 worker->
executeFunction(
Worker::Function::createStatic(normalize1ChannelFloatToUint8Subset<T, T>, source, target, width, height, minimalValue, range, sourcePaddingElements, targetPaddingElements, 0u, 0u), 0u, height, 8u, 9u, 20u);
636 normalize1ChannelFloatToUint8Subset<T, T>(source, target, width, height, minimalValue, range, sourcePaddingElements, targetPaddingElements, 0u, height);
641 template <
typename TSource,
typename TTarget>
642 bool FrameNormalizer::normalizeToFloat(
const TSource* source, TTarget* target,
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const TTarget* bias,
const TTarget* scale,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
Worker* worker)
644 ocean_assert(channels != 0u && channels <= 4u);
649 normalizeToFloat<TSource, TTarget, 1u>(source, target, width, height, bias, scale, sourcePaddingElements, targetPaddingElements, worker);
653 normalizeToFloat<TSource, TTarget, 2u>(source, target, width, height, bias, scale, sourcePaddingElements, targetPaddingElements, worker);
657 normalizeToFloat<TSource, TTarget, 3u>(source, target, width, height, bias, scale, sourcePaddingElements, targetPaddingElements, worker);
661 normalizeToFloat<TSource, TTarget, 4u>(source, target, width, height, bias, scale, sourcePaddingElements, targetPaddingElements, worker);
665 ocean_assert(
false &&
"Invalid number of channels!");
669 ocean_assert(
false &&
"Should never be here");
673 template <
typename T>
675 #if defined(OCEAN_CLANG_VERSION) && OCEAN_CLANG_VERSION > 0
676 __attribute__((no_sanitize(
"signed-integer-overflow")))
679 static_assert(!std::is_floating_point<T>::value,
"Invalid data type!");
681 ocean_assert(source !=
nullptr && target !=
nullptr);
682 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
684 const unsigned int sourceStrideElements = width + sourcePaddingElements;
685 const unsigned int targetStrideElements = width + targetPaddingElements;
690 const NextLargerUnsignedType range_2 = NextLargerUnsignedType(range) / NextLargerUnsignedType(2);
692 source += firstRow * sourceStrideElements;
693 target += firstRow * targetStrideElements;
695 for (
unsigned int nRow = firstRow; nRow < firstRow + numberRows; ++nRow)
697 for (
unsigned int x = 0u; x < width; ++x)
699 ocean_assert((std::is_same<T, uint64_t>::value || std::is_same<T, int64_t>::value) || (
double(*source) >=
double(minimalValue) &&
double(*source) <=
double(minimalValue) +
double(range)));
700 ocean_assert(
double(NextLargerUnsignedType(UnsignedType(*source - minimalValue)) * NextLargerUnsignedType(0xFF) + range_2) /
double(NextLargerUnsignedType(range)) >= 0.0);
701 ocean_assert(
double(NextLargerUnsignedType(UnsignedType(*source - minimalValue)) * NextLargerUnsignedType(0xFF) + range_2) /
double(NextLargerUnsignedType(range)) < 256.0);
703 *target++ = uint8_t((NextLargerUnsignedType(UnsignedType(*source++ - minimalValue)) * NextLargerUnsignedType(0xFF) + range_2) / NextLargerUnsignedType(range));
706 source += sourcePaddingElements;
707 target += targetPaddingElements;
711 template <
typename T,
typename TRange>
712 void FrameNormalizer::normalize1ChannelFloatToUint8Subset(
const T* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const T minimalValue,
const TRange range,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows)
714 static_assert(std::is_floating_point<TRange>::value,
"Invalid data type!");
715 static_assert(
sizeof(T) <=
sizeof(TRange),
"TRange range must not be smaller than T");
717 ocean_assert(source !=
nullptr && target !=
nullptr);
718 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
720 const unsigned int sourceStrideElements = width + sourcePaddingElements;
721 const unsigned int targetStrideElements = width + targetPaddingElements;
730 const TRange invRange = TRange(255.999) / range;
732 const TRange maxValueThreshold = TRange(minimalValue) + range + range * TRange(0.0001);
734 source += firstRow * sourceStrideElements;
735 target += firstRow * targetStrideElements;
737 for (
unsigned int nRow = firstRow; nRow < firstRow + numberRows; ++nRow)
739 for (
unsigned int x = 0u; x < width; ++x)
745 *target = uint8_t(255);
749 *target = uint8_t(0);
754 ocean_assert_and_suppress_unused(*source >= minimalValue && *source <= maxValueThreshold, maxValueThreshold);
756 const TRange normalizedValue = TRange(*source - minimalValue) * invRange;
758 ocean_assert(normalizedValue >= TRange(0));
759 ocean_assert(normalizedValue < TRange(256));
761 *target = uint8_t(normalizedValue);
768 source += sourcePaddingElements;
769 target += targetPaddingElements;
773 template <
typename TSource,
typename TTarget,
unsigned int tChannels>
774 void FrameNormalizer::normalizeToFloatSubset(
const TSource* source, TTarget* target,
const unsigned int width,
const unsigned int height,
const TTarget* bias,
const TTarget* scale,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows)
776 static_assert(std::is_floating_point<TTarget>::value,
"Invalid data type!");
777 static_assert(tChannels != 0u,
"Invalid number of channels");
779 ocean_assert(source !=
nullptr && target !=
nullptr);
780 ocean_assert(width >= 1u && height >= 1u);
781 ocean_assert(bias !=
nullptr && scale !=
nullptr);
782 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
784 const unsigned int sourceStrideElements = width * tChannels + sourcePaddingElements;
785 const unsigned int targetStrideElements = width * tChannels + targetPaddingElements;
787 source += firstRow * sourceStrideElements;
788 target += firstRow * targetStrideElements;
790 for (
unsigned int nRow = firstRow; nRow < firstRow + numberRows; ++nRow)
792 for (
unsigned int x = 0u; x < width; ++x)
794 for (
unsigned int c = 0u; c < tChannels; ++c)
798 *target = TTarget(*source);
802 *target = (TTarget(*source) + bias[c]) * scale[c];
810 source += sourcePaddingElements;
811 target += targetPaddingElements;
815 template <
typename T,
typename TRange>
816 void FrameNormalizer::normalizeLogarithm1ChannelToUint8Subset(
const T* source, uint8_t* target,
const unsigned int width,
const unsigned int height,
const Scalar octaves,
const T minimalValue,
const TRange range,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows)
818 ocean_assert(octaves > 0 && octaves <= 10);
819 ocean_assert(source && target);
820 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
824 const unsigned int sourceStrideElements = width + sourcePaddingElements;
825 const unsigned int targetStrideElements = width + targetPaddingElements;
830 source += firstRow * sourceStrideElements;
831 target += firstRow * targetStrideElements;
833 for (
unsigned int nRow = firstRow; nRow < firstRow + numberRows; ++nRow)
835 for (
unsigned int x = 0u; x < width; ++x)
841 *target = uint8_t(255);
845 *target = uint8_t(0);
861 source += sourcePaddingElements;
862 target += targetPaddingElements;
866 template <
typename TSource,
typename TTarget>
867 void FrameNormalizer::normalizeLogarithm1ChannelToFloatSubset(
const TSource* source, TTarget* target,
const unsigned int width,
const unsigned int height,
const Scalar octaves,
const TTarget minimalValue,
const TTarget range,
const unsigned int sourcePaddingElements,
const unsigned int targetPaddingElements,
const unsigned int firstRow,
const unsigned int numberRows)
869 static_assert(std::is_floating_point<TTarget>::value,
"Invalid data type!");
871 ocean_assert(octaves > 0 && octaves <= 10);
872 ocean_assert(source && target);
873 ocean_assert_and_suppress_unused(firstRow + numberRows <= height, height);
875 const unsigned int sourceStrideElements = width + sourcePaddingElements;
876 const unsigned int targetStrideElements = width + targetPaddingElements;
878 const TTarget factor = TTarget(
Numeric::pow(10, octaves) - 1) / TTarget(range);
879 const TTarget normalization = TTarget(1) / TTarget(octaves);
881 source += firstRow * sourceStrideElements;
882 target += firstRow * targetStrideElements;
884 for (
unsigned int nRow = firstRow; nRow < firstRow + numberRows; ++nRow)
886 for (
unsigned int x = 0u; x < width; ++x)
890 *target = TTarget(*source);
894 ocean_assert(TTarget(*source) >= minimalValue && TTarget(*source) <= minimalValue + range +
NumericT<TTarget>::eps());
895 ocean_assert(
NumericT<TTarget>::log10(TTarget(1) + (TTarget(*source) - minimalValue) * factor) * normalization >= TTarget(0));
905 source += sourcePaddingElements;
906 target += targetPaddingElements;
910 template <
typename T>
917 inline float FrameNormalizer::epsilon<float>()
923 inline double FrameNormalizer::epsilon<double>()
static void determineMinMaxValues(const T *frame, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements, T *minimalValues, T *maximalValues, Worker *worker=nullptr)
Determines the minimal and maximal pixel values in a given frame.
Definition: FrameMinMax.h:544
This class implements functions normalizing frames.
Definition: FrameNormalizer.h:34
static bool normalizeToUint8(Frame &frame, Worker *worker=nullptr)
Normalizes a given 1-channel frame linearly to a uint8 image.
static void normalizeLogarithm1ChannelToFloat(const TSource *source, TTarget *target, const unsigned int width, const unsigned int height, const Scalar octaves, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Normalizes a given 1 channel frame to float values with value range [0, 1] logarithmically.
Definition: FrameNormalizer.h:543
static bool normalizeToFloat32(const Frame &source, Frame &target, Worker *worker=nullptr)
Normalizes each channel of a frame linearly to a float32 image to the range [0, 1].
static void normalize1ChannelFloatToUint8(const T *source, uint8_t *target, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Normalizes a given 1 channel float frame to the 8 bit value range [0, 255] linearly.
Definition: FrameNormalizer.h:601
static void normalizeLogarithm1ChannelToUint8Subset(const T *source, uint8_t *target, const unsigned int width, const unsigned int height, const Scalar octaves, const T minimalValue, const TRange range, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
Normalizes a subset of a given 1 channel frame to the 8 bit value range [0, 255] logarithmically.
Definition: FrameNormalizer.h:816
static void normalize1ChannelIntegerToUint8(const T *source, uint8_t *target, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Normalizes a given 1 channel integer frame to the 8 bit value range [0, 255] linearly.
Definition: FrameNormalizer.h:568
static void normalize1ChannelIntegerToUint8Subset(const T *source, uint8_t *target, const unsigned int width, const unsigned int height, const T minimalValue, const typename UnsignedTyper< T >::Type range, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
Normalizes a subset of a given 1 channel frame to the 8 bit value range [0, 255] linearly.
Definition: FrameNormalizer.h:674
static void normalize1ChannelToUint8(const T *source, uint8_t *target, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Normalizes a given 1 channel frame to the 8 bit value range [0, 255] linearly.
Definition: FrameNormalizer.h:437
static bool normalizeToFloat32(const Frame &source, Frame &target, const float *bias, const float *scale, Worker *worker=nullptr)
Normalizes a given frame linearly to a float32 image.
static T epsilon()
Returns the smallest epsilon larger than zero for a specific data type.
Definition: FrameNormalizer.h:911
static void normalizeToFloat(const TSource *source, TTarget *target, const unsigned int width, const unsigned int height, const TTarget *bias, const TTarget *scale, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Normalizes a frame to float values by using predefined per-channel bias and scaling values.
Definition: FrameNormalizer.h:443
static bool normalizeLogarithmToFloat32(Frame &frame, const Scalar octaves=5.0f, Worker *worker=nullptr)
Normalizes a given frame linearly to a float32 image.
static bool normalizeToFloat32(Frame &frame, Worker *worker=nullptr)
Normalizes a given 1-channel frame linearly to a float32 image.
static void normalizeToFloatSubset(const TSource *source, TTarget *target, const unsigned int width, const unsigned int height, const TTarget *bias, const TTarget *scale, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
Normalizes a subset of rows of a frame to float values by using predefined per-channel bias and scali...
Definition: FrameNormalizer.h:774
static bool normalizeLogarithmToUint8(Frame &frame, const Scalar octaves=5.0f, Worker *worker=nullptr)
Normalizes a given frame linearly to a uint8 image.
static bool normalizeLogarithmToUint8(const Frame &source, Frame &target, const Scalar octaves=5.0f, Worker *worker=nullptr)
Normalizes a given frame logarithmically to a uint8 image.
static void normalizeLogarithm1ChannelToUint8(const T *source, uint8_t *target, const unsigned int width, const unsigned int height, const Scalar octaves, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, Worker *worker=nullptr)
Normalizes a given 1 channel frame to the 8 bit value range [0, 255] logarithmically.
Definition: FrameNormalizer.h:504
static bool normalizeToUint8(const Frame &source, Frame &target, Worker *worker=nullptr)
Normalizes a given 1-channel frame linearly to a uint8 image.
static bool normalizeLogarithmToFloat32(const Frame &source, Frame &target, const Scalar octaves=5.0f, Worker *worker=nullptr)
Normalizes a given frame logarithmically to a float32 image.
static void normalizeLogarithm1ChannelToFloatSubset(const TSource *source, TTarget *target, const unsigned int width, const unsigned int height, const Scalar octaves, const TTarget minimalValue, const TTarget range, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
Normalizes a subset of a given 1 channel frame to the value range [0, 1] logarithmically.
Definition: FrameNormalizer.h:867
static void normalize1ChannelFloatToUint8Subset(const T *source, uint8_t *target, const unsigned int width, const unsigned int height, const T minimalValue, const TRange range, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int firstRow, const unsigned int numberRows)
Normalizes a subset of a given 1 channel frame to the 8 bit value range [0, 255] linearly.
Definition: FrameNormalizer.h:712
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
This class implements Ocean's image class.
Definition: Frame.h:1792
@ CM_USE_KEEP_LAYOUT
The source memory is used only, no copy is created, the padding layout is preserved.
Definition: Frame.h:1801
bool setValue(const uint8_t value, const unsigned int planeIndex=0u, const bool skipPaddingData=true)
Sets the memory of the frame to a specified byte value (the memory of one plane).
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition: Frame.h:30
@ FORMAT_Y8
Pixel format for grayscale images with byte order Y and 8 bits per pixel.
Definition: Frame.h:594
@ ORIGIN_UPPER_LEFT
The first pixel lies in the upper left corner, the last pixel in the lower right corner.
Definition: Frame.h:1050
T Type
Definition of the data type for the next larger data type.
Definition: DataType.h:255
This class provides basic numeric functionalities.
Definition: Numeric.h:57
static constexpr T minValue()
Returns the min scalar value.
Definition: Numeric.h:3250
static T pow(const T x, const T y)
Returns x raised to the power of y.
Definition: Numeric.h:1860
static T log10(const T value)
Returns the logarithm to base 10 of a given value.
Definition: Numeric.h:1711
static constexpr T eps()
Returns a small epsilon.
static constexpr T maxValue()
Returns the max scalar value.
Definition: Numeric.h:3244
T Type
Definition of the unsigned data type, if existing.
Definition: DataType.h:339
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.
T minmax(const T &lowerBoundary, const T &value, const T &upperBoundary)
This function fits a given parameter into a specified value range.
Definition: base/Utilities.h:903
float Scalar
Definition of a scalar type.
Definition: Math.h:128
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15
float Type
Definition: FrameNormalizer.h:433
double Type
Definition: FrameNormalizer.h:427
Helper struct allowing to determine the type able to store data multiplied by 255.
Definition: FrameNormalizer.h:54
NextLargerTyper< T >::Type Type
The matching datatype which is able to store all values in T multiplied by 255.
Definition: FrameNormalizer.h:56
double Type
Definition: FrameNormalizer.h:421
Helper struct allowing to determine the necessary float type for a given data type.
Definition: FrameNormalizer.h:43
float Type
The matching float type for T, is double if T is double, otherwise always float.
Definition: FrameNormalizer.h:45