C++ library thats implemets class color. Available models: RGB, HSL, HSV, CMY, CMYK, YIQ, YUV and growing.

Overview

Yet another c++ library that implements color.

Description

  • Yet another c++ library that implements color conversion and manipulation.

Key features:

  • No virtual functions
  • Minimal memory footprint
  • Ability to copy array/vector of colors with memcpy, memmove and initialize with memset.
  • Conversions from/to different models ( and its formats ).
  • Headers only
    • One file to include to start the fun
    • By using del or rm it is reducible in to only two of them.
  • No third parties
  • No additional binaries
  • Out of the box ready
    • No need to recompile or start some install process.
  • Color models:
    • GRAY,
    • RGB, CMY, CMYK,
    • HSI, HSL, HSV, HWB,
    • YIQ, YUV(BT.601, BT.709), YCgCo, YPbPr(BT.601, BT.709, BT.2020),
    • XYZ( sRGB, D65, 2° ), LAB( CIE, Hunter), LUV, LMS( von Kries D65, von Kries E, BFD, MCAT02 ), xyY, LabCH, LuvCH

Code sample - Initialization:

// Initialize with constant.
color::bgr<std::uint8_t>  b( ::color::constant::aqua_t{} );

//!< Use x11 green.
color::yiq<std::uint8_t>  y( ::color::constant::x11::green_t{} );

// Use intuitive/natural values for initialization.
// hue goes from 0 to 360, saturation and value from 0 to 100.
color::hsv<double>        h( { 120.0, 50.0, 60.0 } );

// Lightens will goes from 0 to 100. a and b from -127 to 127.
color::lab<float>         l( { 50.0, -10, 90 } );

// Well known rgb. Values are between 0 and 1.
color::rgb<float>         r( { 0.5, 0, 0.9 } );

Code sample - Conversion:

// any model/format to any model/format by use of operator=

b = r; //!< Reformat and convert.
r = b; //!< Reformat and convert in opposite direction.
h = b; //!< Reformat and convert from bgr<std::uint8_t> to hsv<double>
h = y; //!< Reformat and convert from yiq<std::uint8_t> to hsv<double>
l = y; //!< Reformat and convert from yiq<std::uint8_t> to lab<float>

Code sample - Feature Extraction:

color::rgb<std::uint8_t>  r = ::color::constant::aqua_t{};
::color::get::red( r ); //!< Extract red

color::yiq<std::uint8_t>  y = ::color::constant::orange_t{};
::color::get::red( y ); //!< Extract red

Code sample - Distance:

using namespace std;
using namespace color;
using namespace color::operation;
using namespace color::constant;
using namespace color::constant::distance;

rgb<uint8_t>  r0 = aqua_t{};
rgb<uint8_t>  r1 = turquoise_t{};
yiq<uint8_t>  y  = orange_t{};

cout << distance< euclid_entity  >( r0, r1 ) << endl;
cout << distance< CIE76_entity >( r0, y ) << endl;
cout << distance< CIE94_graphics_entity >( r0, y ) << endl;
cout << distance< CIE94_textile_entity >( r0, y ) << endl;
cout << distance< CIEDE2000_entity >( r0, y ) << endl;
cout << distance< CMC1984_entity >( r0, y, 1, 2 ) << endl;
cout << distance< delta_gray_entity >( r0, r1 ) << endl;

Code sample - Blending:

color::yiq<std::uint8_t>  y1 = ::color::constant::turquoise_t{};
color::yiq<std::uint8_t>  y2 = ::color::constant::orange_t{};
color::yiq<std::uint8_t>  yr;

::color::operation::blend(  y1, 0.1, y2 ); //!< Blend two colors for given alpha. Accumulation style.
yr = color::operation::mix( y2, 0.5, y2 ); //!< Blend two colors for given alpha. return style.

Install:

  1. Clone this Repository:
    Examples:
  2. Inform compiler where to find headers:
    Examples:
    • MSVC : /Ic:\my-work-folder\my-git-folder\color\src
    • gcc : -I/home/my-user-name/my-work-folder/my-git-folder/color/src

Want to see more:

Tested against:

  • GCC 7.3.0
  • GCC 10.2.0
  • MSVC 2015 Update 3
  • MSVC 2017 15.9.28
  • MSVC 2019 16.8.3

License

Licensed under an Apache-2.0 license.

Issues
  • Fix for issue

    Fix for issue " Results differ from python colormath package #6 "

    After some debugging, the problem turned out to be a wrong conversion. You converted a value from rad to deg instead the other way round. This does not make sense, as the sin() function takes values in radians. After the fix is applied, the values match with python-colormath.

    opened by ehtec 2
  • Results differ from python colormath package

    Results differ from python colormath package

    Hello, thank you for your library. I want to replace my usage of the python colormath package with some faster c code, but I am having problems. I tested both libraries on a lot of values, and most of them match (at least approximately). But for some values, the difference is large, for example these (RGB):

    color1: [218, 9, 189] color2: [104, 112, 148]

    I get a distance of only about 5 (colormath reports 28). I have the feeling that 5 is pretty low (look at the colors, they are not that similar).

    The algorithm I use is CIEDE2000.

    I had a quick look at your algorithm on my own, but could not find an error. Do you have an idea why we get different results here?

    Thanks in advance for helping out.

    opened by ehtec 1
  • unix stuff, adding cmake and testing on travis

    unix stuff, adding cmake and testing on travis

    Hi, nice library, thanks for sharing! here's some support to auto-testing when checking into github. Including cmake and ctest. also set the executable bits on the shell scripts. Cheers

    opened by tesch1 0
Owner
Dejan
Dejan
Slate is a bitmap editor available for Linux, Windows and Mac.

Slate is a bitmap editor available for Linux, Windows and Mac.

Mitch Curtis 898 Aug 10, 2022
image color filters

ifilter ======= Basic image color filters. ifilter reads an image from standard input, applies a color filter and dumps the resulting image to standa

phil9 4 Dec 2, 2021
Utility to combine color channels from different textures into a single output.

unity-texture-packer ?? Utility to merge different texture channels into a final texture output. Install Using Git Make sure the Git client is install

Andy Duboc 565 Aug 7, 2022
pngtostl is a program that converts a PNG image into STL 3D models

pngtostl is a program that converts a PNG image into a litophane, in STL format, suitable to be printed by entry level 3D printers.

Salvatore Sanfilippo 157 Jul 27, 2022
This library provides a cross-platform image loading library in C11 for projects based on our foundation library

Image Library - Public Domain This library provides a cross-platform image loading library in C11 for projects based on our foundation library.

Mattias Jansson 1 Jan 29, 2022
PillowResize library is a C++ porting of the resize method from the Pillow python library.

Pillow Resize Table of Contents Description Compilation Installation Usage Description PillowResize library is a C++ porting of the resize method from

Zuru Tech 30 Jul 29, 2022
C++ image processing and machine learning library with using of SIMD: SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2, AVX-512, VMX(Altivec) and VSX(Power7), NEON for ARM.

Introduction The Simd Library is a free open source image processing and machine learning library, designed for C and C++ programmers. It provides man

Ihar Yermalayeu 1.6k Aug 4, 2022
libspng is a C library for reading and writing PNG format files with a focus on security and ease of use.

libspng (simple png) is a C library for reading and writing Portable Network Graphics (PNG) format files with a focus on security and ease of use.

Randy 520 Aug 6, 2022
Tiny ISO-compliant C++ EXIF and XMP parsing library for JPEG.

TinyEXIF: Tiny ISO-compliant C++ EXIF and XMP parsing library for JPEG Introduction TinyEXIF is a tiny, lightweight C++ library for parsing the metada

cDc 78 Jul 31, 2022
Video++, a C++14 high performance video and image processing library.

Video++ Video++ is a video and image processing library taking advantage of the C++14 standard to ease the writing of fast video and image processing

Matthieu Garrigues 685 Aug 6, 2022
ZT is a zig-contained library that automatically compiles+links ImGui, OpenGL, and GLFW into typed packages.

ZT is a zig-contained library that automatically compiles+links ImGui, OpenGL, and GLFW into typed packages. By zig contained I mean that ZT is intend

null 85 Aug 8, 2022
ppl.cv is a high-performance image processing library of openPPL supporting x86 and cuda platforms.

ppl.cv is a high-performance image processing library of openPPL supporting x86 and cuda platforms.

null 331 Aug 8, 2022
The CImg Library is a small and open-source C++ toolkit for image processing

http://cimg.eu The CImg Library is a small and open-source C++ toolkit for image processing, designed with these properties in mind: CImg defines clas

David Tschumperlé 1.1k Aug 8, 2022
Pangolin: a lightweight portable rapid development library for managing OpenGL display / interaction and abstracting video input.

What is Pangolin Pangolin is a lightweight portable rapid development library for managing OpenGL display / interaction and abstracting video input. A

Yee 1 Dec 25, 2021
Video, Image and GIF upscale/enlarge(Super-Resolution) and Video frame interpolation. Achieved with Waifu2x, SRMD, RealSR, Anime4K, RIFE, CAIN, DAIN and ACNet.

Video, Image and GIF upscale/enlarge(Super-Resolution) and Video frame interpolation. Achieved with Waifu2x, SRMD, RealSR, Anime4K, RIFE, CAIN, DAIN and ACNet.

Aaron Feng 7.3k Aug 11, 2022
GD Graphics Library

GD Graphics (Draw) Library GD is an open source code library for the dynamic creation of images by programmers. GD is written in C, and "wrappers" are

GD Graphics Library 752 Aug 5, 2022
An open source library for face detection in images. The face detection speed can reach 1000FPS.

libfacedetection This is an open source library for CNN-based face detection in images. The CNN model has been converted to static variables in C sour

Shiqi Yu 11.1k Jul 30, 2022