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++)
 
  168        scale_[c] = scale[c];
 
  169        offset_[c] = offset == 
nullptr ? 0.0f : offset[c];
 
  170        gamma_[c] = gamma == 
nullptr ? 1.0f : max(
NumericF::eps(), gamma[c]);
 
 
  174template <
unsigned int tChannels>
 
  177    if (channel >= tChannels)
 
  182    constexpr float inv255 = 1.0f / 255.0f;
 
  184    return uint8_t(minmax<int>(0u, 
int(((
NumericF::pow(input * inv255, gamma_[channel]) * scale_[channel]) + offset_[channel]) * 255.0f + 0.5f), 255u));
 
 
  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.
 
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.
 
Defines a scaling and offset color channel mapping.
Definition ColorChannelMapper.h:113
 
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:1808
 
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition Frame.h:183
 
static T pow(const T x, const T y)
Returns x raised to the power of y.
Definition Numeric.h:1860
 
static constexpr bool isAbove(const T value, const T lower, const T epsilon=NumericT< T >::eps())
Returns whether a parameter lies on or above a given border tolerating a small epsilon.
Definition Numeric.h:2940
 
static constexpr T eps()
Returns a small epsilon.
 
This class implements a vector with three elements.
Definition Vector3.h:97
 
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
 
The namespace covering the entire Ocean framework.
Definition Accessor.h:15