Add deltaE functions and lab2lch color conversion utils - #665
Conversation
There was a problem hiding this comment.
In the past I believe we allowed or even preferred this syntax, but more recently we've moved to preferring PEP8 style generally (with spaces on either side of all operators, including **).
There are a few other places where spaces should be added around e.g. *. Running flake8 on these will show you where. Also, if it results in a bad line break or poor readability feel free to defend non-PEP8 syntax - PEP8 itself says it's meant to be broken ;)
There was a problem hiding this comment.
i personally like tightly bound operators tightly spaced (especially **), but not a big deal and easily easily fixed.
|
This looks great, thanks! Other than the minor comments above, I think it should be possible to break the references to roughly 80 characters. |
|
Thanks for the review. I made the requested changes. |
There was a problem hiding this comment.
Could you split these into two separate lines, respectively?
There was a problem hiding this comment.
It will cost you a temporary array.
There was a problem hiding this comment.
Of course, also applies to other occurrences.
|
I've never actually attempted building the docs, and I don't think I'm doing it right. @mrterry, can you tell me how to get from checking out your branch to the error you're having trouble with? |
|
I'm not positive I'm doing it right either : ) Here is what I'm doing: unichr(0x2013) is a hyphen-like character "–" which occurs in skimage/filter/_denoise_cy.pyx If you replace them with ascii dashes, re-install, and re-build doc, sphinx starts complaining about other unicode. ä, ü, and presumably more. |
|
@mrterry, just to be clear, your doc fails only at that spot? ie, is there any more output after that "Error 1"? Because I get a lot of apparent errors, I think to do with missing plugins in my test box, and I can't even find the unicode error you mentioned. Do you have the right version of sphinx? Here's my build blatantly stepping right over your error: =P And here it is finally croaking: @stefanv @ahojnnes @tonysyu @josteinbf, I'm assuming you have built the doc before and have an environment properly set up to do so. Could you try checking out @mrterry's branch and building the docs, see if you can reproduce this error? Other than that, imho this is ready to merge. |
|
@jni The docs build at my setup, but with a lot of warnings (normal, but bad). None of the warnings mention the word "color", so I suppose none of the warnings are from the color package. On the other hand, I cannot find neither Let me know if you want to see the full sphinx log or need to know more about my setup. |
|
@jni Something in my environment was borked. I see the same error you do. Upon further investigation, it appears to be a problem in the latest sphinx. With sphinx 1.2b, my master, my branch, and my branch's master-parent fail to build the docs. |
|
Yikes! Is this due to an abuse on our side, or is Sphinx now broken? |
|
I'm going to blame sphinx. I found this suspicious looking (solved) bug report, but it isn't in the 1.2b release on PyPI. Somewhat OT, but it seems a little fishy for |
|
@josteinbf When I build the docs (with sphinx-1.1), all the new functions show up in the docs. Did you build & install my branch? I think the docs build script looks at |
|
I experienced the same issues some months ago... as far as I can remember it is caused by a bug in Sphinx. |
|
@mrterry Sorry, it was a stupid mistake (although not the one you suggested). It is working as it should (sphinx 1.1.3). |
|
@josteinbf, are you saying you have successfully built the docs on this branch? I haven't, but I haven't successfully built the docs on any branch. ;) Other than that, the tests, coverage, functionality, and syntax are ready, as far as I'm concerned. If anyone can tell me why I'm getting a buttload of errors such as this one when building the docs, I'd be eternally grateful. =) Exception raised while running:
plot_rank_filters.py in /home/ubuntu/projects/scikit-image/doc/source/../examples/applications
\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Traceback (most recent call last):
File "/home/ubuntu/projects/scikit-image/doc/source/../ext/plot2rst.py", line 253, in write_gallery
write_example(src_name, src_dir, rst_dir, cfg)
File "/home/ubuntu/projects/scikit-image/doc/source/../ext/plot2rst.py", line 325, in write_example
figure_list, rst = process_blocks(blocks, src_path, image_path, cfg)
File "/home/ubuntu/projects/scikit-image/doc/source/../ext/plot2rst.py", line 493, in process_blocks
exec(bcontent, example_globals)
File "<string>", line 12, in <module>
File "/home/ubuntu/.virtualenvs/scikit-image-dev/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 2892, in imshow
imlim=imlim, resample=resample, url=url, **kwargs)
File "/home/ubuntu/.virtualenvs/scikit-image-dev/local/lib/python2.7/site-packages/matplotlib/axes.py", line 7299, in imshow
im.set_data(X)
File "/home/ubuntu/.virtualenvs/scikit-image-dev/local/lib/python2.7/site-packages/matplotlib/image.py", line 425, in set_data
raise TypeError("Image data can not convert to float")
TypeError: Image data can not convert to float
\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Incidentally the backslashes in front of the tilde line breaks are mine, otherwise the markdown doesn't render properly... Something else to troubleshoot!) |
|
@jni Yes, I successfully built the docs for both this branch and master. 2013/8/14 Juan Nunez-Iglesias [email protected]
|
|
Hmm, I was just about to push the merge button but I ran a merge+test... Nothing major but some warnings... @mrterry, any idea what's causing them and whether they can be easily avoided? |
|
Oh, and it looks like a function in the tests is misspelled: |
|
The warning is a sqrt(negative zero) that shows up when comparing two
|
|
Apparently this was more interesting than the work I was supposed be doing. : ) This change fixes the roundoff issues that were showing up for identical colors. It should be faster and more memory efficient too. |
definitely been there! ;) Question: why do you compute dH2 as dLab2 - dL2 - dC2, or, in the new code, as da2 + db2 - dC**2, instead of just getting H from the lab2lch conversion and computing the difference directly? I'm asking because it took me a while to figure out what you were doing, and I'm hoping to save future maintainers the same effort. So I would either:
Sorry to be nitpicky, but I think the improved clarity will be worth it...! |
|
@jni, |
|
Very nice! All tests pass with no warnings and the code is much clearer. (to me at least!) Thanks for sticking with it! Incidentally, you wrote "working directly with the hue value directly", but I'll let you fix that in a separate PR, this one has dragged on long enough. =) |
Add deltaE functions and lab2lch color conversion utils
|
thanks! |
Adds four color distance metrics CIE76, CIEDE94, CIEDE2000, and CMC. Docs and tests included. The deltaE functions should work so long as the two color arrays are conformable. ie deltaE(x, y) works for x.shape == (3,); y.shape = (10, 10, 3) as well as when they have the same shape.
It also adds lab2lch (lch2lab) color conversion functions. These were needed for some of the deltaE functions, but are not actually called internally.