Color quantization experiment for golang

bitcrush

Color quantization experiment, version 4

Build

git clone https://github.com/sapphirecat/bitcrush
cd bitcrush
go build

Tested on go1.18beta1 linux/amd64, although there are no 1.18 features in use.

Run

./bitcrush -in image.jpg -out image-332.png -space rgb332
./bitcrush -in image.jpg -out image-y4.png -space y4 -sd

Options:

  • -in Input file, default img.png
  • -out Output file, default output.png
  • -flat Do not dither images
  • -space Color space description (see below)
  • -sd For Y* color spaces, use BT.470 luma weights, not BT.703 (or FCC NTSC)

Color space descriptions

Color space descriptions are made up of an identifier for the color space, followed by the bit depths to reduce each channel to. Each color space may optionally process alpha by appending "A" and including a bit depth for the alpha channel. "_" for a bit depth means to skip quantization for the channel entirely; it will remain 8-bit. "0" is not a valid bit depth.

Supported color spaces:

  1. Y: black-and-white only, similar to desaturating by "luma" in a popular open-source image editor
  2. RGB: Red/Green/Blue, the additive color primaries
  3. HSV: Hue/Saturation/Value, where value expresses black to color
  4. HSL: Hue/Saturation/Lightness, where lightness expresses black to color (at the midpoint) to white
  5. YUV: PAL/SECAM TV, with UV representing blue-yellow and red-green differences
  6. YIQ: NTSC (North America) TV, with IQ representing blue-orange and green-magenta differences

Thus, Y4 means 16 levels of gray (2 raised to the 4th power.) This is identical to YA4_, which leaves the alpha channel unchanged. In contrast, YA41 produces two levels of alpha (fully transparent and fully opaque.)

Previously...

  • blit-crusher in F#
  • Python3/Pillow and Python2/PIL variants

License

MIT.

Owner
Sapphire Cat
Developer and dabbler in things from Web to SNES.
Sapphire Cat
Similar Resources

A CLI tool implemented by Golang to manage `CloudComb` resource

CloudComb CLI tool: comb Get Started comb is a CLI tool for manage resources in CloudComb base on cloudcomb-go-sdk. Support Mac, Linux and Windows. We

Jan 4, 2021

Automatically generate Go (golang) struct definitions from example JSON

gojson gojson generates go struct definitions from json or yaml documents. Example $ curl -s https://api.github.com/repos/chimeracoder/gojson | gojson

Jan 1, 2023

Command Line Alias Manager and Plugin System - Written in Golang

Command Line Alias Manager and Plugin System - Written in Golang

aly - Command Line Alias Manager and Packager Aly offers the simplest way to manage, share, and obtain command line aliases! Warning: This project is

Jun 16, 2022

💻 PTerm | Pretty Terminal Printer A golang module to print pretty text

💻 PTerm | Pretty Terminal Printer A golang module to print pretty text

✨ PTerm is a modern go module to beautify console output. Featuring charts, progressbars, tables, trees, and many more 🚀 It's completely configurable and 100% cross-platform compatible.

Jan 1, 2023

A collection of terminal-based widgets for richer Golang CLI apps.

A collection of terminal-based widgets for richer Golang CLI apps.

Flinch A collection of terminal-based widgets for richer Golang CLI apps. Ships with a library to build your own widgets/TUIs too. Warning: This modul

Jan 7, 2023

A really basic thread-safe progress bar for Golang applications

A really basic thread-safe progress bar for Golang applications

progressbar A very simple thread-safe progress bar which should work on every OS without problems. I needed a progressbar for croc and everything I tr

Jan 1, 2023

Console progress bar for Golang

Terminal progress bar for Go Installation go get github.com/cheggaaa/pb/v3 Documentation for v1 bar available here Quick start package main import (

Jan 9, 2023

Golang terminal dashboard

Golang terminal dashboard

termui termui is a cross-platform and fully-customizable terminal dashboard and widget library built on top of termbox-go. It is inspired by blessed-c

Dec 29, 2022

A library for writing system daemons in golang.

A library for writing system daemons in golang.

go-daemon Library for writing system daemons in Go. Now supported only UNIX-based OS (Windows is not supported). But the library was tested only on Li

Dec 29, 2022
A Go package for converting RGB and other color formats/colorspaces into DMC thread colors (DMC color name and floss number)

go-c2dmc A Go package for converting RGB and other color formats/colorspaces into DMC thread colors (DMC color name and floss number). Implemented as

Jul 25, 2022
Color package for Go (golang)
Color package for Go (golang)

color Color lets you use colorized outputs in terms of ANSI Escape Codes in Go (Golang). It has support for Windows too! The API can be used in severa

Dec 31, 2022
A simple logging interface that supports cross-platform color and concurrency.
A simple logging interface that supports cross-platform color and concurrency.

WLog Package wlog creates simple to use UI structure. The UI is used to simply print to the screen. There a wrappers that will wrap each other to crea

Sep 26, 2022
Draw images in your ANSI terminal with true color
Draw images in your ANSI terminal with true color

___ _____ ____ / _ \/ _/ |/_/ /____ ______ _ Made with love by Eliuk Blau / ___// /_> </ __/ -_) __/ ' \ https://github.com/eliukblau/pix

Dec 14, 2022
Advanced ANSI style & color support for your terminal applications
Advanced ANSI style & color support for your terminal applications

termenv lets you safely use advanced styling options on the terminal. It gathers information about the terminal environment in terms of its ANSI & col

Dec 31, 2022
A Go library for terminal background color detection

go-termbg A Go library for terminal background color detection. The detected color is provided by RGB or theme ( dark or light ). Based on https://git

Jan 4, 2022
Argparse for golang. Just because `flag` sucks

Golang argparse Let's be honest -- Go's standard command line arguments parser flag terribly sucks. It cannot come anywhere close to the Python's argp

Dec 28, 2022
Golang library with POSIX-compliant command-line UI (CLI) and Hierarchical-configuration. Better substitute for stdlib flag.
Golang library with POSIX-compliant command-line UI (CLI) and Hierarchical-configuration. Better substitute for stdlib flag.

cmdr cmdr is a POSIX-compliant, command-line UI (CLI) library in Golang. It is a getopt-like parser of command-line options, be compatible with the ge

Oct 28, 2022
Fully featured Go (golang) command line option parser with built-in auto-completion support.

go-getoptions Go option parser inspired on the flexibility of Perl’s GetOpt::Long. Table of Contents Quick overview Examples Simple script Program wit

Dec 14, 2022
CONTRIBUTIONS ONLY: A Go (golang) command line and flag parser

CONTRIBUTIONS ONLY What does this mean? I do not have time to fix issues myself. The only way fixes or new features will be added is by people submitt

Dec 29, 2022