imagetest

package module
v0.0.0-...-5d4bf8f Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2014 License: MIT Imports: 4 Imported by: 7

README

What's that?

The imagetest package asserts the equality of two images between a tolerance interval using a naive distance algorithm. It's useful in black-box testing for comparing the expected screen with the actual one. In future it may grow in a complete suite of matching tool for images.

Install

go get https://github.com/remogatto/imagetest

Example

See imagetest_test.go.

License

See LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// A default scaler.
	Scale = Scaler{}

	// A default centerer with black fill color.
	Center = Centerer{color.Black}
)

Functions

func CompareDistance

func CompareDistance(img1 image.Image, img2 image.Image, adjust Adjuster) (distance float64)

Compare compares two images with a naive "distance" algorithm. It returns a distance value from 0 (identical images) to 1 (totally different images). If adjust is not nil, Images are adjusted by before comparaison.

Types

type Adjuster

type Adjuster interface {
	// Adjust adjusts the images before the comparaison.
	Adjust(img1, img2 image.Image) (image.Image, image.Image)
}

type Centerer

type Centerer struct {
	FillColor color.Color
}

Centerer is an Adjuster that aligns the centers's images and fill the background of smaller image with a color. Default fill color is black.

func (Centerer) Adjust

func (c Centerer) Adjust(img1, img2 image.Image) (image.Image, image.Image)

Adjust adjusts the two images aligning ther centers. The background of the smaller image is filled with FillColor. The returned images are of the same size.

type Scaler

type Scaler struct{}

Scaler is an Adjuster that resize the two images to the same size of the smaller one.

func (Scaler) Adjust

func (s Scaler) Adjust(img1, img2 image.Image) (image.Image, image.Image)

Adjust adjusts the size of the two images to fit the size of the smaller one.

Jump to

Keyboard shortcuts

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