Template matching based on the Lp norm using sufficient conditions with incremental approximations