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

ColorDistance[], ColorConvert[] #400

Merged
merged 31 commits into from
Sep 2, 2016
Merged

Conversation

poke1024
Copy link
Contributor

@poke1024 poke1024 commented Jun 4, 2016

implements ColorDistance[], ColorConvert[] and accompanying color spaces like LABColor[]. Values computed (through ColorConvert[] or ColorDistance[]) should always be identical to MMA within the first few digits at least.

Fixes current behaviour that always added alpha channels to colors, i.e. turning RGBColor[1, 0, 0] into RGBColor[1, 0, 0, 1] instantly. Alpha values now only occur if they are specified.

@poke1024
Copy link
Contributor Author

I just realized I should rework this in a more general way, in order to use the color conversion functions for Image[] as well, in order to get rid of the skimage dependency there and switch to PIL instead.

@wolfv
Copy link
Member

wolfv commented Jun 13, 2016

Or maybe Pillow instead of PIL?

@poke1024 poke1024 mentioned this pull request Jul 23, 2016
@sn6uv
Copy link
Member

sn6uv commented Jul 29, 2016

@poke1024 What's the status of this? It looks finished to me but I thought I should check with you before merging.

@poke1024
Copy link
Contributor Author

I'm done with it, it's the best solution I can come up with. My main goals were that there's no code duplication of the color conversion stuff for numpy and non-numpy cases and that numerical results are near or identical to MMA. Would be happy to work on Image[] based on this.

@poke1024
Copy link
Contributor Author

rebased on current master and ready to merge

@poke1024
Copy link
Contributor Author

Have no idea why the PyPy build is marked as fail, it ends with OK.

@sn6uv
Copy link
Member

sn6uv commented Aug 23, 2016

The PyPy test is failing when running the unittests, i.e. setup.py test:

======================================================================

ERROR: testConversions (test_color.ColorTest)

----------------------------------------------------------------------

Traceback (most recent call last):

  File "/home/travis/build/mathics/Mathics/test/test_color.py", line 252, in testConversions

    c = components[:3]

NotImplementedError: settting a slice of a PySequence_Fast is not supported

@poke1024
Copy link
Contributor Author

I fear I broke Travis for good now. It's rebased and still no Travis info.

@sn6uv sn6uv closed this Aug 25, 2016
@sn6uv sn6uv reopened this Aug 25, 2016
@sn6uv
Copy link
Member

sn6uv commented Aug 25, 2016

Travis is having some issues today: link to details. Might be related to that. I've closed and opened which seems to have triggered a build.

func = conversions.get('%s>%s' % (s, d))
if not func:
return None
components = stacked(func, components)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about conversions that require intermediate transformations. E.g. LCH -> LAB -> XYZ -> RGB -> HSB. Is it worth formulating this as a graph search problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LCH -> LAB -> XYZ -> RGB -> HSB would be handled by flow using RGB as proxy (first if case) and then converting LCH to RGB and RGB to HSB. The code is a mess though, and I'll redo this with a simple and properly precomputed graph route table.

The underlying graph is beautiful, with RGB and XYZ being the central conversion hubs:

color-graph

@sn6uv sn6uv merged commit 5720a9c into mathics:master Sep 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants