Stephan Hennig on wrote... | Hi, | | Task: | Convert a image to grey scale with a limited number of colours. | | | Approach: | convert bluebells_darker.jpg -colorspace Gray -colors 64 c.png | | Checking the number of colours in c.png with | | identify -format "%k unique colors" c.png | 16 unique colors | | shows that it has /far/ less than 64 colours. | | For different arguments to '-colors <col>' I get the following results: | | <col> colours in image | 1 1 | 2 2 | 3 3 | 4 - 15 4 | 16 - 63 8 | 64 - 254 16 | 255 64 | | For different images there are other values. | | Although, this is in accordance to the description of option -colors, | which says | | > The actual number of colors in the image may be less than your | > request, but never more. | | I think the colour reduction algorithm performs really poor. Is that a bug? | | Best regards, | Stephan Hennig | | > convert -version | > Version: ImageMagick 6.3.7 11/29/07 Q8 http://www.imagemagick.org | > Copyright: Copyright (C) 1999-2007 ImageMagick Studio LLC | The colors quantization algorithm uses a tree basied segmentation method to cluster colors together until it gets less than the maximum number of colors needed.
Often there can be a sudden jump in the resulting number of colors when the colors do not cluster very well. That is a lot of very distinct colors. Also there is a second phase to the -colors algorithm where once the colors have been selected the image needs to be transformed to use those colors. This process is called 'mapping' or 'dithering'. However the alogorithms that do this may not in fact use all the colors found by the quantization algorithm!!! Try repeating you test with a +dither option and see how that effects the outcome. You may also like to not only set -colorspace gray, but also -quantize gray. If this effects the outcome is not know to me. All my existing notes about color quantization and dithering is currently documented and exampled in IM Examples http://imagemagick.org/Usage/quantize/ Cristy... is there some way to get just the color quantization results without the colors being mapped directly onto the image. Say a verbose table, or a way to output a image like -unique-colors? This may allow users who want to examine or modify the color results from the color quantization rouinte before applying it to the image. Also exactly what does -treedepth do in the color quantization and how does it effect results? Anthony Thyssen ( System Programmer ) <[EMAIL PROTECTED]> ----------------------------------------------------------------------------- My religious faith is a private matter bettween me and my God. -- Robert A. Heinlein "If this Goes On..." ----------------------------------------------------------------------------- Anthony's Home is his Castle http://www.cit.gu.edu.au/~anthony/ _______________________________________________ Magick-users mailing list [email protected] http://studio.imagemagick.org/mailman/listinfo/magick-users
