private List <ImgHash> FindDuplicatesTo(ImgHash hash, int minSimilarity, ref List <ImgHash> alreadyMarkedAsDupl)
        {
            var currHashDupl = new List <ImgHash>();

            foreach (var hashCompareWith in _hashLib)
            {
                if (hash.CompareWith(hashCompareWith) >= minSimilarity)
                {
                    if (!alreadyMarkedAsDupl.Contains(hash))
                    {
                        alreadyMarkedAsDupl.Add(hash);

                        currHashDupl.Add(hash);
                    }

                    if (!alreadyMarkedAsDupl.Contains(hashCompareWith))
                    {
                        alreadyMarkedAsDupl.Add(hashCompareWith);

                        currHashDupl.Add(hashCompareWith);
                    }
                }
            }

            return(currHashDupl);
        }
        public void AddPicByNameJY(string path)
        {
            var hash = new ImgHash(_hashSize);

            hash.GenerateFromPath(path);

            _hashLib.Add(hash);
        }
Beispiel #3
0
        /// <summary>
        /// Method to compare 2 image hashes
        /// </summary>
        /// <returns>% of similarity</returns>
        public double CompareWith(ImgHash compareWith)
        {
            if (HashData.Length != compareWith.HashData.Length)
            {
                throw new Exception("Cannot compare hashes with different sizes");
            }

            int differenceCounter = 0;

            for (int i = 0; i < HashData.Length; i++)
            {
                if (HashData[i] != compareWith.HashData[i])
                {
                    differenceCounter++;
                }
            }

            return(100 - differenceCounter / 100.0 * HashData.Length / 2.0);
        }