(gamma float64)
| 39 | } |
| 40 | |
| 41 | func (h *Heatmap) Image(gamma float64) *image.Gray16 { |
| 42 | im := image.NewGray16(image.Rect(0, 0, h.W, h.H)) |
| 43 | var hi uint64 |
| 44 | for _, h := range h.Count { |
| 45 | if h > hi { |
| 46 | hi = h |
| 47 | } |
| 48 | } |
| 49 | i := 0 |
| 50 | for y := 0; y < h.H; y++ { |
| 51 | for x := 0; x < h.W; x++ { |
| 52 | p := float64(h.Count[i]) / float64(hi) |
| 53 | p = math.Pow(p, gamma) |
| 54 | im.SetGray16(x, y, color.Gray16{uint16(p * 0xffff)}) |
| 55 | i++ |
| 56 | } |
| 57 | } |
| 58 | return im |
| 59 | } |