public override bool IsSimilar(IHashDetails other, double similarity) { if (Hash.Length != other.Hash.Length || !(other is BrightnessHash)) { return(false); } //If the aspect ratio is too different then don't bother checking the hash var margin = 1 - similarity; var xAspect = this.GetAspectRatio(); var yAspect = other.GetAspectRatio(); if (xAspect > yAspect * (1 + margin) || xAspect < yAspect * (1 - margin)) { return(false); } var matchCount = 0; var xHash = Hash; var yHash = other.Hash; for (var i = 0; i < xHash.Length; ++i) { if (xHash[i] == yHash[i]) { ++matchCount; } } return((matchCount / (float)xHash.Length) >= similarity); }
protected FileImageDetails( DateTimeOffset createdAt, string source, IHashDetails original, IHashDetails thumbnail) { CreatedAt = createdAt; Original = original; Source = source; Thumbnail = thumbnail; }
public override bool IsSimilar(IHashDetails other, double similarity) => false;
public static float GetAspectRatio(this IHashDetails details) => details.Width / (float)details.Height;
protected ImageDetails(IHashDetails original, IHashDetails thumbnail) { Original = original; Thumbnail = thumbnail; }