项目作者: corona10

项目描述 :
Go Perceptual image hashing package
高级语言: Go
项目地址: git://github.com/corona10/goimagehash.git
创建时间: 2017-07-28T17:15:58Z
项目社区:https://github.com/corona10/goimagehash

开源协议:BSD 2-Clause "Simplified" License

下载


GitHub Action
GoDoc
Go Report Card

goimagehash

Inspired by imagehash

A image hashing library written in Go. ImageHash supports:

Installation

  1. go get github.com/corona10/goimagehash

Special thanks to

Usage

  1. func main() {
  2. file1, _ := os.Open("sample1.jpg")
  3. file2, _ := os.Open("sample2.jpg")
  4. defer file1.Close()
  5. defer file2.Close()
  6. img1, _ := jpeg.Decode(file1)
  7. img2, _ := jpeg.Decode(file2)
  8. hash1, _ := goimagehash.AverageHash(img1)
  9. hash2, _ := goimagehash.AverageHash(img2)
  10. distance, _ := hash1.Distance(hash2)
  11. fmt.Printf("Distance between images: %v\n", distance)
  12. hash1, _ = goimagehash.DifferenceHash(img1)
  13. hash2, _ = goimagehash.DifferenceHash(img2)
  14. distance, _ = hash1.Distance(hash2)
  15. fmt.Printf("Distance between images: %v\n", distance)
  16. width, height := 8, 8
  17. hash3, _ := goimagehash.ExtAverageHash(img1, width, height)
  18. hash4, _ := goimagehash.ExtAverageHash(img2, width, height)
  19. distance, _ = hash3.Distance(hash4)
  20. fmt.Printf("Distance between images: %v\n", distance)
  21. fmt.Printf("hash3 bit size: %v\n", hash3.Bits())
  22. fmt.Printf("hash4 bit size: %v\n", hash4.Bits())
  23. var b bytes.Buffer
  24. foo := bufio.NewWriter(&b)
  25. _ = hash4.Dump(foo)
  26. foo.Flush()
  27. bar := bufio.NewReader(&b)
  28. hash5, _ := goimagehash.LoadExtImageHash(bar)
  29. }

Release Note

v1.1.0

  • The performance of Perceptionhash is enhanced.

v1.0.3

  • Add workflow for GithubAction
  • Fix typo on the GoDoc for LoadImageHash

v1.0.2

  • go.mod is now used for install goimagehash

v1.0.1

  • Perception/ExtPerception hash creation times are reduced

v1.0.0

IMPORTANT
goimagehash v1.0.0 does not have compatible with the before version for future features

v0.3.0

  • Support DifferenceHashExtend.
  • Support AverageHashExtend.
  • Support PerceptionHashExtend by @TokyoWolFrog.

v0.2.0

  • Perception Hash is updated.
  • Fix a critical bug of finding median value.

v0.1.0

  • Support Average hashing
  • Support Difference hashing
  • Support Perception hashing
  • Use bits.OnesCount64 for computing Hamming distance by @dominikh
  • Support hex serialization methods to ImageHash by @brunoro