Efficient template matching for multi-channel images