Skip to content

kokounet/ColorMine

 
 

Repository files navigation

I haven't done much work on this library in a long time, you should check out Colourful, It's a great library with some fantastic features: https://github.com/tompazourek/Colourful

What is ColorMine?

MIT Licensed .Net library that makes converting between color spaces and comparing colors easy.

Getting Started

ColorMine is available as a nuget package so you can install by searching for "ColorMine" in the "Manage Nuget Packages" menu, or run the following command in the Package Manager Console:

PM> Install-Package ColorMine

Color Conversions

You can convert between any supported color spaces via generic methods like so:

var myRgb = new Rgb(149, 13, 12)
var myCmy = myRgb.To<Cmy>();
var myXyz = new Xyz(myRgb);
var myLab = myXyz.To<Lab>();
var myYxy = new Yxy { Y1 = .1124, X = .22, Y2 = .14 };
var myHsl = myYxy.To<Hsl>();

Cmyk conversion also supports profiles

var myCmyk = myRgb
    .WithProfile("~/JapanWebCoated.icc")
    .To<Cmyk>();
var myHunterLab = myCmyk
    .WithProfile("~/JapanWebCoated.icc")
    .To<HunterLab>();

Online example at http://colormine.org/color-converter

Delta-E

Delta-E calculations take and compare colors in any of the supported formats.

double deltaE = myRgb.Compare(myCmy,new Cie1976Comparison());
double deltaE = myXyz.Compare(myLab,new CmcComparison(lightness: 2, chroma: 1));
double deltaE = myYxy.Compare(myHsl,new Cie94(Cie94Comparison.Application.GraphicArts));
double deltaE = myHunterLab.Compare(myLuv, new CieDe2000());

Huge thanks to Jonathan Hofinger for correct implementation of CieDe2000 and to Gaurav Sharma for test data.

Note: Delta-e calculations are quasimetric, the result of comparing color a to b isn't always equal to comparing color b to a...but it will probably be pretty close!


Currently Supported Color Spaces

  • CMY
  • CMYK
  • HSL
  • HSB
  • HSV
  • CIE L*AB
  • Hunter LAB
  • LCH
  • LUV
  • RGB
  • XYZ
  • YXY

Currently Supported Comparisons

  • CIE76
  • CMC l:c
  • CIE94
  • CIE2000

About

.Net library that makes working with colors easy!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%