Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this a minor error of lightness normalization into colors' sort? #80

Open
nzamulov opened this issue Apr 12, 2024 · 0 comments
Open

Comments

@nzamulov
Copy link

nzamulov commented Apr 12, 2024

Hello,

according to the article about CIELAB color space from your code:
https://github.com/thephpleague/color-extractor/blob/master/src/ColorExtractor.php#L275
https://en.wikipedia.org/wiki/CIELAB_color_space

area of definition of lightness param (L*/Lstar) is [0:100], where 0 - black, 100 - white. But in colors' sorting algorithm
https://github.com/thephpleague/color-extractor/blob/master/src/ColorExtractor.php#L58

you have follow lightness normalization:
(1 - $labColor['L'] / 200)

If we follow strict classical mathematical rules about any kind of normalization, lightness normalization in your code must be looks like:
(1 - $labColor['L'] / 100)

It turns out that you have an extra 1/2 constant for lightness normalization. I understand that it is not cause any problem with correctness of sort algorithm itself, because you multiply EACH lightness value by this constant and this is why it is still correct. But I do not understand why do you divide L param by 200, not by 100?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant