kornelski / dssim

Image similarity comparison simulating human perception (multiscale SSIM in Rust)
https://kornel.ski/dssim
GNU Affero General Public License v3.0
1.07k stars 69 forks source link

[Help] How to simply compare two JPEG images in memory #130

Closed azureqaq closed 1 year ago

azureqaq commented 1 year ago

Hi, I'm trying to use this crate in my project, but since I'm new to rust, I'm having some problems. I have Bytes data of two jpeg images in memory, now I want to compare the &Bytes of the original image with the &Bytes of the other image and finally get an f64. I would appreciate if you could provide some ideas. Sample code would be nice. Sorry for disturbing.

azureqaq commented 1 year ago

They are not the same size

kornelski commented 1 year ago

You'll need to decode them first, see https://lib.rs/load_image and if they're not the same pixel size, then the comparison is going to be weird. You'll have to resize them both to the same size first, see https://lib.rs/resize.

azureqaq commented 1 year ago

thank you very much! 👀