Reduce an image to 15 colors from a 159 color palette.

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Metroids
Posts: 2
Joined: 2013-07-05T14:11:01-07:00
Authentication code: 6789

Reduce an image to 15 colors from a 159 color palette.

Post by Metroids »

I want something like this:

Code: Select all

convert input.png -dither Riemersma -remap palette.png -colors 15 output.png
(but I don't think that's a valid use of the library, pretty sure it's ignoring the colors param)

Input is an arbitrary image. Palette looks like this: http://topolla.net/images/palette.png

A two step process like this works, but I don't think it chooses the best image.

Code: Select all

convert input.png -dither Riemersma -remap palette.png ouput.png
convert ouput.png -dither Riemersma -colors 15 ouput_final.png
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Reduce an image to 15 colors from a 159 color palette.

Post by snibgo »

"-colors 15" chooses, from all possible colors, the 15 colors that best fit the image.

If you want to restrict the possible colors to those in palette.png, you could:

1. Remap to palette.png.

2. From the result, find the 15 most common colors.

3. Make a palette map of those 15 colors.

4. Remap input.png to the map from (3).
snibgo's IM pages: im.snibgo.com
Metroids
Posts: 2
Joined: 2013-07-05T14:11:01-07:00
Authentication code: 6789

Re: Reduce an image to 15 colors from a 159 color palette.

Post by Metroids »

Thanks, I've gotten pretty good results from that process.
Post Reply