nQuant.Master 1.3.1

dotnet add package nQuant.Master --version 1.3.1
NuGet\Install-Package nQuant.Master -Version 1.3.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="nQuant.Master" Version="1.3.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add nQuant.Master --version 1.3.1
#r "nuget: nQuant.Master, 1.3.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install nQuant.Master as a Cake Addin
#addin nuget:?package=nQuant.Master&version=1.3.1

// Install nQuant.Master as a Cake Tool
#tool nuget:?package=nQuant.Master&version=1.3.1

nQuant.cs Color Quantizer

Fast pairwise nearest neighbor based algorithm with C# console

nQuant.cs is a C# color quantizer producing high quality 256 color 8 bit PNG images using an algorithm optimized for the highest quality possible.

Another advantage of nQuant.cs is that it is a .net library that you can integrate nicely with your own C# code while many of the popular quantizers only provide command line implementations. nQuant.cs also provides a command line wrapper in case you want to use it from the command line.

Less artifacts by using advanced dithering techniques such as Generalized Hilbert ("gilbert") space-filling curve and partial Blue noise distribution to diffuse the minimized quantization errors.

If you are using C#, you would call nQuant as follows:

    bool dither = true;
    var quantizer = new PnnQuant.PnnQuantizer();
    using(var bitmap = new Bitmap(sourcePath))
            using (var dest = quantizer.QuantizeImage(bitmap, pixelFormat, maxColors, dither))
                dest.Save(targetPath, ImageFormat.Png);
                System.Console.WriteLine("Converted image: " + Path.GetFullPath(targetPath));
        catch (Exception q)

More importantly, a parallel genetic algorithm called PNNLAB+ is proposed for converting a sequence of similar images under the same palette.<br />

    var alg = new APNsgaIII<PnnLABGAQuantizer>(new PnnLABGAQuantizer(new PnnLABQuantizer(), bitmaps, maxColors));
    alg.Run(999, -Double.Epsilon);
    using (var pGAq = alg.Result) {
        System.Console.WriteLine("\n" + pGAq.Result);
        var imgs = pGAq.QuantizeImage(dither);
        for (int i = 0; i < imgs.Count; ++i) {
            var fname = Path.GetFileNameWithoutExtension(paths[i]);                       
            var destPath = Path.Combine(targetPath, fname) + " - PNNLAB+quant" + maxColors + ".png";
            imgs[i].Save(destPath, ImageFormat.Png);
            System.Console.WriteLine("Converted image: " + Path.GetFullPath(destPath));

OTSU method (OTSU) is a global adaptive binarization threshold image segmentation algorithm. This algorithm takes the maximum inter class variance between the background and the target image as the threshold selection rule.

    var quantizer = new OtsuThreshold.Otsu();
    using(var bitmap = new Bitmap(sourcePath))
            using (var dest = quantizer.ConvertGrayScaleToBinary(bitmap))
                dest.Save(targetPath, ImageFormat.Png);
                System.Console.WriteLine("Converted black and white image: " + Path.GetFullPath(targetPath));
        catch (Exception q)

<p>Example image:<br /><img src="https://user-images.githubusercontent.com/26831069/142559831-f8f6f2ce-487e-4353-8aa1-7845706e7833.png" /></p> <p>Resulted image:<br /><pre><img src="https://user-images.githubusercontent.com/26831069/142559920-88143e07-2787-46a2-a07c-cccf5a39065a.png" /></pre></p>

If you are using the command line. Assuming you are in the same directory as nQuant.exe and nQuant.Master.dll, you would enter: nQuant yourImage.jpg /o yourNewImage.png

To switch algorithms, /a otsu can perform the above black and white conversion.

nQuant will quantize yourImage.jpg and create yourNewImage.png in the same directory.

There are a few configuration arguments you can optionaly use to try and influence how the image gets quantized. These are explained in the console application.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.1 185 10/5/2023
1.3.0 120 8/31/2023
1.2.9 137 6/17/2023
1.2.8 12,041 4/20/2023
1.2.6 705 12/11/2022
1.2.5 252 12/11/2022
1.1.0 2,991 5/18/2020
1.0.0 459 5/18/2020