Message Boards Message Boards

GROUPS:

Export a PNG file with ColorMap and RawData?

Posted 1 year ago
1045 Views
|
1 Reply
|
3 Total Likes
|

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:

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.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract