Compare `Mat` from disk to memory

not at all, what your question title says…
you don’t need 2 images for that. what’s the second one for ? your question is already unclear about it
and what does your mat_eq function actually compare ?

why on earth would someone do this ?

whole idea look murky. either throw an exception, or return something valid