|
M5Unit-COLOR 0.2.0 git rev:d6fe6e1
|
Color corrections for 8-bit RGB values (pure hue, brightness normalization, grayscale, color names) More...
Go to the source code of this file.
Classes | |
| struct | m5::unit::tcs3472x::RGB8 |
| 8-bit RGB value More... | |
Namespaces | |
| namespace | m5 |
| Top level namespace of M5Stack. | |
Enumerations | |
| enum class | m5::unit::tcs3472x::ColorName : uint8_t { Black , White , Gray , Red , Orange , Yellow , Green , Cyan , Blue , Purple , Magenta , Brown } |
| Color names for nearestColorName. More... | |
Functions | |
| RGB8 | m5::unit::tcs3472x::pureHue (const uint8_t r, const uint8_t g, const uint8_t b) |
| Pure hue. | |
| RGB8 | m5::unit::tcs3472x::normalizeBrightness (const uint8_t r, const uint8_t g, const uint8_t b) |
| Brightness normalization. | |
| RGB8 | m5::unit::tcs3472x::grayscale (const uint8_t r, const uint8_t g, const uint8_t b) |
| Grayscale. | |
| ColorName | m5::unit::tcs3472x::nearestColorName (const uint8_t r, const uint8_t g, const uint8_t b) |
| Nearest color name. | |
| RGB8 | m5::unit::tcs3472x::colorNameToRGB (const ColorName name) |
| Representative color of the color name. | |
| const char * | m5::unit::tcs3472x::colorNameToString (const ColorName name) |
| String of the color name. | |
Color corrections for 8-bit RGB values (pure hue, brightness normalization, grayscale, color names)
Each function takes an 8-bit RGB value, such as Data::R8() or Calibration::R8(), and returns the corrected color. Pass calibrated values (Calibration) for the best results, so that white and gray have equal channels.
|
strong |
| RGB8 m5::unit::tcs3472x::colorNameToRGB | ( | const ColorName | name | ) |
Representative color of the color name.
| name | Color name |
| const char * m5::unit::tcs3472x::colorNameToString | ( | const ColorName | name | ) |
String of the color name.
| name | Color name |
| RGB8 m5::unit::tcs3472x::grayscale | ( | const uint8_t | r, |
| const uint8_t | g, | ||
| const uint8_t | b ) |
Grayscale.
Luma by the ITU-R BT.709 weights (0.2126 R + 0.7152 G + 0.0722 B)
| r | Red (0-255) |
| g | Green (0-255) |
| b | Blue (0-255) |
| ColorName m5::unit::tcs3472x::nearestColorName | ( | const uint8_t | r, |
| const uint8_t | g, | ||
| const uint8_t | b ) |
Nearest color name.
Classifies the color by HSV: dark colors are Black, low saturation colors are White or Gray, and the others are named by hue (dark orange is Brown). The thresholds are rough guides for a typical indoor environment
| r | Red (0-255) |
| g | Green (0-255) |
| b | Blue (0-255) |
| RGB8 m5::unit::tcs3472x::normalizeBrightness | ( | const uint8_t | r, |
| const uint8_t | g, | ||
| const uint8_t | b ) |
Brightness normalization.
Scales all channels by the same factor so that the largest channel becomes 255. The hue and saturation are kept, so the color looks the same at different distances or illuminance
| r | Red (0-255) |
| g | Green (0-255) |
| b | Blue (0-255) |
| RGB8 m5::unit::tcs3472x::pureHue | ( | const uint8_t | r, |
| const uint8_t | g, | ||
| const uint8_t | b ) |
Pure hue.
Removes the white component (the smallest channel) and scales the largest remaining channel to 255. The result is the most saturated color of the same hue (a dull blue becomes a vivid blue). Useful to classify colors by hue regardless of brightness and dullness
| r | Red (0-255) |
| g | Green (0-255) |
| b | Blue (0-255) |