Apply a sepia filter to an image
I would like to know if there is a way to improve the code.

// Part to improve from HERE
r &gt;&gt;= 8
g &gt;&gt;= 8
b &gt;&gt;= 8
a &gt;&gt;= 8

r = uint32(math.Min(.393*float64(r)+.769*float64(g)+.189*float64(b), 255))
g = uint32(math.Min(.349*float64(r)+.686*float64(g)+.168*float64(b), 255))
b = uint32(math.Min(.272*float64(r)+.534*float64(g)+.131*float64(b), 255))

newColor := color.RGBA{
  uint8(r),
  uint8(g),
  uint8(b),
  uint8(a),
}
// to HERE





In Go, readability is paramount. I would write:

// Part to improve from HERE

rr := float64(r &gt;&gt; 8)
gg := float64(g &gt;&gt; 8)
bb := float64(b &gt;&gt; 8)
aa := a &gt;&gt; 8

newColor := color.RGBA{
    R: uint8(math.Min(.393*rr+.769*gg+.189*bb, 255)),
    G: uint8(math.Min(.349*rr+.686*gg+.168*bb, 255)),
    B: uint8(math.Min(.272*rr+.534*gg+.131*bb, 255)),
    A: uint8(aa),
}

// to HERE