Skip to content

ColorDistance[], ColorConvert[] - #400

Merged
sn6uv merged 31 commits into
masterfrom
unknown repository
Sep 2, 2016
Merged

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

Conversation

@ghost

@ghost ghost commented Jun 4, 2016

Copy link
Copy Markdown

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

ghost commented Jun 13, 2016

Copy link
Copy Markdown
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

wolfv commented Jun 13, 2016

Copy link
Copy Markdown
Member

Or maybe Pillow instead of PIL?

@ghost ghost mentioned this pull request Jul 23, 2016
@sn6uv

sn6uv commented Jul 29, 2016

Copy link
Copy Markdown
Member

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

@ghost

ghost commented Jul 29, 2016

Copy link
Copy Markdown
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.

@ghost

ghost commented Aug 18, 2016

Copy link
Copy Markdown
Author

rebased on current master and ready to merge

@ghost

ghost commented Aug 18, 2016

Copy link
Copy Markdown
Author

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

@sn6uv

sn6uv commented Aug 23, 2016

Copy link
Copy Markdown
Member

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 commented Aug 25, 2016

Copy link
Copy Markdown
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

sn6uv commented Aug 25, 2016

Copy link
Copy Markdown
Member

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.

Comment thread mathics/builtin/colors.py
func = conversions.get('%s>%s' % (s, d))
if not func:
return None
components = stacked(func, components)

Copy link
Copy Markdown
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
Copy Markdown
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