Message Boards Message Boards

Export a PNG file with ColorMap and RawData?

GROUPS:

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.

Attachment

Attachments:
POSTED BY: Zhang Yanbo
Answer
6 months ago

http://reference.wolfram.com/language/ref/format/PNG.html

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
Answer
4 months ago

Group Abstract Group Abstract