Browse Source

Add global histogram equalization test which compares result to reference output

js/color-alpha-handling
Brian Popow 5 years ago
parent
commit
82a5a61f3d
  1. 39
      tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs
  2. 1
      tests/ImageSharp.Tests/TestImages.cs
  3. 2
      tests/Images/External
  4. 3
      tests/Images/Input/Jpg/baseline/640px-Unequalized_Hawkes_Bay_NZ.jpg

39
tests/ImageSharp.Tests/Processing/Normalization/HistogramEqualizationTests.cs

@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization
[Theory]
[InlineData(256)]
[InlineData(65536)]
public void HistogramEqualizationTest(int luminanceLevels)
public void GlobalHistogramEqualization_WithDifferentLumanceLevels(int luminanceLevels)
{
// Arrange
var pixels = new byte[]
@ -45,20 +45,21 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization
var expected = new byte[]
{
0, 12, 53, 32, 146, 53, 174, 53,
57, 32, 12, 227, 219, 202, 32, 154,
65, 85, 93, 239, 251, 227, 65, 158,
73, 146, 146, 247, 255, 235, 154, 130,
97, 166, 117, 231, 243, 210, 117, 117,
117, 190, 36, 190, 178, 93, 20, 170,
130, 202, 73, 20, 12, 53, 85, 194,
146, 206, 130, 117, 85, 166, 182, 215
0, 12, 53, 32, 146, 53, 174, 53,
57, 32, 12, 227, 219, 202, 32, 154,
65, 85, 93, 239, 251, 227, 65, 158,
73, 146, 146, 247, 255, 235, 154, 130,
97, 166, 117, 231, 243, 210, 117, 117,
117, 190, 36, 190, 178, 93, 20, 170,
130, 202, 73, 20, 12, 53, 85, 194,
146, 206, 130, 117, 85, 166, 182, 215
};
// Act
image.Mutate(x => x.HistogramEqualization(new HistogramEqualizationOptions
{
LuminanceLevels = luminanceLevels
LuminanceLevels = luminanceLevels,
Method = HistogramEqualizationMethod.Global
}));
// Assert
@ -75,6 +76,24 @@ namespace SixLabors.ImageSharp.Tests.Processing.Normalization
}
}
[Theory]
[WithFile(TestImages.Jpeg.Baseline.HistogramEqImage, PixelTypes.Rgba32)]
public void GlobalHistogramEqualization_CompareToReferenceOutput<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : unmanaged, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage())
{
var options = new HistogramEqualizationOptions
{
Method = HistogramEqualizationMethod.Global,
LuminanceLevels = 256,
};
image.Mutate(x => x.HistogramEqualization(options));
image.DebugSave(provider);
image.CompareToReferenceOutput(ValidatorComparer, provider, extension: "png");
}
}
[Theory]
[WithFile(TestImages.Jpeg.Baseline.LowContrast, PixelTypes.Rgba32)]
public void Adaptive_SlidingWindow_15Tiles_WithClipping<TPixel>(TestImageProvider<TPixel> provider)

1
tests/ImageSharp.Tests/TestImages.cs

@ -196,6 +196,7 @@ namespace SixLabors.ImageSharp.Tests
public const string YcckSubsample1222 = "Jpg/baseline/ycck-subsample-1222.jpg";
public const string Iptc = "Jpg/baseline/iptc.jpg";
public const string App13WithEmptyIptc = "Jpg/baseline/iptc-psAPP13-wIPTCempty.jpg";
public const string HistogramEqImage = "Jpg/baseline/640px-Unequalized_Hawkes_Bay_NZ.jpg";
public static readonly string[] All =
{

2
tests/Images/External

@ -1 +1 @@
Subproject commit cc6465910d092319ef9bf4e99698a0649996d3c5
Subproject commit 8b43d14d21ce9b436af3d12a70d38402cdba176b

3
tests/Images/Input/Jpg/baseline/640px-Unequalized_Hawkes_Bay_NZ.jpg

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d1fafc61231325c42d94fe163486a6c5144fb6211ccdceb902d5cb4ddebda9e1
size 32428
Loading…
Cancel
Save