Coder Social home page Coder Social logo

nquant.cs's Introduction

nQuant.cs Color Quantizer

Fast pairwise nearest neighbor based algorithm with C# console

nQuant 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 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 also provides a command line wrapper in case you want to use it from the command line. To get started: Either download nQuant from this site or add it to your Visual Studio project seamlessly via Nuget. To use Nuget, simply enter Install-Package nQuant from the Package Manager Console. If you do not use Nuget, add nQuant to your project and add a reference to it. If you are using C#, you would call nQuant as follows:

        var quantizer = new PnnQuant.PnnQuantizer();
        using(var bitmap = new Bitmap(sourcePath))
        {
            using (var dest = new Bitmap(bitmap.Width, bitmap.Height, PixelFormat.Format8bppIndexed))
            {
                if (quantizer.QuantizeImage(bitmap, dest, maxColors, true))
                    dest.Save(targetPath, ImageFormat.Png);
            }
        }

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

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.