I'm working on this idea of choosing best cover image from given db for image steganography(hiding secret image inside cover).
I've started with calculating cross-correlation matrix between images in db with given secret image(there are images with different content/texture, like secret could be a building while cover image could be a face and so...).
So first of all i'm not sure if cross-correlation is a proper choice!? but anyway how can i interpret cross-correlation matrix for image similarity? should i only rely on maximum of the result matrix or mean would do better comparison?
What other comparison methods would you recommend for this problem?
I was thinking of binary similarity measures but i'm not sure...(i guess i need proper features first).

I'm using scipy.signal.correlate2d for calculating cross-correlation matrix.

  • $\begingroup$ Is your problem to know the degree of similarity between two images? $\endgroup$ Dec 23, 2017 at 7:41
  • $\begingroup$ Yes, mostly. but i'm curious in case of cross-correlation, is maximum of result matrix enough to judge? $\endgroup$ Dec 23, 2017 at 8:04

1 Answer 1


In the case of 2 images $m_{1}(x,y)$ and $m_{2}(x,y)$ of size $m×n$ , where $(x,y)$ are the coordinates of the image, the correlation constructs a matrix $A$ where each $A(i,j)$ is the degree of similarity between the image $m_{1}(x,y)$ and $m_{2}(x+i,y+j)$ (note that $m_{2}(x+i,y+i)$ is the image $m_{2}(x,y)$ translated $i$, $j$ pixels). This degree of similarity is basically a measure of the angle between the vectors $v_{1}$ and $v_{2}$ of $R^{m×n}$ that could be constructed by vectoring the images $m_{1}(x,y)$ and $m_{2}(x+i,y+j)$, this is because for each $i, j$ What the correlation really does is the normalized dot product $\frac{v_{1}.v_{2}}{|v_{1}||v_{2}|}$. Remember that $v_{1}.v_{2}=|v_{1}||v_{2}|cos(θ)$, where θ is the angle between the vectors $v_{1}$ and $v_{2}$.

In conclusion, the maximum $A(i,j)$ tells you that for the degree of similarity (angle θ) between $m_{1}(x,y)$ and $m_{2}(x,y)$ to be maximized, $m_{2}(x,y)$ must be translated $(i, j)$ pixels.

This measure of similarity is not very good, since it is not robust to changes in tones, lighting, noise, among others. There are other comparison alternatives such as PCA, SRC, SIFT or SURF.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.