Change the computeImageDistance function