Suppose I have two sets of spatial locations $X$ and $Y$ on the plane, each with $n$ locations. The coordinates are $X=\{(x_1, y_1), \dots, (x_n, y_n)\}$ and $Y=\{(u_1, v_1), \dots, (u_n, v_n)\}$. I want to find a quantity representing the similarity between the two patterns formed by those locations.
For example, in the figure below, the pattern by black dots are apparently more similar to the one by the red dots than the blue dots. But that's subjective. I wonder if there is a reasonable way to define a quantity which will take a larger value if two patterns are more similar and a small value if they are very different.
This quantity should have the following properties:
- It does not depend on the scale. One pattern can be large, e.g., the pattern of the stars in the sky; the other one could be small, e.g., the pattern of trees in your backyard. You are free to proportionally rescale the pattern.
- It does not depend on the orientation. In the figure, I can rotate the red dots by an appropriate angle first and then compare with the black pattern.
- It does not depend on the absolute location which means I can freely move the pattern around by a translation before comparing.
Here is what I did so far. Since the rotation in 2D can be represented by a matrix $$T=\begin{pmatrix} \cos\theta & -\sin\theta \\ \sin \theta & \cos \theta\end{pmatrix}\, ,$$ scaling can be represented by the multiplication of a constant $a$, and translation can be represented by adding a constant two-dimensional vector $\mathbf{b}=(b_1, b_2)$. I can first transform the second pattern $Y$ as $$Y'=aTY + \mathbf{b}\, .$$ After that, I define a distance between the two patterns $X$ and $Y'$ as $$D=\| X-Y'\| ^2=\sum_{i=1}^{n}[(x_i-u'_i)^2+(y_i-v'_i)^2]$$ Since $D$ is a function of $a, \theta, b_1, b_2$, I can minimize $D$ to the optimal parameters $\hat{a}, \hat{\theta}, \hat{b}_1, \hat{b}_2$.
Here is a question I have. When computing $D$, I have to pair those locations, black 1 with red 1, black 2 with red 2, etc. However, that is subjective already. Is there an automatic way of doing this? Or, is there a better way of doing the whole thing?
