Color reduction issue - limited colors - image quality

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
objuan
Posts: 2
Joined: 2013-05-07T15:57:53-07:00
Authentication code: 6789

Color reduction issue - limited colors - image quality

Post by objuan »

Hi everyone.

Relatively new to imagemagick but very impressed so far. I am trying to reduce the number of colors in a composite image. I basically am creating a canvas/background and composing/combining it with a logo that has a transparent background. The composed image has to only use the the colors in the background and the logo. I also have to resize the logo to scale it to be consistent with the background/canvas size. Let's say I have a background that is 1 color, and a logo that has 4 colors. I can only use a total of 5 colors. When I combine the 2 images, however, I get a dithered edge that creates many more colors. If I specify the number of colors to 5, I get jagged edges around the logo. The logo is clean before it gets composed, and the background is only 1 color. If anyone can help with the right combination of Imagemagick commands to get the end result, I would be very grateful.

Kind regards,
objuan
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Color reduction issue - limited colors - image quality

Post by fmw42 »

That is likely due to the anti-aliasing in the alpha channel which causes a mix of colors when compositing. Your alpha channel is likely 8-bit and not binary.

The best I can suggest is to create an image of only the colors you want. Combine your images. Then use -remap with the colormap image to reassign the colormap to use only your colors. see

http://www.imagemagick.org/Usage/quantize/#remap

but use +dither or -dither none to turn off dithering if you want.


see

http://www.imagemagick.org/Usage/quantize/
http://www.imagemagick.org/script/quantize.php
Last edited by fmw42 on 2013-05-15T20:09:00-07:00, edited 1 time in total.
objuan
Posts: 2
Joined: 2013-05-07T15:57:53-07:00
Authentication code: 6789

Re: Color reduction issue - limited colors - image quality

Post by objuan »

Thank you fmw42!!! I will try that. I'll let you know what I find. Just coming back to the issue, so I apologize for not saying thanks earlier! I really appreciate it!
Post Reply