MCPcopy Index your code
hub / github.com/gonum/plot / cmpImg

Function cmpImg

cmpimg/cmpimg.go:121–149  ·  view source on GitHub ↗
(v1, v2 image.Image, delta float64)

Source from the content-addressed store, hash-verified

119}
120
121func cmpImg(v1, v2 image.Image, delta float64) bool {
122 img1, ok := v1.(*image.RGBA)
123 if !ok {
124 img1 = newRGBAFrom(v1)
125 }
126
127 img2, ok := v2.(*image.RGBA)
128 if !ok {
129 img2 = newRGBAFrom(v2)
130 }
131
132 if len(img1.Pix) != len(img2.Pix) {
133 return false
134 }
135
136 max := delta * delta
137 bnd := img1.Bounds()
138 for x := bnd.Min.X; x < bnd.Max.X; x++ {
139 for y := bnd.Min.Y; y < bnd.Max.Y; y++ {
140 c1 := img1.RGBAAt(x, y)
141 c2 := img2.RGBAAt(x, y)
142 if !yiqEqApprox(c1, c2, max) {
143 return false
144 }
145 }
146 }
147
148 return true
149}
150
151// yiqEqApprox compares the colors of 2 pixels, in the NTSC YIQ color space,
152// as described in:

Callers 1

EqualApproxFunction · 0.85

Calls 3

newRGBAFromFunction · 0.85
yiqEqApproxFunction · 0.85
BoundsMethod · 0.80

Tested by

no test coverage detected