8#ifndef META_OCEAN_CV_ADVANCED_COLOR_CHANNEL_MAPPER_H
9#define META_OCEAN_CV_ADVANCED_COLOR_CHANNEL_MAPPER_H
102 template <
unsigned int tChannels>
103 static void applyLookup8BitsPerChannelSubset(uint8_t* frameData,
const unsigned int frameWidth,
const unsigned int frameHeight,
const unsigned int framePaddingElements,
const uint8_t* lookupData,
const unsigned int firstRow,
const unsigned int numberRows);
111template <
unsigned int tChannels>
128 ScaleOffsetMapping(
const float* scale,
const float* offset,
const float* gamma =
nullptr);
136 uint8_t
map(
const unsigned int channel,
const uint8_t input);
150template <
unsigned int tChannels>
153 for (
unsigned int c = 0u; c < tChannels; c++)
161template <
unsigned int tChannels>
164 for (
unsigned int c = 0; c < tChannels; c++)
169 offset_[c] = offset ==
nullptr ? 0.0f : offset[c];
174template <
unsigned int tChannels>
177 if (channel >= tChannels)
182 constexpr float inv255 = 1.0f / 255.0f;
187template <
unsigned int tChannels>
190 ocean_assert(frameData !=
nullptr && lookupData !=
nullptr);
191 ocean_assert(frameWidth > 0u && frameHeight > 0u);
192 ocean_assert_and_suppress_unused(numberRows <= frameHeight, frameHeight);
194 const unsigned int frameStrideElements = frameWidth * tChannels + framePaddingElements;
196 for (
unsigned int y = firstRow; y < firstRow + numberRows; ++y)
198 uint8_t* data = frameData + y * frameStrideElements;
200 for (
unsigned int x = 0u; x < frameWidth; ++x)
202 for (
unsigned int c = 0u; c < tChannels; c++)
204 *data = lookupData[*data * tChannels + c];
Provides methods for fast remapping of colors inside frames.
Definition ColorChannelMapper.h:34
static void applyLookup8BitsPerChannel(Frame &frame, const Frame &lookupFrame, Worker *worker=nullptr)
Maps the colors of the specified frame to new values using the specified look-up table.
static void mapScaleOffset(Frame &frame, const VectorF3 &scale, const VectorF3 &offset, const VectorF3 &gamma, Worker *worker=nullptr)
Performs a color scaling and offset operation on the specified image frame.
Callback< uint8_t, unsigned int, uint8_t > ColorChannelMapFunction
Callback function for color mapping First parameter: color channel index Second parameter: color chan...
Definition ColorChannelMapper.h:43
static void applyLookup8BitsPerChannelSubset(uint8_t *frameData, const unsigned int frameWidth, const unsigned int frameHeight, const unsigned int framePaddingElements, const uint8_t *lookupData, const unsigned int firstRow, const unsigned int numberRows)
Maps the colors of the specified frame to new values using the specified look-up table for a specifie...
Definition ColorChannelMapper.h:188
static void createLookupScaleOffset(const FrameType::PixelFormat &pixelFormat, Frame &lookupFrame, const VectorF3 &scale, const VectorF3 &offset, const VectorF3 &gamma)
Creates a lookup table for color scaling and offset operation.
static bool createLookup8BitsPerChannel(FrameType::PixelFormat pixelFormat, Frame &lookupFrame, const ColorChannelMapFunction &function)
Creates a look-up table using the specified color channel mapping function.
float gamma_[tChannels]
Specifies color scale factor for each color channel.
Definition ColorChannelMapper.h:141
float scale_[tChannels]
Specifies color scale factor for each color channel.
Definition ColorChannelMapper.h:144
float offset_[tChannels]
Specifies color offset for each color channel.
Definition ColorChannelMapper.h:147
uint8_t map(const unsigned int channel, const uint8_t input)
Maps a color value for the specified intensity index.
Definition ColorChannelMapper.h:175
ScaleOffsetMapping()
Creates a new instance with an identity mapping.
Definition ColorChannelMapper.h:151
This class implements a container for callback functions.
Definition Callback.h:3454
This class implements Ocean's image class.
Definition Frame.h:1969
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition Frame.h:183
static float pow(const float x, const float y)
static constexpr bool isAbove(const float value, const float lower, const float epsilon=NumericT< float >::eps())
static constexpr float eps()
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
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:973
VectorT3< float > VectorF3
Definition of a 3D vector with float values.
Definition Vector3.h:43
Namespace of the CV Advanced library.
Definition Advanced.h:20
Namespace of the CV library.
Definition Advanced.h:17
The namespace covering the entire Ocean framework.
Definition Accessor.h:15