Beispiel #1
0
        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);
        }
Beispiel #2
0
 protected FileImageDetails(
     DateTimeOffset createdAt,
     string source,
     IHashDetails original,
     IHashDetails thumbnail)
 {
     CreatedAt = createdAt;
     Original  = original;
     Source    = source;
     Thumbnail = thumbnail;
 }
Beispiel #3
0
 public override bool IsSimilar(IHashDetails other, double similarity)
 => false;
Beispiel #4
0
 public static float GetAspectRatio(this IHashDetails details)
 => details.Width / (float)details.Height;
Beispiel #5
0
 protected ImageDetails(IHashDetails original, IHashDetails thumbnail)
 {
     Original  = original;
     Thumbnail = thumbnail;
 }