Giter Club home page Giter Club logo

deltae's Introduction

DeltaE - Quantify Color Difference

CIE color difference algorithms in Dart. This is a port of zschuessler's JavaScript DeltaE library. You can learn about the Delta E metric here: https://zschuessler.github.io/DeltaE/learn/.

How to use it

This package differs from the original JavaScript version in quite a few ways. You can compare the following code to the original library's Use It section to get a sense of differences between the two.

// Creating two test LAB color objects to compare
LabColor lab1 = LabColor(36, 60, 41);
LabColor lab2 = LabColor(100, 40, 90);
// 1976 formula
print(deltaE76(lab1, lab2)); // 83.04817878797824
print(deltaE(lab1, lab2, algorithm: DeltaEAlgorithm.cie76)); // 83.04817878797824
// 1994 formula
print(deltaE94(lab1, lab2)); // 67.97917774753019
print(deltaE(lab1, lab2, algorithm: DeltaEAlgorithm.cie94)); // 67.97917774753019
// 2000 formula
print(deltaE00(lab1, lab2)); // 56.85828292477247
print(deltaE(lab1, lab2, algorithm: DeltaEAlgorithm.ciede2000)); // 56.85828292477247

Top-Level Functions

  • deltaE76(LabColor lab1, LabColor lab2)
    The 1976 formula is the first formula that related a measured color difference to a known set of CIELAB coordinates. This formula has been succeeded by the 1994 and 2000 formulas because the CIELAB space turned out to be not as perceptually uniform as intended, especially in the saturated regions. This means that this formula rates these colors too highly as opposed to other colors.
  • deltaE94(LabColor lab1, LabColor lab2, [ Weights weights = const Weights() ])
    The 1976 definition was extended to address perceptual non-uniformities, while retaining the CIELAB color space, by the introduction of application-specific weights derived from an automotive paint test's tolerance data.
  • deltaE00(LabColor lab1, LabColor lab2, [ Weights weights = const Weights() ])
    Since the 1994 definition did not adequately resolve the perceptual uniformity issue, the CIE refined their definition, adding five corrections:
    • A hue rotation term, to deal with the problematic blue region (hue angles in the neighborhood of 275°)
    • Compensation for neutral colors (the primed values in the LCh differences)
    • Compensation for lightness
    • Compensation for chroma
    • Compensation for hue
  • deltaE(LabColor lab1, LabColor lab2, { DeltaEAlgorithm algorithm = DeltaEAlgorithm.ciede2000, Weights weights = const Weights() })
    Another way of calling the three above functions by passing an algorithm parameter which specifies which formula to use.

Classes

  • LabColor(double lightness, double chroma, double hue)
    Represents a color in the CIELAB color space, required by all top-level functions. The lightness (L*) must be between 0 and 100, the chroma (a*) between -128 and 128, and the hue (b*) between -128 and 128. This class comes with handy factories that create LabColor instances from RGB, ARGB and RGBA values (alpha is ignored).
  • Weights({ double lightness = 1, double chroma = 1, double hue = 1 })
    Used to configure the weight factors of the 1994 and 2000 formulas. All the factors must be positive.

Enums

  • DeltaEAlgorithm
    Represents a DeltaE algorithm. It can be either cie76, cie94 or ciede2000.

Tests

The tests have been ported using the test package. You can run them from the following command from inside this package's folder.

pub run test test/delta_e_test.dart

deltae's People

Contributors

ragepeanut avatar kalildev avatar

Stargazers

TechAurelian2 avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

kalildev

deltae's Issues

Delta94 issue

delta94 does not preclude squareroot operations when "C" is greater than the pow2 of deltaA and pow2 of deltaB.
when this happens, you will get an overflow because of a squareroot on a potentially large negative number:
suggest:
final double deltaH = deltaH1 < 0 ? 0 : sqrt(deltaH1);
and
return i < 0 ? 0 : sqrt(i);

Non Nullable migration

Hey, i need to use your package on a null-safe library, so it needs to be migrated also. Can i migrate and make an pr?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.