perceptualhash

package module
v0.0.0-...-4277af2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2017 License: MIT Imports: 10 Imported by: 0

README

perceptual-hash

This Library calculates the similarity between two images and returns a value in similarity in percentage

Algorithm

  • Start
  • Open Images to compare
  • Decode them using a suitable Decoder(jpeg, png)
  • Convert them to Grayscale
  • Downsize them to a 9x9(faster, less accurate) or 17x17(slightly slower, but more accurate)
  • Calculate the dHash or differenceHash of each image
  • Compare the two hashes and then calculate the difference in percentage b/w the two
  • End

Notes

You can provide hash length to whatever value you want. Keep in mind, that increasing hash length will decrease performance and might increase accuracy.

Example

Say, You provided 512 bits as hash length, Then,

512 / 2 = 256
sqrt(256) = 16

Now the image is downsized to 17x17.

Inspiration

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateHash

func CalculateHash(img image.Image) string

func CalculateSimilarity

func CalculateSimilarity(firstImagePath, secondImagePath string, hashLength int) (float32, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址