diff

package
v0.0.0-...-238917c Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: BSD-3-Clause Imports: 11 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombinedDiffMetric

func CombinedDiffMetric(channelDiffs [4]int, pixelDiffPercent float32) float32

CombinedDiffMetric returns a value in [0, 10] that represents how large the diff is between two images. Implements the MetricFn signature.

func GetNRGBA

func GetNRGBA(img image.Image) *image.NRGBA

GetNRGBA converts the image to an *image.NRGBA in an efficient manner.

Types

type Calculator

type Calculator interface {
	// CalculateDiffs recomputes all diffs for the current grouping, including any digests provided.
	CalculateDiffs(ctx context.Context, grouping paramtools.Params, additional []types.Digest) error
}

type DiffMetrics

type DiffMetrics struct {
	// NumDiffPixels is the absolute number of pixels that are different.
	NumDiffPixels int

	// CombinedMetric is a value in [0, 10] that represents how large the diff is between two
	// images. It is based off the MaxRGBADiffs and PixelDiffPercent.
	CombinedMetric float32

	// PixelDiffPercent is the percentage of pixels that are different. The denominator here is
	// (maximum width of the two images) * (maximum height of the two images).
	PixelDiffPercent float32

	// MaxRGBADiffs contains the maximum difference of each channel.
	MaxRGBADiffs [4]int

	// DimDiffer is true if the dimensions between the two images are different.
	DimDiffer bool
}

DiffMetrics contains the diff information between two images.

func ComputeDiffMetrics

func ComputeDiffMetrics(leftImg *image.NRGBA, rightImg *image.NRGBA) *DiffMetrics

ComputeDiffMetrics computes and returns the diff metrics between two given images.

func PixelDiff

func PixelDiff(img1, img2 image.Image) (*DiffMetrics, *image.NRGBA)

PixelDiff is a utility function that calculates the DiffMetrics and the image of the difference for the provided images.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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