/
main.go
56 lines (47 loc) · 1.25 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"fmt"
"image"
"image/jpeg"
"log"
"os"
"time"
imagecolor "github.com/evanoberholster/imageColor"
"github.com/nfnt/resize"
)
func loadImage(fileName string) (image.Image, error) {
file, err := os.Open(fileName)
if err != nil {
log.Fatal(err)
}
// decode jpeg into image.Image
img, err := jpeg.Decode(file)
if err != nil {
log.Fatal(err)
}
defer file.Close()
return img, err
}
func main() {
img, err := loadImage("../../test/img/10.jpg")
if err != nil {
panic(err)
}
imgR := resize.Resize(256, 256, img, resize.Lanczos3)
start := time.Now()
ic := imagecolor.GetImageColors(imgR)
fmt.Println(time.Since(start))
start = time.Now()
//m, std := ic.MeanHue()
//fmt.Printf("Hue\t\t Avg: %.2f\t Std: %.2f\n", m, std)
pc := ic.ProminentColors(0.01)
//fmt.Printf("Lightness\t Avg: %.2f\t Std: %.2f\n", pc.Lightness[0]*100, pc.Lightness[1]*100)
//fmt.Printf("Saturation\t Avg: %.2f\t Std: %.2f\n", pc.Saturation[0]*100, pc.Saturation[1]*100)
//fmt.Printf("Colorfulness\t %.2f\n", pc.Colorfulness*100)
//fmt.Printf("Quantile light\t %.2f\n", pc.Qlightness*100)
fmt.Println(pc.Colors)
fmt.Println("Time Since Start", time.Since(start))
//start = time.Now()
//color.CalcCompositionBoxes(img)
//fmt.Println(time.Since(start))
}