{"id":41585496,"url":"https://github.com/mcychan/nquantgpp","last_synced_at":"2026-04-06T08:02:26.803Z","repository":{"id":171349157,"uuid":"647784607","full_name":"mcychan/nQuantGpp","owner":"mcychan","description":"nQuantGpp includes top 10 color quantization algorithms for g++ producing high quality optimized images.","archived":false,"fork":false,"pushed_at":"2026-01-18T03:34:41.000Z","size":689,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-18T14:59:43.233Z","etag":null,"topics":["blue-noise","cielab","color-quantization","dithering","dl3-quantization","error-diffusion","hilbert-curve","image-processing","median-cut","opencv","otsu-threshold","otsu-thresholding","quantization-algorithms","transparency","unsupervised-clustering"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcychan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-05-31T14:10:24.000Z","updated_at":"2026-01-18T03:34:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"19d9dac4-84ee-40d9-87c0-9dd55ee11736","html_url":"https://github.com/mcychan/nQuantGpp","commit_stats":null,"previous_names":["mcychan/nquantgpp"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/mcychan/nQuantGpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcychan%2FnQuantGpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcychan%2FnQuantGpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcychan%2FnQuantGpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcychan%2FnQuantGpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcychan","download_url":"https://codeload.github.com/mcychan/nQuantGpp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcychan%2FnQuantGpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28721992,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T08:27:05.734Z","status":"ssl_error","status_checked_at":"2026-01-24T08:27:01.197Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blue-noise","cielab","color-quantization","dithering","dl3-quantization","error-diffusion","hilbert-curve","image-processing","median-cut","opencv","otsu-threshold","otsu-thresholding","quantization-algorithms","transparency","unsupervised-clustering"],"created_at":"2026-01-24T09:03:24.851Z","updated_at":"2026-01-24T09:03:29.415Z","avatar_url":"https://github.com/mcychan.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nQuantGpp\n\u003cp align=\"justify\"\u003enQuantGpp includes top 10 color quantization algorithms for g++ producing high quality optimized images. I enhance each of the algorithms to support semi transparent images. \nnQuantGpp also provides a command line wrapper in case you want to use it from the command line.\u003c/p\u003e\n\n\u003cp align=\"justify\"\u003enQuantGpp is ported from nQuantCpp which migrates to OpenCV to leverage the deep learning features of such popular library.\u003cbr /\u003e\nPNG8 or PNG1 is used because it's the only widely supported format which can store partially transparent images.\u003c/p\u003e\n\u003cp\u003eFor Windows users, it is assumed that you have downloaded and extracted OpenCV 4 to the public user folder %PUBLIC%.\u003cbr /\u003e\nIn addition, nQuantGpp depends on OpenCV library opencv_world4xx.dll, it also required opencv_videoio_ffmpeg4xx_64.dll to open gif files.\u003c/p\u003e\n\u003cp align=\"justify\"\u003eFor Linux users, please refer to Dockerfile to install libopencv-dev and compile by CMake.\u003c/p\u003e\n\u003cp align=\"justify\"\u003eIf you are using the command line. Assuming you are in the same directory as nQuantGpp.exe, you could enter: `nQuantGpp yourImage.jpg /m 16`. To avoid dot gain, `/d n` can set the dithering to false. However, false contours will be resulted for gradient color zones.\u003cbr /\u003e\nnQuantGpp will quantize yourImage.jpg and create yourImage-PNNLABquant16.png in the same directory.\u003c/p\u003e\nLet's catch up with the races: Ready, Go!!!\u003cp /\u003e\n\u003cp\u003eOriginal photo of sailing\u003cbr /\u003e\u003cimg src=\"https://mcychan.github.io/PnnQuant.js/demo/img/sailing_2020.jpg\" /\u003e\u003c/p\u003e\n\u003cp\u003eReduced to 256 colors by NeuQuant Neural-Net Quantization Algorithm\u003cbr /\u003e\u003cimg src=\"https://github.com/mcychan/nQuantGpp/assets/26831069/e149efbc-0d82-4ee9-9cf8-f94168438079\" /\u003e\u003c/p\u003e\n\u003cp\u003eReduced to 256 colors by Fast pairwise nearest neighbor based algorithm\u003cbr /\u003e\u003cimg src=\"https://github.com/mcychan/nQuantGpp/assets/26831069/7eb32e78-b920-4868-be87-104c1220ce20\" /\u003e\u003c/p\u003e\n\u003cp\u003eReduced to 256 colors by Fast pairwise nearest neighbor based algorithm with CIELAB color space\u003cbr /\u003e\u003cimg src=\"https://github.com/mcychan/nQuantGpp/assets/26831069/d2786a4c-0b43-4837-8a90-99d2fa0f3945\" /\u003e\u003c/p\u003e\n\u003cp\u003eReduced to 256 colors by Xialoin Wu's fast optimal color Quantization Algorithm\u003cbr /\u003e\u003cimg src=\"https://github.com/mcychan/nQuantGpp/assets/26831069/7d8ed4cf-6dae-4bf6-8b7a-86558e19fc43\" /\u003e\u003c/p\u003e\n\u003chr /\u003e\n\u003cp align=\"justify\"\u003eMost color quantization algorithms are based on K-Means clustering, can you see the minor but significant color is loss for the NeuQuant Neural-Net Quantization Algorithm?\u003cbr /\u003e\nHowever, keeping the minor but significant color which in terms giving rise to false contours because some dominant colors are not selected into palette.\u003c/p\u003e\n\u003cp align=\"justify\"\u003eTo select the most fitted palette, firstly reducing the color depth to 16 bits, ARGB4444 suits best for semi-transparent images. This means the value of alpha less than 16 will be converted to transparent color. For images having alpha channel value either 255 or 0, ARGB1555 is preferred.\u003c/p\u003e\n\u003cp align=\"justify\"\u003eFast pairwise nearest neighbor based algorithm is updated to use YUV channels rather than RGB channels. Then the resulted image become less visible artifacts.\u003c/p\u003e\n\u003cp align=\"justify\"\u003eColor quantization algorithms conduct palette selection, Spatial color quantization algorithm; Efficient, Edge-Aware, Combined Color Quantization and Dithering algorithm conduct dithering at the same time.\u003cbr /\u003e\nThe color dithering functions may not belong to such algorithms. However, dithering leads to regular artifacts are very common like hue shift and dot gain.\u003c/p\u003e\n\u003cp align=\"justify\"\u003eColor dithering using a generalized Hilbert (\"gilbert\") space-filling curve produces clustered approximations to images with less regular artifacts which is O(n) instead of O(n\u003csup\u003e2\u003c/sup\u003e) of the classical dithering algorithm. Most importantly, \"gilbert\" required to set the maximum error acceptance level to avoid undesired artifacts. To deal with the false contours, partial Blue noise distribution is used.\u003c/p\u003e\n\u003cp align=\"justify\"\u003eOn top of color dithering, Blue noise dithered sampling use high-quality stratified sampling patterns, which minimizes the low-frequency content in the output noise. It correlates the pixel estimates in a way that fits the implicative patterns of the original image. Unfortunately, using Blue noise distribution entirely would reduce the effect of color dithering and cannot resolve the color banding in gradient problem during CQ.\u003c/p\u003e\n\u003cp align=\"justify\"\u003eThere are many magic numbers in Fast pairwise nearest neighbor based algorithm with CIELAB color space. Due to different framework returns different pixel values, these magic numbers are fine tuned by evaluating the highest PSNR and SSIM on testing images. However, this will arouse the overfitting problem.\u003c/p\u003e\n\u003cp align=\"justify\"\u003eFor the future development, it is hoped that the models can be saved to files and load them up again to make better CQ.\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcychan%2Fnquantgpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcychan%2Fnquantgpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcychan%2Fnquantgpp/lists"}