grayscale option
This commit is contained in:
10
blend.go
10
blend.go
@ -118,10 +118,10 @@ func encodeImage(imgData *image.RGBA) {
|
||||
log.Println("Done.")
|
||||
}
|
||||
|
||||
// convert RGBA pixel to grayscale
|
||||
// convert RGBA pixel to grayscale. BT.709 luminosity formula
|
||||
func grayscale(pixel color.Color) color.Color {
|
||||
c := color.RGBAModel.Convert(pixel).(color.RGBA)
|
||||
gray := uint8((c.R + c.G + c.B) / 3)
|
||||
gray := uint8(0.2126*float64(c.R) + 0.7152*float64(c.G) + 0.0722*float64(c.B))
|
||||
return color.RGBA{
|
||||
R: gray,
|
||||
G: gray,
|
||||
@ -167,9 +167,13 @@ func blendColor(color1 color.Color, color2 color.Color) color.Color {
|
||||
g := uint8(blend(oc1.G, oc2.G, oc1.A, oc2.A))
|
||||
b := uint8(blend(oc1.B, oc2.B, oc1.A, oc2.A))
|
||||
a := oc1.A + (1-oc1.A)*oc2.A
|
||||
return color.RGBA{
|
||||
new := color.RGBA{
|
||||
R: r, G: g, B: b, A: a,
|
||||
}
|
||||
if ConfigRegister.Grayscale == true {
|
||||
return grayscale(new)
|
||||
}
|
||||
return new
|
||||
}
|
||||
|
||||
// creates a new rectangle with the min height and width from both images
|
||||
|
||||
Reference in New Issue
Block a user