title: Correlation among 2 images
body: <p>I am trying to find the following correlation among two images f1 and f2 where the size of the image is PXP.</p>
  
  <p>I have written a for loop program for the same but I think an inbuilt function would be faster for the same.</p>
  
  <p><img src="https://i.stack.imgur.com/EHoEW.png" alt="enter image description here"></p>
  
  <p>Which function in matlab can help me compute this ? </p>
  
  <p>Also if the size of both the images are M X N can someone tell me how this formula will change or if the function will be able to handle it.</p>
  
  <p>EDIT:</p>
  
  <p>Is there any faster function than <strong>xcorr2</strong> that can help me seeing that it takes too much time when I only need to have the value for correlation the unshifted images....</p>