Skip to content

Comments

ColorDistance[], ColorConvert[]#400

Merged
sn6uv merged 31 commits intomasterfrom
unknown repository
Sep 2, 2016
Merged

ColorDistance[], ColorConvert[]#400
sn6uv merged 31 commits intomasterfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost 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.

@ghost
Copy link
Author

ghost commented Jun 13, 2016

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?

@ghost ghost force-pushed the colorconvert branch from 3081314 to 9c3da45 Compare June 14, 2016 19:11
@ghost ghost 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.

@ghost
Copy link
Author

ghost commented Jul 29, 2016

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.

@ghost ghost force-pushed the colorconvert branch from d8113a6 to da3b9f3 Compare August 18, 2016 07:06
@ghost
Copy link
Author

ghost commented Aug 18, 2016

rebased on current master and ready to merge

@ghost
Copy link
Author

ghost commented Aug 18, 2016

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

@ghost ghost force-pushed the colorconvert branch from f62de9b to eb9ddab Compare August 24, 2016 08:25
@ghost
Copy link
Author

ghost commented Aug 25, 2016

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
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