convert im to gray before template recognition