GithubHelp home page GithubHelp logo

dithering's Introduction

Dithering

This is a simple project to demonstrate Floyd–Steinberg dithering as code.

What

Floyd–Steinberg dithering is an image dithering algorithm first published in 1976 by Robert W. Floyd and Louis Steinberg. It is commonly used by image manipulation software, for example when an image is converted into GIF format that is restricted to a maximum of 256 colors.

Why

One common application of dithering is to more accurately display graphics containing a greater range of colors than the display hardware is capable of showing. For example, dithering might be used in order to display a photographic image containing millions of colors on video hardware that is only capable of showing 256 colors at a time. The 256 available colors would be used to generate a dithered approximation of the original image. Without dithering, the colors in the original image would be quantized to the closest available color, resulting in a displayed image that is a poor representation of the original.

How

The algorithm achieves dithering using error diffusion, meaning it pushes (adds) the residual quantization error of a pixel onto its neighboring pixels, to be dealt with later. It spreads the debt out according to the distribution (shown as a map of the neighboring pixels):

calculation

A version of this algorithm can be seen in pkg/dithering.go.

Requirements

Bulid

$ make build

Run

$ ./build/dither -h
$ ./build/dither --in foo.png --out bar.png
$ make examples

Test

$ make test
$ make lint # requires golangci-lint installed

Verify CI Locally

Install act on your machine. This runs GitHub workflows locally.

$ act push

Examples

Original Dithered
american_gothic american_gothic_dith
baby baby_dith
milkyway milkyway_dith
gopher gopher_dith
michelangelo michelangelo_dith
Factor Image
Original factor
1 factor_1
2 factor_2
3 factor_3
4 factor_4

dithering's People

Contributors

themagicalkarp avatar

Watchers

James Cloos avatar  avatar

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.