cmpimg

package
v0.9.1-0...-d6b52a6 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package cmpimg compares the raw representation of images taking into account idiosyncracies related to their underlying format (SVG, PDF, PNG, ...).

Index

Constants

This section is empty.

Variables

View Source
var GenerateTestData = flag.Bool("regen", false, "Uses the current state to regenerate the test data.")

Functions

func CheckPlot

func CheckPlot(ExampleFunc func(), t *testing.T, filenames ...string)

CheckPlot checks a generated plot against a previously created reference. If GenerateTestData = true, it regenerates the reference. For image.Image formats, a base64 encoded png representation is output to the testing log when a difference is identified.

func CheckPlotApprox

func CheckPlotApprox(ExampleFunc func(), t *testing.T, delta float64, filenames ...string)

CheckPlotApprox checks a generated plot against a previously created reference. The normalized delta parameter describes how tight the matching should be performed, where delta=0 expresses a perfect match, and delta=1 a very loose match. If GenerateTestData = true, it regenerates the reference. For image.Image formats, a base64 encoded png representation is output to the testing log when a difference is identified.

func Diff

func Diff(dst draw.Image, a, b image.Image) image.Rectangle

Diff calculates an intensity-scaled difference between images a and b and places the result in dst, returning the intersection of a, b and dst. It is the responsibility of the caller to construct dst so that it will overlap with a and b. For the purposes of Diff, alpha is not considered.

Diff is not intended to be used for quantitative analysis of the difference between the input images, but rather to highlight differences between them for testing purposes, so the calculation is rather naive.

func Equal

func Equal(typ string, raw1, raw2 []byte) (bool, error)

Equal takes the raw representation of two images, raw1 and raw2, together with the underlying image type ("eps", "jpeg", "jpg", "pdf", "png", "svg", "tiff"), and returns whether the two images are equal or not.

Equal may return an error if the decoding of the raw image somehow failed.

func EqualApprox

func EqualApprox(typ string, raw1, raw2 []byte, delta float64) (bool, error)

EqualApprox takes the raw representation of two images, raw1 and raw2, together with the underlying image type ("eps", "jpeg", "jpg", "pdf", "png", "svg", "tiff"), a normalized delta parameter to describe how close the matching should be performed (delta=0: perfect match, delta=1, loose match) and returns whether the two images are equal or not.

EqualApprox may return an error if the decoding of the raw image somehow failed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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