Reliable rejection of mismatching candidates for efficient ZNCC template matching