MCPcopy
hub / github.com/fogleman/primitive / differencePartial

Function differencePartial

primitive/core.go:91–124  ·  view source on GitHub ↗
(target, before, after *image.RGBA, score float64, lines []Scanline)

Source from the content-addressed store, hash-verified

89}
90
91func differencePartial(target, before, after *image.RGBA, score float64, lines []Scanline) float64 {
92 size := target.Bounds().Size()
93 w, h := size.X, size.Y
94 total := uint64(math.Pow(score*255, 2) * float64(w*h*4))
95 for _, line := range lines {
96 i := target.PixOffset(line.X1, line.Y)
97 for x := line.X1; x <= line.X2; x++ {
98 tr := int(target.Pix[i])
99 tg := int(target.Pix[i+1])
100 tb := int(target.Pix[i+2])
101 ta := int(target.Pix[i+3])
102 br := int(before.Pix[i])
103 bg := int(before.Pix[i+1])
104 bb := int(before.Pix[i+2])
105 ba := int(before.Pix[i+3])
106 ar := int(after.Pix[i])
107 ag := int(after.Pix[i+1])
108 ab := int(after.Pix[i+2])
109 aa := int(after.Pix[i+3])
110 i += 4
111 dr1 := tr - br
112 dg1 := tg - bg
113 db1 := tb - bb
114 da1 := ta - ba
115 dr2 := tr - ar
116 dg2 := tg - ag
117 db2 := tb - ab
118 da2 := ta - aa
119 total -= uint64(dr1*dr1 + dg1*dg1 + db1*db1 + da1*da1)
120 total += uint64(dr2*dr2 + dg2*dg2 + db2*db2 + da2*da2)
121 }
122 }
123 return math.Sqrt(float64(total)/float64(w*h*4)) / 255
124}

Callers 2

AddMethod · 0.85
EnergyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…