FastLED 3.9.3
Loading...
Searching...
No Matches
Gamma Adjustment Functions

Detailed Description

Functions for applying gamma adjustments to LED data.

Gamma correction tries to compensate for the non-linear manner in which humans perceive light and color. Gamma correction is applied using the following expression:

output = pow(input / 255.0, gamma) * 255.0;

Larger gamma values result in darker images that have more contrast. Lower gamma values result in lighter images with less contrast.

These functions apply either:

Note that the gamma is specified as a traditional floating point value, e.g., "2.5", and as such these functions should not be called in your innermost pixel loops, or in animations that are extremely low on program storage space. Nevertheless, if you need these functions, here they are.

Furthermore, bear in mind that CRGB LEDs have only eight bits per channel of color resolution, and that very small, subtle shadings may not be visible.

See also
Dimming and Brightening Functions
https://en.wikipedia.org/wiki/Gamma_correction

Functions

uint8_t applyGamma_video (uint8_t brightness, float gamma)
 Applies a gamma adjustment to a color channel.
 
CRGB applyGamma_video (const CRGB &orig, float gamma)
 Applies a gamma adjustment to a color.
 
CRGB applyGamma_video (const CRGB &orig, float gammaR, float gammaG, float gammaB)
 Applies a gamma adjustment to a color.
 
CRGBnapplyGamma_video (CRGB &rgb, float gamma)
 Destructively applies a gamma adjustment to a color.
 
CRGBnapplyGamma_video (CRGB &rgb, float gammaR, float gammaG, float gammaB)
 Destructively applies a gamma adjustment to a color.
 
void napplyGamma_video (CRGB *rgbarray, uint16_t count, float gamma)
 Destructively applies a gamma adjustment to a color array.
 
void napplyGamma_video (CRGB *rgbarray, uint16_t count, float gammaR, float gammaG, float gammaB)
 Destructively applies a gamma adjustment to a color array.
 

Function Documentation

◆ applyGamma_video() [1/3]

CRGB applyGamma_video ( const CRGB & orig,
float gamma )

Applies a gamma adjustment to a color.

Parameters
origthe color to apply an adjustment to
gammathe gamma value to apply
Returns
copy of the CRGB object with gamma adjustment applied

Definition at line 1374 of file colorutils.cpp.

◆ applyGamma_video() [2/3]

CRGB applyGamma_video ( const CRGB & orig,
float gammaR,
float gammaG,
float gammaB )

Applies a gamma adjustment to a color.

Parameters
origthe color to apply an adjustment to
gammaRthe gamma value to apply to the CRGB::red channel
gammaGthe gamma value to apply to the CRGB::green channel
gammaBthe gamma value to apply to the CRGB::blue channel
Returns
copy of the CRGB object with gamma adjustment applied

Definition at line 1383 of file colorutils.cpp.

◆ applyGamma_video() [3/3]

uint8_t applyGamma_video ( uint8_t brightness,
float gamma )

Applies a gamma adjustment to a color channel.

Parameters
brightnessthe value of the color data
gammathe gamma value to apply
Returns
the color data, adjusted for gamma

Definition at line 1361 of file colorutils.cpp.

◆ napplyGamma_video() [1/4]

CRGB & napplyGamma_video ( CRGB & rgb,
float gamma )

Destructively applies a gamma adjustment to a color.

Parameters
rgbthe color to apply an adjustment to (modified in place)
gammathe gamma value to apply

Definition at line 1392 of file colorutils.cpp.

◆ napplyGamma_video() [2/4]

CRGB & napplyGamma_video ( CRGB & rgb,
float gammaR,
float gammaG,
float gammaB )

Destructively applies a gamma adjustment to a color.

Parameters
rgbthe color to apply an adjustment to (modified in place)
gammaRthe gamma value to apply to the CRGB::red channel
gammaGthe gamma value to apply to the CRGB::green channel
gammaBthe gamma value to apply to the CRGB::blue channel

Definition at line 1398 of file colorutils.cpp.

◆ napplyGamma_video() [3/4]

void napplyGamma_video ( CRGB * rgbarray,
uint16_t count,
float gamma )

Destructively applies a gamma adjustment to a color array.

Parameters
rgbarraypointer to an LED array to apply an adjustment to (modified in place)
countthe number of LEDs to modify
gammathe gamma value to apply

Definition at line 1404 of file colorutils.cpp.

◆ napplyGamma_video() [4/4]

void napplyGamma_video ( CRGB * rgbarray,
uint16_t count,
float gammaR,
float gammaG,
float gammaB )

Destructively applies a gamma adjustment to a color array.

Parameters
rgbarraypointer to an LED array to apply an adjustment to (modified in place)
countthe number of LEDs to modify
gammaRthe gamma value to apply to the CRGB::red channel
gammaGthe gamma value to apply to the CRGB::green channel
gammaBthe gamma value to apply to the CRGB::blue channel

Definition at line 1411 of file colorutils.cpp.