IRSOL
C++ code implementing socket server for interacting with Baumer camera.
irsol::camera::PixelConversion< SourceBitDepth, TargetBitDepth > Struct Template Reference

Helper to convert pixel values from one bit depth to another with scaling. More...

#include <pixel_format.hpp>

Static Public Member Functions

static Pixel< TargetBitDepth >::representation scale (typename Pixel< SourceBitDepth >::representation value)
 Scales a pixel value from source bit depth to target bit depth.
 

Static Public Attributes

static constexpr double factor
 Compile-time scaling factor: max(Target) / max(Source)
 

Detailed Description

template<uint8_t SourceBitDepth, uint8_t TargetBitDepth>
struct irsol::camera::PixelConversion< SourceBitDepth, TargetBitDepth >

Helper to convert pixel values from one bit depth to another with scaling.

This template computes a scaling factor at compile time to convert pixel values from SourceBitDepth to TargetBitDepth by linearly mapping the value ranges.

Example usage:

using SourcePixel = Pixel<12>;
using TargetPixel = Pixel<16>;
auto scaledValue = PixelConversion<12, 16>::scale(sourceValue);
static Pixel< TargetBitDepth >::representation scale(typename Pixel< SourceBitDepth >::representation value)
Scales a pixel value from source bit depth to target bit depth.
Represents a pixel with a given bit depth.
Template Parameters
SourceBitDepthBit depth of the input pixel value.
TargetBitDepthBit depth of the output pixel value.

Definition at line 122 of file pixel_format.hpp.

Member Function Documentation

◆ scale()

template<uint8_t SourceBitDepth, uint8_t TargetBitDepth>
static Pixel< TargetBitDepth >::representation irsol::camera::PixelConversion< SourceBitDepth, TargetBitDepth >::scale ( typename Pixel< SourceBitDepth >::representation  value)
inlinestatic

Scales a pixel value from source bit depth to target bit depth.

Performs linear scaling of the input value and clamps the result to the maximum value allowed by the target bit depth.

Parameters
valuePixel value at SourceBitDepth.
Returns
Scaled pixel value at TargetBitDepth.

Definition at line 137 of file pixel_format.hpp.

139 {
140 auto rawScale = factor * value;
141 return static_cast<typename Pixel<TargetBitDepth>::representation>(
142 std::min(rawScale, static_cast<decltype(rawScale)>(Pixel<TargetBitDepth>::max())));
143 }
static constexpr double factor
Compile-time scaling factor: max(Target) / max(Source)
typename PixelRepresentation< BitDepth >::type representation
The integral type used to represent pixel values at this bit depth.
static constexpr uint64_t max()
Returns the maximum representable pixel value for this bit depth.
auto value

Member Data Documentation

◆ factor

template<uint8_t SourceBitDepth, uint8_t TargetBitDepth>
constexpr double irsol::camera::PixelConversion< SourceBitDepth, TargetBitDepth >::factor
staticconstexpr
Initial value:

Compile-time scaling factor: max(Target) / max(Source)

Definition at line 125 of file pixel_format.hpp.


The documentation for this struct was generated from the following file: