ImageHashes package
ImageHashes.jl is a Julia package for image hashing. It covers various techniques to simplify the task of finding exact and near duplicates in an image collection, among other applications.
Benchmark
The package provides basic benchmarks in benchmarks/benchmark.jl. One can run
julia --project=. benchmarks/benchmark.jl to get
BENCHMARK RESULTS
time taken to compute a hash using difference_hash : 1.28e-6 seconds
Hashes per second: 781645
time taken to compute 100000000 hash distances: 0.531 secondsThere is an equivalent benchmark in Python using
https://github.com/JohannesBuchner/imagehashwhich produces
BENCHMARK RESULTS
time taken to compute a hash using dhash: 0.004 seconds
Hashes per second: 250
time taken to compute 100000000 hash distances: 242.927 secondsRelated material to ImageHashes
This Package is inspired by:
https://github.com/JohannesBuchner/imagehashGood related material can be found in
- https://github.com/JohannesBuchner/imagehash
- https://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html
- https://erdogant.github.io/undouble/pages/html/hash_functions.html
- https://content-blockchain.org/research/testing-different-image-hash-functions/
ImageHashes._difference_hash_matrixImageHashes._preprocess_imageImageHashes.difference_hashImageHashes.difference_mathashImageHashes.init_hash_container
ImageHashes._difference_hash_matrix — Method_difference_hash_matrix(image, n_size_side::Int; orientation=:vertical)Compute the boolean bit matrix for difference hash.
orientation = :vertical: compares columns (resize to(n_size_side, n_size_side+1)), result(n_size_side, n_size_side).orientation = :horizontal: compares rows (resize to(n_size_side+1, n_size_side)), result(n_size_side, n_size_side).
ImageHashes._preprocess_image — Method_preprocess_image(image, size::Union{Int,Tuple{Int,Int}}; func=nothing)Resize an image to the target size and convert it to grayscale.
Arguments
image: the input image.size: either anInt(resized to(size, size)) or a tuple(height, width).func: optional function applied on the grayscale image. If provided, the function output is returned together with the grayscale image.
Returns
- If
funcisnothing: the resized grayscale image. - Otherwise: a tuple
(img_resized_gray, func(img_resized_gray)).
ImageHashes.difference_hash — Functiondifference_hash(image, n_size_side::Int=8; orientation=:horizontal)Return the difference hash as a compact integer.
ImageHashes.difference_mathash — Functiondifference_mathash(image, n_size_side::Int=8; orientation=:horizontal)Return the difference hash as a BitMatrix.
- By default, uses
orientation=:horizontalto match test expectations.
ImageHashes.init_hash_container — Methodinit_hash_container(n_bits::Int)Choose the proper variable type for the variable storing the resulting hash based on n_bits of the input..