convolve

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convolve

func Convolve(dst draw.Image, src image.Image, k Kernel) (err error)

Convolve produces dst by applying the convolution kernel k to src.

Types

type Kernel

type Kernel interface {
	// Weights returns the square matrix of weights in row major order.
	Weights() []float64
}

Kernel is a square matrix that defines a convolution.

func NewKernel

func NewKernel(w []float64) (Kernel, error)

NewKernel returns a square convolution kernel.

type SeparableKernel

type SeparableKernel struct {
	X, Y []float64
}

SeparableKernel is a linearly separable, square convolution kernel. X and Y are the per-axis weights. Each slice must be the same length, and have an odd length. The middle element of each slice is the weight for the central pixel. For example, the horizontal Sobel kernel is:

sobelX := &SeparableKernel{
	X: []float64{-1, 0, +1},
	Y: []float64{1, 2, 1},
}

func (*SeparableKernel) Weights

func (k *SeparableKernel) Weights() []float64

Jump to

Keyboard shortcuts

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