This is a simple grayscale filter implementening image.Image
. It can be used in place where an image.Image
is expected.
img, err := loadImage("input.jpg")
// check error
err := saveImage(&GrayscaleFilter{img})
//check error
The approach above uses the so-called "luminosity method" for averaging colors
P.S. Learn more about this and other Graphics Programming stuff in Go in my book Generative Art in Go.