compute the chi-square distance for based on optical flow result