#image #perceptual #hash #difference #hash-values

bin+lib img_hash

一个简单的库,为图像提供感知哈希和差异计算

10 个稳定版本 (3 个主要版本)

使用旧的 Rust 2015

3.2.0 2021年5月4日
3.1.1 2021年3月13日
3.1.0 2020年2月19日
3.0.0 2019年10月28日
0.0.2 2014年11月28日

#299图像

Download history 107/week @ 2024-03-11 97/week @ 2024-03-18 126/week @ 2024-03-25 181/week @ 2024-04-01 65/week @ 2024-04-08 111/week @ 2024-04-15 149/week @ 2024-04-22 103/week @ 2024-04-29 162/week @ 2024-05-06 84/week @ 2024-05-13 99/week @ 2024-05-20 84/week @ 2024-05-27 138/week @ 2024-06-03 79/week @ 2024-06-10 110/week @ 2024-06-17 91/week @ 2024-06-24

每月下载量 434
7 crate 中使用(6 个直接使用)

MIT/Apache

56KB
696

img_hash 构建状态 Crates.io 徽标

现在可以在稳定 Rust 上构建!(但需要夜间构建以进行基准测试。)

一个用于获取图像感知哈希值的库。

感谢 Dr. Neal Krawetz 提供了均值(aHash)、梯度(dHash)和 DCT(pHash)感知哈希算法的概要。
http://www.hackerfactor.com/blog/?/archives/432-Looks-Like-It.html(访问时间:2014年8月)

还提供了 Blockhash.io 算法 的实现。

此 crate 可以直接在 PistonDevelopers/image crate 的缓冲区上操作。

使用方法

文档

img_hash 添加到您的 Cargo.toml

[dependencies.img_hash]
version = "3.0"

示例程序

 extern crate image;
 extern crate img_hash;
 
 use img_hash::{HasherConfig, HashAlg};

 fn main() {
     let image1 = image::open("image1.png").unwrap();
     let image2 = image::open("image2.png").unwrap();
     
     let hasher = HasherConfig::new().to_hasher();

     let hash1 = hasher.hash_image(&image1);
     let hash2 = hasher.hash_image(&image2);
     
     println!("Image1 hash: {}", hash1.to_base64());
     println!("Image2 hash: {}", hash2.to_base64());
     
     println!("Hamming Distance: {}", hash1.dist(&hash2));
 }

基准测试

为了在 Rust 稳定版上构建和测试,必须将基准测试放在功能门后面。如果您已安装 Rust 夜间版并想运行基准测试,请使用以下命令

cargo bench --features bench

许可证

许可方式任选其一

由您选择。

贡献

除非您明确声明,否则您提交给本工作的任何有意贡献,根据 Apache-2.0 许可证的定义,应按上述方式双重许可,不附加任何额外条款或条件。

依赖关系

~14MB
~114K SLoC