/// <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"); } var differenceCounter = HashData.Where((t, i) => t != compareWith.HashData[i]).Count(); return(100 - differenceCounter / 100.0 * HashData.Length / 2.0); }
private static void Main(string[] args) { Console.WriteLine("Hello World!"); foreach (var f in Directory.EnumerateFiles("../Cheaturu/poke_out/poke")) { Console.WriteLine(f); var hash = new ImgHash(); hash.GenerateFromPath(f); File.WriteAllText("./data/" + Path.GetFileNameWithoutExtension(f) + ".txt", string.Join(",", hash.HashData)); } }