I have a grayscale (one channel) image in Mathematica. How can I export it as a grayscale Bitmap?
Every single option I tried so far does not have an influence on the Bitmap exported using Export
. If I export the image as PNG, Mathematica exports the grayscale image as expected.
Simple Example
Let's create a simple grayscale image:
image = Image[RandomReal[{0, 1}, {100, 150}]];
Simple export via:
Export["test.bmp",image];
shows exactly the problem mentioned above. Additional options like setting ColorSpace->"Grayscale"
does not seem to have any effect. Any kind of color-conversion before doing the export did not work either, which is not surprising to me because the image already clearly carries the information that it is a grayscale image and export via
Export["test.png",image];
does export a grayscale PNG. Verification can for example be done by simple reimporting the ColorSpace Element of the exported image:
Import["test.bmp","ColorSpace"];