fuzzy

package
v0.0.0-...-50fdeb8 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matcher

type Matcher struct {
	MaxDifferentPixels            int
	PixelDeltaThreshold           int
	PixelPerChannelDeltaThreshold int
	IgnoredBorderThickness        int
	// contains filtered or unexported fields
}

Matcher is an image matching algorithm.

It considers two images to be equal if the following conditions are met:

  • Both images are of equal size.
  • The total number of different pixels is below MaxDifferentPixels.
  • If PixelDeltaThreshold > 0: There are no pixels such that dR + dG + dB + dA > PixelDeltaThreshold, where d{R,G,B,A} are the per-channel deltas.
  • Else: There are no pixels such that max(dR, dG, dB, dA) > PixelPerChannelDeltaThreshold, where d{R,G,B,A} are the per-channel deltas.
  • If IgnoredBorderThickness > 0, then the first/last IgnoredBorderThickness rows/columns will be ignored when performing the above pixel-wise comparisons.

Note that if MaxDifferentPixels = 0 this algorithm will perform an exact image comparison. If that is intentional, consider using exact matching instead (e.g. by not specifying the image_matching_algorithm optional key).

This algorithm assumes 8-bit channels.

Valid PixelDeltaThreshold values are 0 to 1020 inclusive (0 <= d{R,G,B,A} <= 255, thus 0 <= dR + dG + dB + dA <= 255*4 = 1020).

Valid PixelPerChannelDelta values are 0 to 255 inclusive.

func (*Matcher) Match

func (m *Matcher) Match(expected, actual image.Image) bool

Match implements the imagmatching.Matcher interface.

func (*Matcher) MaxPixelDelta

func (m *Matcher) MaxPixelDelta() int

MaxPixelDelta returns the maximum per-channel delta sum between the last two matched images.

func (*Matcher) NumDifferentPixels

func (m *Matcher) NumDifferentPixels() int

NumDifferentPixels returns the number of different pixels between the last two matched images.

func (*Matcher) PixelComparisonMethod

func (m *Matcher) PixelComparisonMethod() string

PixelComparisonMethod returns whether pixel comparison is being done using the sum of per-channel differences or the max per-channel difference.

Jump to

Keyboard shortcuts

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