Abstract. Template matching is widely used in machine vision, digital photogrammetry, and multimedia data mining to search for a target object by similarity between its prototype image (template) and a sensed image of a natural scene containing the target. In the real-world environment, similarity scores are frequently affected by contrast / offset deviations between the template and target signals. Most of the popular least-squares scores presume only simple smooth deviations that can be approximated with a low-order polynomial. This paper proposes an alternative and more general quadratic programming based matching score that extends the conventional least-squares framework onto both smooth and non-smooth signal deviations.