halftone

package module
v0.0.0-...-6fe2db4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2021 License: MIT Imports: 3 Imported by: 0

README

go-haftone

This repository contains a implemenation of "digital halftoning" algorithm written in go.

Halftone is the reprographic technique that simulates continuous-tone imagery through the use of dots, varying either in size or in spacing, This technique is used by the printer to convert digital image (see more here)

usage

Type go run cmd/haftone.go --help to check the option supported.

Usage:
			go run <image>
Options:
  -method string
    name of the filters to apply, options: 'bayer', 'bayer2', 'bayer4' (default bayer2)
  -output string
		Directory name, where to save the generated images (default "output")`
example

example of result:

Filter Input Output
bayer
bayer2
bayer4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Bayer = newFilter(
	"bayer",
	[][]int32{
		[]int32{0, 2},
		[]int32{3, 1},
	},
)
View Source
var Bayer2 = newFilter(
	"bayer2",
	[][]int32{
		[]int32{0, 8, 2, 10},
		[]int32{12, 4, 14, 6},
		[]int32{3, 11, 1, 9},
		[]int32{15, 7, 13, 5},
	},
)
View Source
var Bayer4 = newFilter(
	"bayer4",
	[][]int32{
		[]int32{0, 48, 12, 60, 3, 61, 15, 63},
		[]int32{32, 16, 44, 28, 35, 19, 47, 21},
		[]int32{8, 56, 4, 52, 11, 59, 7, 55},
		{40, 24, 36, 20, 43, 27, 39, 23},
		{2, 50, 14, 62, 1, 49, 13, 61},
		{34, 18, 46, 30, 33, 17, 45, 29},
		{10, 58, 6, 54, 9, 57, 5, 53},
		{42, 26, 38, 22, 41, 25, 37, 21},
	},
)

Functions

func Halftone

func Halftone(img image.Image, filter Filter) image.Image

Types

type Filter

type Filter struct {
	Name   string
	Matrix [][]int32
}

func (Filter) Max

func (f Filter) Max() int32

func (Filter) Min

func (f Filter) Min() int32

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL