fastimagehash

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 12 Imported by: 0

README

fastimagehash

MIT License GoDoc Go Report Card Releases

fast image hashing library for Go.

fastimagehash supports:

  • Average Hashing
  • Diffrence Hashing
  • Perception Hashing
  • Wavelet Hashing

Installation

go get github.com/octu0/fastimagehash

Benchmark

The basic score was based on goimagehash.

goos: darwin
goarch: amd64
pkg: github.com/octu0/fastimagehash
cpu: Intel(R) Core(TM) i5-8210Y CPU @ 1.60GHz
BenchmarkAverageHash
BenchmarkAverageHash/goimagehash/8x8
BenchmarkAverageHash/goimagehash/8x8-4         	    2707	    424327 ns/op
BenchmarkAverageHash/goimagehash/32x32
BenchmarkAverageHash/goimagehash/32x32-4       	    1836	    570279 ns/op
BenchmarkAverageHash/fastimagehash/32x32
BenchmarkAverageHash/fastimagehash/32x32-4     	   39634	     29911 ns/op
BenchmarkDifferenceHash
BenchmarkDifferenceHash/goimagehash/9x8
BenchmarkDifferenceHash/goimagehash/9x8-4      	    2277	    456987 ns/op
BenchmarkDifferenceHash/goimagehash/33x32
BenchmarkDifferenceHash/goimagehash/33x32-4    	    1874	    592438 ns/op
BenchmarkDifferenceHash/fastimagehash/33x32
BenchmarkDifferenceHash/fastimagehash/33x32-4  	   33601	     34354 ns/op
BenchmarkPerceptionHash
BenchmarkPerceptionHash/goimagehash/64x64
BenchmarkPerceptionHash/goimagehash/64x64-4    	    1311	    813998 ns/op
BenchmarkPerceptionHash/fastimagehash/64x64
BenchmarkPerceptionHash/fastimagehash/64x64-4  	    7542	    146732 ns/op
BenchmarkWaveletHash
BenchmarkWaveletHash/fastimagehash/64x64
BenchmarkWaveletHash/fastimagehash/64x64-4     	    6045	    191712 ns/op

License

MIT, see LICENSE file for details.

Documentation

Index

Examples

Constants

View Source
const (
	AppName string = "fastimagehash"
	Version string = "0.0.3"
)

Variables

View Source
var (
	ErrHalideBufferRGBA      = errors.New("failed to create_halide_buffer_rgba")
	ErrHalideBufferYUV       = errors.New("failed to create_halide_buffer_yuv")
	ErrHalideBuffer2DUint8   = errors.New("failed to create_halide_buffer_2d_uint8")
	ErrHalideBuffer2DFloat32 = errors.New("failed to create_halide_buffer_2d_float")
)
View Source
var (
	ErrHaarX    = errors.New("failed to haar_x")
	ErrHaarY    = errors.New("failed to haar_y")
	ErrHaarXY   = errors.New("failed to haar_xy")
	ErrHaarXYHi = errors.New("failed to haar_xy_hi")
)
View Source
var (
	ErrYUV444ToRGBA                = errors.New("failed to yuv444_to_rgba")
	ErrYUV422ToRGBA                = errors.New("failed to yuv422_to_rgba")
	ErrYUV420ToRGBA                = errors.New("failed to yuv420_to_rgba")
	ErrYUVNotSupportSubsampleRatio = errors.New("not support subsample ratio")
)
View Source
var (
	ErrScaleNormal = errors.New("failed to scale_normal")
	ErrScaleBox    = errors.New("failed to scale_box")
	ErrScaleLinear = errors.New("failed to scale_linear")
	ErrScaleGauss  = errors.New("failed to scale_gauss")
)
View Source
var (
	ErrDCT = errors.New("failed to dct")
)
View Source
var (
	ErrGrayscale = errors.New("failed to grayscale")
)
View Source
var (
	ErrHash1024InvalidSize = errors.New("invalid hash1024 size")
)

Functions

func ConvertToRGBA added in v0.0.2

func ConvertToRGBA(img image.Image) (*image.RGBA, error)

func YCbCrToRGBA added in v0.0.2

func YCbCrToRGBA(ycbcr *image.YCbCr) (*image.RGBA, error)

Types

type Hash1024

type Hash1024 [16]uint64
Example
h := Hash1024([16]uint64{
	1, 8, 16, 32, 64, 128, 256, 512,
	1, 2, 3, 4, 5, 6, 7,
})
println(h.Hex())
Output:

func AverageHash

func AverageHash(in image.Image) (Hash1024, error)

func DifferenceHash

func DifferenceHash(in image.Image) (Hash1024, error)

func Hash1024FromBytes

func Hash1024FromBytes(data []byte) (Hash1024, error)

func Hash1024FromString

func Hash1024FromString(s string) (Hash1024, error)

func PerceptionHash

func PerceptionHash(in image.Image) (Hash1024, error)

func WaveletHash

func WaveletHash(in image.Image) (Hash1024, error)

func (Hash1024) Bytes

func (h Hash1024) Bytes() []byte

func (Hash1024) Distance

func (h Hash1024) Distance(o Hash1024) int

func (Hash1024) Hex

func (h Hash1024) Hex() string

func (Hash1024) String

func (h Hash1024) String() string

type Hash64

type Hash64 [1]uint64

func (Hash64) Bytes

func (h Hash64) Bytes() []byte

func (Hash64) Distance

func (h Hash64) Distance(o Hash64) int

func (Hash64) Hex

func (h Hash64) Hex() string

func (Hash64) String

func (h Hash64) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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