Problems with coordinate ranges when doing conversion from LCH to LAB to RGB

Juan Nunez-Iglesias jni.soma at gmail.com
Wed Oct 1 01:15:55 EDT 2014


Hey Matteo,




I’m not familiar with all the different colour spaces, but from your second notebook you know that L in Lab ranges from 0-100, so I imagine it’s the same in Lch. Similarly for ab -> c. You might want to try 0-100 as your ranges. Various resources on the internet also point to that range, e.g., http://www.colourphil.co.uk/lab_lch_colour_space.shtml .




In addition, I think your call to swapaxes to get lch256 in the final notebook might be incorrect. You need to put axis 0, the channels, at the end for our colour conversions to work, so it should be swapaxes(arr, 0, 2).




Having said that, you are right that our documentation could be improved, at the very least linking to relevant web documents for each function. I’ll add an issue for this.




I hope this helps, and thanks for reporting the issue!




Juan.


—
Sent from Mailbox

On Wed, Oct 1, 2014 at 2:29 PM, Matteo <matteo.niccoli at gmail.com> wrote:

> A while ago I wrote a post on my blog with code on how to import in Python 
> a colour palette in an ASCII file and convert it to a Matplotlib colormap: 
> mycarta.wordpress.com/2014/04/25/convert-color-palettes-to-python-matplotlib-colormaps/
> Following that post I wrote a tutorial on a geoscience magazine on how to 
> evaluate and compare colormaps using Python: 
> wiki.seg.org/wiki/How_to_evaluate_and_compare_color_maps
> In the accompanying notebook I show how to convert a 256x3 RGB colormap to 
> a 256x256x3 RGB image, then convert it to CIELAB using scikit-image's 
> rgb2lab, then plot the 256x1 lightness (L) array to evaluate the colormaps 
> perceptually.
> You can read the relevant extract of the notebook using this nbviewer link:
> http://nbviewer.ipython.org/urls/dl.dropbox.com/s/54zoax2qesb71wn/evaluate_colormaps_skimage_test.ipynb?dl=0 
> In that case scikit-image worked really well for me.
> Now I am trying to follow up with a new tutorial and I run into problems 
> with the color space conversions.
> You can follow what I am trying to do in this other notebook extract:
> http://nbviewer.ipython.org/urls/dl.dropbox.com/s/noli66nzrlk0676/make_colormap_skimage_test.ipynb?dl=0
> The goal of this new tutorial is to show how to build colormaps from 
> scratch using perceptual principles. I design a color palette in LCH (polar 
> version of CIELAB) by keeping Chroma and Lightness fixed and interpolating 
> Hue around the circle, then convert to LAB, then to RGB.
> As far as I know the code I wrote should work, but the result is a black 
> colormap. I am thinking I got wrong one or more of the ranges for the LCH 
> coordinates. I assumed L between (0,1), Ch between (0,1), and H between (0, 
> 2*pi).
> Is that wrong, and if that's the case, what are the ranges? Many of them 
> are not stated clearly in the documentation in here: 
> http://scikit-image.org/docs/dev/api/skimage.color.html
> Is it possible to update the documentation to clearly state all ranges for 
> all colour spaces.
> Thanks for your help.
> Matteo
> -- 
> You received this message because you are subscribed to the Google Groups "scikit-image" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20140930/9a0b471a/attachment.html>


More information about the scikit-image mailing list