how to find the correlation between two images

21,188

Have you looked at the scipy signal processing kit?

from scipy import signal
cor = signal.correlate2d (im1, im2)

will calculate the 2D correlation for you.

Share:
21,188
user1750948
Author by

user1750948

Updated on March 04, 2020

Comments

  • user1750948
    user1750948 about 4 years

    I need some help in trying to figure out something. I currently a python script which generates two images using the imshow method in matplotlib. My task is to find the correlation between these two images, or in other words the similarity between the two images. Both images are the same size and both use the jet colormap.
    Let me know if this is clear enough or if i need to explain in more detail. It would be helpful if someone could provide an example code of how to do this.

  • Neeraj Komuravalli
    Neeraj Komuravalli over 7 years
    Tried using on my data set (image size is 1280*720) and it took about 15 minutes and results still did not come so I had to kill the process, Any idea why is this happening (apart from the image being large)?
  • lxop
    lxop over 7 years
    @NeerajKomuravalli I suspect it is simply the size of the image. I would expect the computational effort of a cross-correlation to be grow with the product of the squares of Nx and Ny. Maybe try measuring the time required for different (smaller) images and graphing that - it should give you an indication of the time actually required for your data set.