Go to file
Dominik Honnef ad2b6ded3b Use bits.OnesCount64 when available
Benchmark on i7-2600k, which has the POPCNT instruction:

name                 old time/op  new time/op  delta
DistanceIdentical-8  5.08ns ± 0%  1.01ns ± 1%  -80.07%  (p=0.008 n=5+5)
DistanceDifferent-8  81.5ns ± 2%   1.0ns ± 0%  -98.76%  (p=0.016 n=5+4)

Benchmark on Cavium Octeon, a MIPS64 platform with no dedicated
instruction:

name                 old time/op  new time/op  delta
DistanceIdentical-2   120ns ± 6%   144ns ± 5%  +19.93%  (p=0.008 n=5+5)
DistanceDifferent-2   656ns ± 4%   144ns ± 4%  -78.09%  (p=0.008 n=5+5)
2018-05-02 23:52:38 +09:00
_examples [goimagehash] First implement. 2017-07-31 22:47:14 +09:00
etcs Update docs. 2017-07-31 23:29:35 +09:00
transforms Update docs. 2017-07-31 23:29:35 +09:00
vendor/github.com/nfnt/resize [goimagehash] First implement. 2017-07-31 22:47:14 +09:00
.gitignore Initial commit 2017-07-29 02:15:59 +09:00
.travis.yml goimagehash: Add codecov 2018-04-01 16:53:44 +09:00
AUTHORS.md Use bits.OnesCount64 when available 2018-05-02 23:52:38 +09:00
CODEOWNERS [goimagehash] First implement. 2017-07-31 22:47:14 +09:00
doc.go [goimagehash] First implement. 2017-07-31 22:47:14 +09:00
Gopkg.lock [goimagehash] First implement. 2017-07-31 22:47:14 +09:00
Gopkg.toml [goimagehash] First implement. 2017-07-31 22:47:14 +09:00
hashcompute_test.go Use bits.OnesCount64 when available 2018-05-02 23:52:38 +09:00
hashcompute.go Update docs. 2017-07-31 23:29:35 +09:00
imagehash18.go Use bits.OnesCount64 when available 2018-05-02 23:52:38 +09:00
imagehash19.go Use bits.OnesCount64 when available 2018-05-02 23:52:38 +09:00
imagehash_test.go added serialization unit tests 2017-11-17 09:56:54 +09:00
imagehash.go Use bits.OnesCount64 when available 2018-05-02 23:52:38 +09:00
LICENSE Initial commit 2017-07-29 02:15:59 +09:00
README.md goimagehash: Add badge 2018-04-01 16:55:03 +09:00

Build Status GoDoc Go Report Card Coverage Status

goimagehash

Inspired by imagehash

A image hashing library written in Go. ImageHash supports:

Only support 64bits hash.

Installation

go get github.com/corona10/goimagehash

Special thanks to

Usage

func main() {
        file1, _ := os.Open("sample1.jpg")
        file2, _ := os.Open("sample2.jpg")
        defer file1.Close()
        defer file2.Close()

        img1, _ := jpeg.Decode(file1)
        img2, _ := jpeg.Decode(file2)
        hash1, _ := goimagehash.AverageHash(img1)
        hash2, _ := goimagehash.AverageHash(img2)
        distance, _ := hash1.Distance(hash2)
        fmt.Printf("Distance between images: %v\n", distance)

        hash1, _ = goimagehash.DifferenceHash(img1)
        hash2, _ = goimagehash.DifferenceHash(img2)
        distance, _ = hash1.Distance(hash2)
        fmt.Printf("Distance between images: %v\n", distance)
}