gitee.com/h79/goutils@v1.22.10/common/images/images_test.go (about) 1 package images 2 3 import "testing" 4 5 func TestHistogram(t *testing.T) { 6 hist1 := NewHistogram() 7 if er := hist1.OpenFile("./2.png"); er != nil { 8 t.Error(er) 9 } 10 11 hist2 := NewHistogram() 12 if er := hist2.OpenFile("./3.png"); er != nil { 13 t.Error(er) 14 } 15 16 t.Log("match: ", hist1.Match(hist2)) 17 } 18 19 func TestDistance(t *testing.T) { 20 hash1 := NewPHash() 21 if er := hash1.OpenFile("./1.jpg"); er != nil { 22 t.Error(er) 23 } 24 25 hash2 := NewPHash() 26 if er := hash2.OpenFile("./1-1.jpg"); er != nil { 27 t.Error(er) 28 } 29 30 t.Log("match: ", hash1.Match(hash2)) 31 }