https://github.com/zeozeozeo/imagesim
Fast and simple algorithm for comparing the similarity of 2 images in pure Go.
https://github.com/zeozeozeo/imagesim
difference golang image image-search image-similarity pure-go similarity
Last synced: 2 months ago
JSON representation
Fast and simple algorithm for comparing the similarity of 2 images in pure Go.
- Host: GitHub
- URL: https://github.com/zeozeozeo/imagesim
- Owner: zeozeozeo
- License: unlicense
- Created: 2022-11-16T13:35:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-16T13:39:09.000Z (over 2 years ago)
- Last Synced: 2025-01-31T19:39:59.157Z (4 months ago)
- Topics: difference, golang, image, image-search, image-similarity, pure-go, similarity
- Language: Go
- Homepage: https://pkg.go.dev/github.com/zeozeozeo/imagesim
- Size: 966 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://goreportcard.com/report/github.com/zeozeozeo/imagesim)

# image SIMililarityThis is a fast and simple algorithm for comparing the similarity of 2 images. Pure Go and zero dependencies.
# [Example](https://github.com/zeozeozeo/imagesim/blob/main/internal/example/compare.go)
## The hashing algorithm
1. Resize the images to be 8 by 8 pixels. This is done by a very simple resizing algorithm.
2. Make the images grayscale.
3. Get the bitmask image value threshold. This is done by getting the average gray value in the image.
4. Calculate the bitmask of the image, skip all values that are smaller than the threshold.## The hash comparing algorithm
1. Calculate the [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) between two hashes.
2. Divide it by the amount of bits in the hash (this library uses uint64 for hashes, so 64).