Correlation of two images

How do I perform the correlation between two patches that I extracted from an image?
I have extracted two patches and saved them into two different images. Now I just want to perform correlation between them. There is no template image for me. My both images are of same size and type.

Im using flipimagefilter followed by simple Itkconvolutionimagefilter to perform correlation operation.
If my two images are of size 555, how do I print the value of correlation? (I dont want to do any padding for the images. I just need the output correlation value as 111)

What you seem to want is to evaluate an image similarity metric for your two images. If so, please look at ITK metrics direct application and Is there a decent way to quantify the “goodness” of a CT to CT scan registration?

I am actually trying to find the correlation value pixel wise. I need a correlation map that is of the size of my input image. itkMskedFFTNormalizedcorrelationfilter.h gives me double sized image.

I guess it computes correlation for both positive and negative translations, thus making an output which is 2*n-1 in size.

1 Like

Is there any way to make it to size ‘n’ ?

Take the middle part? I think that implies less extreme translations, but you should check the documentation and/or source code of that filter.

1 Like