| Crates.io | imgmatch |
| lib.rs | imgmatch |
| version | 0.1.3 |
| created_at | 2025-09-03 10:30:16.428546+00 |
| updated_at | 2025-09-03 12:01:41.891666+00 |
| description | A Rust program to compare two images |
| homepage | |
| repository | https://github.com/0xAA55/imgmatch |
| max_upload_size | |
| id | 1822328 |
| size | 4,508,513 |
简体中文 | Chinglish
imgmatch <image1> <image2>
The program will try to resize the two images to the same size, then run pixel color difference summing, and print out a value.
0.01, the two images could be considered as different images.0.01, the two images could be considered as identical images.0.01.See the pseudo code here:
for y in 0..MATCH_SIZE { // This line runs in parallel
for x in 0..MATCH_SIZE {
let p1 = img1.get_pixel(x, y);
let p2 = img2.get_pixel(x, y);
sr += ((p1.r as f32 / 255.0) - (p2.r as f32 / 255.0)).abs() as f32;
sg += ((p1.g as f32 / 255.0) - (p2.g as f32 / 255.0)).abs() as f32;
sb += ((p1.b as f32 / 255.0) - (p2.b as f32 / 255.0)).abs() as f32;
}
}
let error = ((sr + sg + sb) / (MATCH_SIZE * MATCH_SIZE * 3) as f32).max(0.0);
println!("{error:.3}");
First is to install Rust.
cargo build --release in the project directory to get the binary program, and use the program as this document says.numa enabled by running cargo build --release --features numa to get the binary program that's NUMA-specific.profiling, then the time consumption of each step, including image loading, resizing, and the image difference summing, will be displayed via stderr.test1.png - test1.png = 0.000
test1.png - test2.JPG = 0.004
test1.png - test3.jpg = 0.401
test1.png - test4.png = 0.720
test1.png - test5.png = 0.402
test2.JPG - test1.png = 0.004
test2.JPG - test2.JPG = 0.000
test2.JPG - test3.jpg = 0.401
test2.JPG - test4.png = 0.720
test2.JPG - test5.png = 0.402
test3.jpg - test1.png = 0.401
test3.jpg - test2.JPG = 0.401
test3.jpg - test3.jpg = 0.000
test3.jpg - test4.png = 0.464
test3.jpg - test5.png = 0.007
test4.png - test1.png = 0.720
test4.png - test2.JPG = 0.720
test4.png - test3.jpg = 0.464
test4.png - test4.png = 0.000
test4.png - test5.png = 0.463
test5.png - test1.png = 0.402
test5.png - test2.JPG = 0.402
test5.png - test3.jpg = 0.007
test5.png - test4.png = 0.463
test5.png - test5.png = 0.000