go-phash: github.com/kavu/go-phash Index | Examples | Files

package phash

import "github.com/kavu/go-phash"

Package phash is a simple pHash wrapper library for the Go programming language.

Index

Examples

Package Files

phash.go

func HammingDistanceForFiles Uses

func HammingDistanceForFiles(filea string, fileb string) (interface{}, error)

HammingDistanceForFiles returns a Hamming Distance between two images with a given paths.

Code:

d, err := HammingDistanceForFiles("test_data/jpg/cat.jpg", "test_data/png/gopher.png")
if err != nil {
    panic(err)
}
fmt.Println(d)

Output:

30

func HammingDistanceForHashes Uses

func HammingDistanceForHashes(hasha uint64, hashb uint64) (int, error)

HammingDistanceForHashes returns a Hamming Distance between two images' DCT pHashes.

Code:

d, err := HammingDistanceForHashes(11220389026139797626, 4855808264951085874)
if err != nil {
    panic(err)
}
fmt.Println(d)

Output:

30

func ImageHashDCT Uses

func ImageHashDCT(file string) (uint64, error)

ImageHash returns a DCT pHash for image with a given path.

Code:

hash, err := ImageHashDCT("test_data/jpg/cat.jpg")
if err != nil {
    panic(err)
}
fmt.Println(hash)

Output:

11220389026139797626

Package phash imports 2 packages (graph) and is imported by 2 packages. Updated 2019-07-22. Refresh now. Tools for package owners.