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

Fix f_lab accuracy #7

Merged
merged 1 commit into from
Jan 7, 2023
Merged

Fix f_lab accuracy #7

merged 1 commit into from
Jan 7, 2023

Conversation

iynehz
Copy link
Contributor

@iynehz iynehz commented Jan 6, 2023

This fixes GH-6.

@mohawk2
Copy link
Member

mohawk2 commented Jan 6, 2023

Thank you for this! I've enabled the CI, as you might see.

Putting xyz(100%, 100%, 100%) into https://products.aspose.app/svg/color-converter/xyz-to-lab gives lab(98.291%, 1.146%, 2.521%), while your updated test shows pdl(1,1,1)->apply($t) gives pdl(100, 8.5945916, 5.5564131). Can you help me understand the discrepancy?

By the way, I'm thinking to change this module from its own Perl-level calculations to using PDL::Graphics::ColorSpace, which has both C/PP implementations of the various functions, and more tests with more values including the ones you mentioned on #6. Do you have an opinion on that?

@mohawk2
Copy link
Member

mohawk2 commented Jan 6, 2023

At the very least we'll want to copy over all the test values so that we have a measure of assurance of correctness.

@iynehz
Copy link
Contributor Author

iynehz commented Jan 6, 2023

while your updated test shows pdl(1,1,1)->apply($t) gives pdl(100, 8.5945916, 5.5564131). Can you help me understand the discrepancy?

Not sure but at least we align with Matlab. If you try it on their web: https://www.mathworks.com/help/images/ref/xyz2lab.html

image

@mohawk2
Copy link
Member

mohawk2 commented Jan 6, 2023

while your updated test shows pdl(1,1,1)->apply($t) gives pdl(100, 8.5945916, 5.5564131). Can you help me understand the discrepancy?

Not sure but at least we align with Matlab. If you try it on their web: https://www.mathworks.com/help/images/ref/xyz2lab.html

The image shows (100, 8.5385, 5.5939). It's not a big discrepancy, but that's different from the converter utility you linked me to on #6, and both the old and new values in your updated test. The word "align" feels like it's adding confusion, not taking it away?

@mohawk2
Copy link
Member

mohawk2 commented Jan 6, 2023

And to add to the fun, P:G:ColorSpace shows:

pdl> use PDL::Graphics::ColorSpace
pdl> p xyz_to_lab(pdl(1,1,1), 'sRGB')
[100  8.5422401  5.5990201]

@iynehz
Copy link
Contributor Author

iynehz commented Jan 6, 2023

The image shows (100, 8.5385, 5.5939). It's not a big discrepancy, but that's different from the converter utility you linked me to on #6, and both the old and new values in your updated test. The word "align" feels like it's adding confusion, not taking it away?

Well I am no expert in this area. What I can do is largely about comparing the library's results vs what's from other calculators. In this case MATLAB is obviously more trustworthy than the other one.

@mohawk2
Copy link
Member

mohawk2 commented Jan 7, 2023

As a bit of fun I thought I would try the MATLAB stuff in Octave, which gave the same results (after installing the relevant package):

$ octave
[snip]
octave:1> pkg install -forge image # if needed
[snip]
octave:2> pkg load image
octave:3> xyz2lab([1 1 1])
ans =
   100.0000     8.5385     5.5939

@mohawk2 mohawk2 merged commit 4731b55 into PDLPorters:master Jan 7, 2023
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

Successfully merging this pull request may close these issues.

t_lab inaccurate
2 participants