-colors question re IM 6.8.9.3 Q16 Mac OSX

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

-colors question re IM 6.8.9.3 Q16 Mac OSX

Post by fmw42 »

I am curious if -colors is working properly? I get a very poor selection of 4 colors for the following image.

Input:

Image

Code: Select all

convert kdf_black.png +dither -colors 4 -unique-colors -scale 10000% kdf_black_4colors.png
Resulting colors:

Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: -colors question re IM 6.8.9.3 Q16 Mac OSX

Post by snibgo »

On 6.8.9-0 on Windows 8.1, I get similar or identical colours to you.

When I remove "+dither", I get better colours. I didn't know that "+dither" affected the choice of colours.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: -colors question re IM 6.8.9.3 Q16 Mac OSX

Post by fmw42 »

snibgo wrote:On 6.8.9-0 on Windows 8.1, I get similar or identical colours to you.

When I remove "+dither", I get better colours. I didn't know that "+dither" affected the choice of colours.
Yes, you seem to be correct about removing +dither and getting somewhat better colors. But I have to go to 5 colors to get any orange-like color.


convert kdf_black.png +dither -colors 5 -unique-colors -scale 10000% kdf_black_d4_colors.png
Image

convert kdf_black.png +dither -colors 5 -unique-colors -scale 10000% kdf_black_d5_colors.png
Image

convert kdf_black.png -colors 4 -unique-colors -scale 10000% kdf_black_nd4_colors.png
Image

convert kdf_black.png -colors 5 -unique-colors -scale 10000% kdf_black_nd5_colors.png
Image

With regard to dithering, see http://www.imagemagick.org/Usage/quantize/#colors

It does not seem to matter which dithering method I use or the default. They all produce the same results for this case. But it does matter if I add +dither or -dither none.

P.S. I am experimenting with color reduction in order to try to get reasonable seed colors for k-means segmentation script that I am writing.
Post Reply