internal static ImageGene FromImage(Image image) { var result = new ImageGene(); result._histogram = ComputeHistogram(image); result.Image = image; return result; }
internal static ImageGene Load(string path) { var result = new ImageGene(); result._histogram = FileUtility.ReadLines(path, StreamOptions.DoNotLockFile).Select(x => float.Parse(x)).ToArray(); if (0x60 != result._histogram.Length) throw new ApplicationException("The specified file is broken. : " + path); return result; }
internal double GetDistance(ImageGene gene) { return GetDistance(this, gene); }
internal bool Equals(ImageGene gene, double threshold) { if (null == gene) return false; if (object.ReferenceEquals(this, gene)) return true; return GetDistance(this, gene) < threshold; }
private static double GetDistance(ImageGene x, ImageGene y) { return x._histogram.Zip(y._histogram, (a, b) => Math.Abs(a - b)).Aggregate(0d, (total, next) => total += next); }