Message Boards Message Boards

Export a PNG file with ColorMap and RawData?


Some database for machine learning, like VOC dataset, use .PNG file to store information. They store information in 0~255, and display it by using ColorMap.

I import it by using this code:

data=Import[path, "RawData"]
cmap=Import[path, "ColorMap"]

But I cannot find a way to export a PNG file in this format. A .PNG file in this format is included.


POSTED BY: Zhang Yanbo
3 months ago

The first example in ImportElements -> Data Representation -> "ColorMap" section shows how to generate a PNG image with a color-reduction palette.

data = Import[path, "RawData"]
cmap = Import[path, "ColorMap"]
Export["palette.png", {"ColorMap"->cmap, "RawData"->data}, "Rules"] 

This syntax is supported also for GIF and TIFF.

POSTED BY: Piotr Wendykier
22 days ago

Group Abstract Group Abstract