Discover Packages
github.com/zeozeozeo/imagesim
package
module
Version:
v0.0.0-...-38bdb0e
Opens a new window with list of versions in this module.
Published: Nov 16, 2022
License: Unlicense
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 1
Opens a new window with list of known importers.
README
README
¶
image SIMililarity
This is a fast and simple algorithm for comparing the similarity of 2 images. Pure Go and zero dependencies.
The hashing algorithm
Resize the images to be 8 by 8 pixels. This is done by a very simple resizing algorithm.
Make the images grayscale.
Get the bitmask image value threshold. This is done by getting the average gray value in the image.
Calculate the bitmask of the image, skip all values that are smaller than the threshold.
The hash comparing algorithm
Calculate the Hamming distance between two hashes.
Divide it by the amount of bits in the hash (this library uses uint64 for hashes, so 64).
Expand ▾
Collapse ▴
Documentation
¶
Compare compares an image with an image hash.
CompareHashes compares two hashes and returns their similarity (lower = more similar).
CompareImages compares two images and returns the similarity (lower = more similar)
between them. You shouldn't use this because it will calculate the hash for both images
at the same time, instead you should only calculate the hash once by calling Hash(img),
and then passing the image you want to compare with the hash of the other image to Compare.
Hash returns the comparable hash of the image.
Source Files
¶
Directories
¶
internal
Click to show internal directories.
Click to hide internal directories.