libvips / pyvips

python binding for libvips using cffi
MIT License
649 stars 50 forks source link

How to compare two images? #415

Open WeisiminPeng-Simmi opened 1 year ago

WeisiminPeng-Simmi commented 1 year ago

Hi, may I ask how to compare two images? Thanks! I just want to know they are the same or not.

I found an issue in libvips repo: https://github.com/libvips/libvips/issues/1201 But i couldn't find that equal() method in pyvips.

jcupitt commented 1 year ago

Hi @WeisiminPeng-Simmi,

In python, you can just do

(a == b).min() == 255

ie. compare the images pixel by pixel to make an image of 0 and 255, then search that for the minimum. If the min is 255, the images must be equal in every pixel.