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

Function AverageImageColor

primitive/util.go:188–205  ·  view source on GitHub ↗
(im image.Image)

Source from the content-addressed store, hash-verified

186}
187
188func AverageImageColor(im image.Image) color.NRGBA {
189 rgba := imageToRGBA(im)
190 size := rgba.Bounds().Size()
191 w, h := size.X, size.Y
192 var r, g, b int
193 for y := 0; y < h; y++ {
194 for x := 0; x < w; x++ {
195 c := rgba.RGBAAt(x, y)
196 r += int(c.R)
197 g += int(c.G)
198 b += int(c.B)
199 }
200 }
201 r /= w * h
202 g /= w * h
203 b /= w * h
204 return color.NRGBA{uint8(r), uint8(g), uint8(b), 255}
205}

Callers

nothing calls this directly

Calls 1

imageToRGBAFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…