goimagehash

package module
v0.0.0-...-4f81cac Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 8 Imported by: 0

README

go-imagehash

corona10/goimagehash的大小设定不够灵活, 并且我更倾向于使用golang.org/x/image处理缩放

瞎写的玩具, 拍脑袋实现

目前只稍微实现了aHashdHash

李姐万岁

go get github.com/M-Quadra/go-imagehash
妄图支持 施工进度
Average hashing 能跑就行
Difference hashing 能跑就行
Perceptual hashing 能跑就行
Wavelet hashing 咕咕咕咕

手到擒来

  • aHash
aHashData, err := goimagehash.Sum.AHash(img)

自定义

aHash := goimagehash.NewAverageHash(8, 8, draw.CatmullRom)
aHashData, err := aHash.Sum(img)
  • dHash

同理

  • pHash

同上

疑难杂症

受限与不同实现对于缩放与灰度图处理不同, 最终结果会存在差异

有时颜色差异已经作为一种强特征, 但灰度图不适用

imageHash作用范围有限, 只能处理部分问题, 若无必要后续只会随缘更新

有朝一日

作为一鶸, 能用就行, 随缘优化

加个快速求中位数? 虽然数据量着实不大

Documentation

Index

Constants

View Source
const (
	// Sum .Sum() of default imageHash
	Sum = sum(0)
	// SumHex .SumHex() of default imageHash
	SumHex = sumHex(0)
)

Variables

This section is empty.

Functions

func EncodeToString

func EncodeToString(src []byte, hexs int) string

EncodeToString ≈ hex.EncodeToString

func HammingDistance

func HammingDistance(a, b []byte) int

HammingDistance the result will be -1 if len(a)!=len(b)

func NewAverageHash

func NewAverageHash(w, h int, scaler draw.Scaler) aHash

NewAverageHash aHash

recommend w*h = 8*n n ∈ N+

func NewDifferenceHash

func NewDifferenceHash(w, h int, scaler draw.Scaler) dHash

NewDifferenceHash dHash

recommend (w-1)*h = 8*n n ∈ N+
w>1

func NewPerceptualHash

func NewPerceptualHash(w, h, factor int, scaler draw.Scaler) pHash

NewPerceptualHash pHash

recommend w*h = 8*n n ∈ N+, factor = 4

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