On Mon, Aug 9, 2010 at 3:40 PM, Friedrich Romstedt < friedrichromst...@gmail.com> wrote:
> 2010/8/6 Benjamin Root <ben.r...@ou.edu>: > > Actually, I have been looking at a somewhat related problem. It might be > a > > useful feature in matplotlib.color to provide a function that can take a > > colormap and produce a grayscale version of it. In my limited amount of > > research, I have found that one could convert the rgb values into hsv or > hsl > > and use the "value" or "lightness" respectively for the grayscale value. > I > > forget which one was aesthetically better, though. > > http://www.pythonware.com/library/pil/handbook/image.htm : > > "When from a colour image to black and white, the library uses the > ITU-R 601-2 luma transform: > > L = R * 299/1000 + G * 587/1000 + B * 114/1000 > " > > That should also be easy to implement. > > Friedrich > I am working on a function that can take a Colormap object and return a grayscale form of it. Ideally, I would like to return the same type of Colormap that was provided, but I am wondering if this is necessary. I supposed it is sufficient to just create a LinearSegmentedColormap from the self._lut data? The problem I see with that approach is that there is still possibly some information loss, particularly with the alpha part of the rgba data. LinearSegmentedColormap has a .from_list() function, but it uses only the rgb part of the rgba array and does not take alpha data. Is the inability of setting alpha a problem? Or maybe I should use deepcopy() instead? Thanks, Ben Root
------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel