blur

package
v0.0.0-...-6cd0f2a Latest Latest
Warning

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

Go to latest
Published: May 1, 2015 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package blur provides functions for blurring images.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Box

func Box(in image.Image, radius int, style Style) image.Image

Box performs a box blur on the Image given.

func Convolve

func Convolve(in image.Image, weights Kernel, style Style) image.Image

func Convolve2

func Convolve2(in image.Image, a, b Kernel, style Style) image.Image

Perform a convolution with two Kernels in succession.

func Gaussian

func Gaussian(in image.Image, radius int, sigma float64, style Style) image.Image

Gaussian performs a gaussian blur on the Image given.

Types

type Kernel

type Kernel [][]float64

A Kernel is a 2-dimensional array of ratios. A 1-dimensional, horizontal or vertical, kernel can easily be defined by a 2-dimensional array in the obvious manner. The weights are taken as row by column, so kernel[0] references the first row and kernel[i][0] (for all i) is the first column.

func NewHorizontalKernel

func NewHorizontalKernel(width int, f func(x int) float64) Kernel

func NewKernel

func NewKernel(height, width int, f func(x, y int) float64) Kernel

NewKernel creates a new Kernel of the dimensions given, it is populated by the given function which itself is passed the signed x and y offsets from the mid point.

func NewVerticalKernel

func NewVerticalKernel(height int, f func(y int) float64) Kernel

func (Kernel) Height

func (k Kernel) Height() int

Height returns the height of the Kernel.

func (Kernel) Mid

func (k Kernel) Mid() image.Point

Mid returns the centre Point of the Kernel.

func (Kernel) Normalised

func (k Kernel) Normalised() Kernel

Normalised returns a copy of the Kernel where the sum of all entries is 1.

func (Kernel) Width

func (k Kernel) Width() int

Width returns the width of the Kernel.

type Style

type Style float64
const (
	// Ignore edges, may leave them semi-transparent
	IGNORE Style = iota
	// Clamp edges, may leave them looking unblurred
	CLAMP
	// Wrap edges, may change colour of edges
	WRAP
)

Jump to

Keyboard shortcuts

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