Changed template matching function from cross correlation to  least
square difference.  Note that for any given match value, the smaller the
better for least square fit.