Compute mask for overlaps