"Matching" together Google's whole image database would be infeasible in terms of computer resources needed, so it is likely that they have used an advanced version of an algorithm that calculates the similarity between images.
A basic way of doing this kind of thing for a set of similar images (or data in general) is called principal components analysis. For your set of images you would compute a mean image and then compute the covariance between all images. Calculate the eigenvectors and eigenvalues of the covariance matrix and then use the top X eigenvectors (by eigenvalue) to determine the main sources of variation in your images/data. Matlab makes this easy, for example, for a set of images "myImages":
meanImage = mean(myImages);
covarianceMatrix = cov(myImages);
[V,D] = eig(covarianceMatrix);
lambdas = diag(D);
After executing those few lines you'd have your top eigenvalues in "lambdas" and could index into the eigenvector matrix V to have the principal components. Similar images would have less variation in these component directions. Much more detail here: