A non-matplotlib way to do this is to use ImageMagick or GraphicsMagick:
gm convert -colorspace Gray color_image.png bw_image.png
in GraphicsMagick or using the ImageMagick routine "convert":
convert -colorspace Gray color_image.png bw_image.png
I think it works on a wide variety of image formats.
Jon
···
Hello,
I need to prepare two versions of figures: color and BW(Black&White).
Is there an easy way to produce just the colored version and than use
some command or script to turn it to BW or grayscale?
I thought that converting from color to BW really means: "in all
object in the figure, turn any color that is not white to black".
Is there an easy way to implement this?
Thanks
Eli
A word of warning on this approach though… If the graphics formats are vector-based (ps, eps, svg, etc…), then ImageMagick will destroy the vector information in the process, even if the output format is also vector based. This is because ImageMagick is a raster-based library and all of its algorithms operate upon raster data.
So, if this is for a publication, ImageMagick is not advised.
I also have another approach that allows you to convert a colormap into a greyscale version of itself, but wouldn’t work on colored lines or anything like that. I suggest going with Friedrich’s approach.
Ben Root
···
On Mon, Sep 20, 2010 at 9:22 AM, Jonathan Slavin <jslavin@…3287…1…> wrote:
A non-matplotlib way to do this is to use ImageMagick or GraphicsMagick:
gm convert -colorspace Gray color_image.png bw_image.png
in GraphicsMagick or using the ImageMagick routine “convert”:
convert -colorspace Gray color_image.png bw_image.png
I think it works on a wide variety of image formats.
Jon