phash

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2022 License: MIT Imports: 12 Imported by: 2

README

phash Coverage ci.yml

A simple perceptual hashing library in Go.

Usage :

f, err := os.Open("image.jpg")
if err != nil {
    panic(err)
}
defer f.Close()
img, _, err := image.Decode(f)
if err != nil {
    panic(err)
}
hash1 := phash.DTC(img)
hash2 := phash.DTC(img)

if phash.Distance(hash1, hash2) == 0 {
    fmt.Println("these images sure do look alike.")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DTC

func DTC(img image.Image) (phash uint64)

DTC computes the perceptual hash for img using phash dtc image technique.

  1. Reduce size to 32x32
  2. Reduce color to greyscale
  3. Compute the DCT.
  4. Reduce the DCT to 8x8 in order to keep high frequencies.
  5. Compute the median value of 8x8 dtc.
  6. Further reduce the DCT into an uint64.

func Distance added in v0.2.0

func Distance(a, b uint64) int

Distance returns the distance between two hashes by calculating the number of different bits in the hash

func FindKeypoints

func FindKeypoints(src image.Image) geometry.Points

FindKeypoints returns a list of points that are interesting/key points It does that by detecting corners using cornerdectect.Fast9

func FromTriangles

func FromTriangles(src image.Image, triangles []triangle.Triangle) []uint64

FromTriangles calculates 3 perceptual hash of src per triangles.

A triangle is transformed into it's equilateral version then we run a DTC on the 3 different angles of the triangle.

When two triangle have the same perceptual hash, it means that the features in the triangle are perceptually similar.

Triangles could come from FindKeypoints or your own library.

This function will start a goroutine per CPU.

Types

This section is empty.

Directories

Path Synopsis
cmd
dtc
rotate90
transformation invariant image phash based on https://github.com/pippy360/transformationInvariantImageSearch
transformation invariant image phash based on https://github.com/pippy360/transformationInvariantImageSearch
tii
transformation invariant image phash based on https://github.com/pippy360/transformationInvariantImageSearch
transformation invariant image phash based on https://github.com/pippy360/transformationInvariantImageSearch

Jump to

Keyboard shortcuts

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