The cross-correlation tool is extremely robust to noise and very precise in the offset estimation. It is however sensitive to periodic patterns and unable to make the difference between one star and another similar point-like object for example. This can be avoided by enlarging the measurement area to a wider surface.
A typical issue is: when and how to determine that the detected local
extremum is the right one? When matching two very different images, the
procedure will always have an answer for the question: what is the best
correlating place? There is clearly a need to define a threshold to
validate a detected match or not. This strongly depends on the input
signal and the expected amount of noise in the image. To get an idea,
this implementation always prints out the value of the cross-correlation
function at the local extremum, i.e. the minimum of sum of squared
differences between both regions of interest. The smaller this value,
the better the match quality (null for an ideal, integer shift without
noise). As a first estimate, the quality of the matched point could be
evaluated by saying (
being this measure of similarity):
This rule of thumb of course varies wildly with the signal present in the input frames. The more signal there is in input, the more these thresholds are likely to get higher, without indicating a bad matching case. A possible enhancement of the algorithm would be to set this value automatically from a quick statistical analysis of the input signal for example.