Exemplo n.º 1
0
        private List <ImageHash> FindDuplicatesTo(ImageHash hash, int minSimilarity, ref List <ImageHash> alreadyMarkedAsDupl)
        {
            var currHashDupl = new List <ImageHash>();

            foreach (var hashCompareWith in _hashLibToCompare)
            {
                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);
        }
Exemplo n.º 2
0
        public void AddPicByPathToCompare(string path)
        {
            var hash = new ImageHash(_hashSize);

            hash.GenerateFromPath(path);
            _hashLibToCompare.Add(hash);

            hash = new ImageHash(_hashSize);
            hash.GenerateFromPathReversed(path);
            _hashLibToCompare.Add(hash);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Method to compare 2 image hashes
        /// </summary>
        /// <returns>% of similarity</returns>
        public double CompareWith(ImageHash 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);
        }