• Stars
    star
    167
  • Rank 226,635 (Top 5 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 8 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Various dithering algorithms implemented in Go

dithergo

CI Go Reference license

Dithergo is a simple Go library implementing various dithering algorithm to produce halftone images. It supports color and monochrome image outputs.

The library implements the following dithering methods: Floyd Steinberg, Atkinson, Burkes, Stucki, Sierra-2, Sierra-3, Sierra-Lite. All of these algorithms have something in common: they diffuse the error in two dimensions, but they always push the error forward, never backward.

We can represent this with the following diagram:

         X   7   5 
 3   5   7   5   3
 1   3   5   3   1

       (1/48)

where X represent the current pixel processed. The fraction at the bottom represents the divisor for the error. Above is the the Floyd-Steinberg dithering algorithm which can be transposed into the following Go code:

ditherers = []dither.Dither{
	dither.Dither{
		"FloydSteinberg",
		dither.Settings{
			[][]float32{
				[]float32{ 0.0, 0.0, 0.0, 7.0 / 48.0, 5.0 / 48.0 },
				[]float32{ 3.0 / 48.0, 5.0 / 48.0, 7.0 / 48.0, 5.0 / 48.0, 3.0 / 48.0 },
				[]float32{ 1.0 / 48.0, 3.0 / 48.0, 5.0 / 48.0, 3.0 / 48.0, 1.0 / 48.0 },
			},
			float32(multiplier),
		},
	},
}

You can plug in any dithering algorithm, so the library can be further extended.

Installation

$ go get -u -v github.com/esimov/dithergo

Running

Type go run cmd/main.go --help to check all the supported commands. The library supports the following commands:

Usage of commands:
  -e string
    	Generates & exports the color and greyscale mode halftone images. 
	Options: 'all', 'color', 'mono' (default "all")
  -em float
    	Error multiplier (default 1.18)
  -o string
    	Output folder
  -t	Option to export the tresholded image (default true)

You can run all of the supported dithering algorithms at once, or you can run a specific one from the cmd directory.

Results:

Input

The below images are generated with the default options using Michelangelo's David statue as sample image.

Color Monochrome
Atkinson Atkinson
Burkes Burkes
Floyd-Steinberg Floyd-Steinberg
Sierra-2 Sierra-2
Sierra-3 Sierra-3
Sierra-Lite Sierra-Lite
Stucki Stucki

Author

License

Copyright Β© 2018 Endre Simo

This software is distributed under the MIT license found in the LICENSE file.

More Repositories

1

caire

Content aware image resize library
Go
10,356
star
2

pigo

Fast face detection, pupil/eyes localization and facial landmark points detection library in pure Go.
Go
4,386
star
3

triangle

Convert images to computer generated art using delaunay triangulation.
Go
2,038
star
4

diagram

CLI app to convert ASCII arts into hand drawn diagrams.
Go
835
star
5

stackblur-go

A fast, almost Gaussian Blur implementation in Go
Go
256
star
6

forensic

Copy-move image forgery detection library.
Go
136
star
7

gobrot

Mandelbrot image renderer in Go
Go
105
star
8

gogu

A comprehensive, reusable and efficient concurrent-safe generics utility functions and data structures library.
Go
97
star
9

colorquant

Go library for color quantization and dithering
Go
85
star
10

legoizer

A tool to convert images to Lego bricks.
Go
80
star
11

ascii-fluid

Terminal based ASCII fluid simulation controlled by your webcam. 🌊
Go
66
star
12

colidr

Coherent Line Drawing implementation in Go.
Go
55
star
13

pigo-wasm-demos

Webassembly demos showcasing the Pigo face detection library.
Go
53
star
14

gifter

Gif image renderer running in terminal.
Go
44
star
15

gospline

Implementing b-spline curves in Go
Go
37
star
16

cloth-physics

Desktop application for cloth physics simulation using Gio GUI.
Go
37
star
17

triangle-app

Desktop application for Triangle.
JavaScript
35
star
18

pigo-face-tracking

Play games with your head. A face tracking application using the Pigo library.
Go
27
star
19

asciibrot

ASCII mandelbrot fractal running in terminal
Go
22
star
20

facemask

Overlay a mask over a person's face
Go
17
star
21

pigo-openfaas-faceblur

OpenFaaS faceblur function using the Pigo face detector library. (https://github.com/esimov/pigo)
Go
17
star
22

minecraft.js

Simplex noise based minecraft map generator
JavaScript
17
star
23

caire-openfaas

OpenFaaS function for Caire, the content aware image resize library. (https://github.com/esimov/caire)
Go
13
star
24

pigo-openfaas

OpenFaaS function for face detection using the Pigo library. (https://github.com/esimov/pigo)
Go
12
star
25

openfaas-coherent-line-drawing

Coherent Line Drawing OpenFaaS function based on https://github.com/esimov/colidr
Go
11
star
26

gomp

Alpha compositing operations and blending modes in Go.
Go
10
star
27

pigo-gocv-benchmark

Pigo vs GoCV face detection benchmark comparison
Go
4
star
28

simplexnoise.js

Javascript simplex noise implementation based on Stefan Gustavson paper: http://webstaff.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
JavaScript
3
star
29

homebrew-triangle

Brew formula for Triangle.
Ruby
2
star
30

go-arena

Testing and benchmarking the new experimental Go memory arenas.
Go
2
star
31

talks

Talks I have given
TeX
1
star
32

flash-experiments

Old Flash (ActionScript3) experiments
ActionScript
1
star