implement the algorithm of image comparison