From 81509ffcf3289a53d434639a30911356dab41f59 Mon Sep 17 00:00:00 2001 From: David Rolland Date: Sat, 26 Sep 2020 20:29:10 +0900 Subject: [PATCH] Fixed typo in AdaptiveThreshold processor and added specific test --- .../Binarization/AdaptiveThresholdProcessor{TPixel}.cs | 3 ++- .../Processing/Binarization/AdaptiveThresholdTests.cs | 1 + tests/Images/External | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Binarization/AdaptiveThresholdProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/AdaptiveThresholdProcessor{TPixel}.cs index 43023c9382..6d95d51b32 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/AdaptiveThresholdProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/AdaptiveThresholdProcessor{TPixel}.cs @@ -67,7 +67,8 @@ protected override void OnFrameApply(ImageFrame source) ref TPixel color = ref Unsafe.Add(ref rowRef, x); color.ToRgba32(ref rgb); - sum += (ulong)(rgb.R + rgb.G + rgb.G); + sum += (ulong)(rgb.R + rgb.G + rgb.B); + if (x - startX != 0) { intImage[x - startX, y - startY] = intImage[x - startX - 1, y - startY] + sum; diff --git a/tests/ImageSharp.Tests/Processing/Binarization/AdaptiveThresholdTests.cs b/tests/ImageSharp.Tests/Processing/Binarization/AdaptiveThresholdTests.cs index 8efac7593d..f4f800107f 100644 --- a/tests/ImageSharp.Tests/Processing/Binarization/AdaptiveThresholdTests.cs +++ b/tests/ImageSharp.Tests/Processing/Binarization/AdaptiveThresholdTests.cs @@ -100,6 +100,7 @@ public void AdaptiveThreshold_SettingUpperLowerWithThresholdLimit_WithRectangle_ [Theory] [WithFile(TestImages.Png.Bradley01, PixelTypes.Rgba32)] [WithFile(TestImages.Png.Bradley02, PixelTypes.Rgba32)] + [WithFile(TestImages.Png.Ducky, PixelTypes.Rgba32)] public void AdaptiveThreshold_Works(TestImageProvider provider) where TPixel : unmanaged, IPixel { diff --git a/tests/Images/External b/tests/Images/External index 6a00308067..28839f6eaa 160000 --- a/tests/Images/External +++ b/tests/Images/External @@ -1 +1 @@ -Subproject commit 6a003080674d1fedc66292c13ce5a357b2a33083 +Subproject commit 28839f6eaa212a575005df630b6030bb4314a75b