modifies template_tracking_color to handle also gray-values, but is slow... :-/