diff --git a/src/BingImageDownload/HistogramHash.cs b/src/BingImageDownload/HistogramHash.cs index 743b76f..0b3d9fa 100644 --- a/src/BingImageDownload/HistogramHash.cs +++ b/src/BingImageDownload/HistogramHash.cs @@ -33,11 +33,8 @@ internal bool Equal(HistogramHash other) var otherVal = other.Rgb.FirstOrDefault(x => x.X.Equals(val.X) && x.Y.Equals(val.Y)); if (otherVal == null) return false; - var differenceR = Math.Abs(val.R - otherVal.R); - var differenceG = Math.Abs(val.G - otherVal.G); - var differenceB = Math.Abs(val.B - otherVal.B); - - if (differenceR > 3 || differenceG > 3 || differenceB > 3) + var difference = Math.Abs(val.RGB - otherVal.RGB); + if (difference > 3) { differencesOverTolerance++; } @@ -45,7 +42,7 @@ internal bool Equal(HistogramHash other) var differencePercent = differencesOverTolerance / Rgb.Count * 100; - return differencePercent < 1; + return differencePercent < 1f; } } } diff --git a/src/BingImageDownload/ImageHashing.cs b/src/BingImageDownload/ImageHashing.cs index 167080c..fdb68e8 100644 --- a/src/BingImageDownload/ImageHashing.cs +++ b/src/BingImageDownload/ImageHashing.cs @@ -124,7 +124,7 @@ private HistogramHash GetRgbHistogramHash(string filePath) for (var y = 0; y < image.Height; y++) { var pixel = image[x, y]; - Rgb.Add(new RgbPixelData(x, y, pixel.R, pixel.G, pixel.B)); + Rgb.Add(new RgbPixelData(x, y, pixel.R + pixel.G + pixel.B)); } } } diff --git a/src/BingImageDownload/RgbPixelData.cs b/src/BingImageDownload/RgbPixelData.cs index c0bd2e5..f719f0a 100644 --- a/src/BingImageDownload/RgbPixelData.cs +++ b/src/BingImageDownload/RgbPixelData.cs @@ -2,17 +2,13 @@ namespace BingImageDownload { public class RgbPixelData { - public byte R { get; } - public byte G { get; } - public byte B { get; } + public int RGB { get; } public int X { get; } public int Y { get; } - public RgbPixelData(int x, int y, byte r, byte g, byte b) + public RgbPixelData(int x, int y, int rgb) { - R = r; - G = g; - B = b; + RGB = rgb; X = x; Y = y; }