Reduce pictures to very low number of colors

Sep 10, 2015 at 10:00 PM
Hi
I would like to use Magick.net with VB.Net to convert high res color pictures to a controlled number of colors (between 4 and 9) maybe using a personalized Ordered dither map.
Anybody can help ?
Many thanks
Paolo*
Coordinator
Sep 11, 2015 at 6:48 PM
You can reduce the number of colors with the Quantize method. You can specify your own ordered dither map with the OrderedDither method. But then you will need to use your own .xml files and modify the thresholds.xml file. You can find some information about the file format for the threshold.xml file here: http://www.imagemagick.org/Usage/quantize/#diy_threshold. The xml files can be found here: https://magick.codeplex.com/SourceControl/latest#Magick.NET.Wrapper/Resources/xml/ and the documentation page has an example on how you can initialize the Magick.NET environment with your own xml files.
Sep 11, 2015 at 10:25 PM
Many thanks for the info, it is still not clear to me how to control the number of colors with ordered dither maps.
I always endup in 8 colors using "hlines12x4" for example.
If I use .Quantize I can set .colors but I don't like the floydSteinberg resulting picture.
What if I need 6 or 5 maximum but I want to use dither maps ?

How can I get using VB.Net and Magick.Net the list of colors used by a picture and the count of pixels for each one ?

Many thanks in advance
Paolo*
Coordinator
Sep 12, 2015 at 7:13 AM
Edited Sep 12, 2015 at 7:14 AM
I am also not an expert on ordered dither maps. Maybe you could ask your question on the ImageMagick forum (http://www.imagemagick.org/discourse-server/) and then I can help you translate the command line back to C#.

You can use the Histogram method of the MagickImage class to get a count per color in the image.