示例#1
0
        /// <summary>
        /// 比较两图是否相似,返回值越小越相似
        /// </summary>
        public static int GetImageDiffCount(ImageInfo img1, ImageInfo img2)
        {
            string s1 = img1.ID;
            string s2 = img2.ID;

            return(ImageDiff.CalcSimilarDegree(s1, s2));
        }
示例#2
0
        /// <summary>
        /// 比较两图是否相似
        /// </summary>
        /// <returns>true:相似</returns>
        public static bool IsSameImage(Bitmap img1, Bitmap img2)
        {
            ImageDiff im  = new ImageDiff(img1);
            ImageDiff im2 = new ImageDiff(img2);
            string    s1  = im.GetHash();
            string    s2  = im2.GetHash();

            int count = 0;

            for (int i = 0; i < s1.Length; i++)
            {
                if (s1[i] != s2[i])
                {
                    count++;
                }
                if (count > 10)
                {
                    return(false);
                }
            }
            return(true);
        }