-
-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
using ImageMagick; | ||
using Xunit; | ||
|
||
namespace Magick.NET.Tests; | ||
|
||
public partial class ChannelPerceptualHashTests | ||
{ | ||
public class TheToStringMethod | ||
{ | ||
[Fact] | ||
public void ShouldReturnTheCorrectValue() | ||
{ | ||
using var image = new MagickImage(Files.ImageMagickJPG); | ||
var phash = image.PerceptualHash(); | ||
Assert.NotNull(phash); | ||
|
||
var red = phash.GetChannel(PixelChannel.Red); | ||
var green = phash.GetChannel(PixelChannel.Green); | ||
Assert.NotNull(red); | ||
Assert.NotNull(green); | ||
|
||
#if Q8 | ||
OpenCLValue.Assert(13.33, 14.48, red.SumSquaredDistance(green)); | ||
#elif Q16 | ||
OpenCLValue.Assert(23.02, 23.06, red.SumSquaredDistance(green)); | ||
#else | ||
OpenCLValue.Assert(29.99, 29.89, red.SumSquaredDistance(green)); | ||
#endif | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
using ImageMagick; | ||
using Xunit; | ||
|
||
namespace Magick.NET.Tests; | ||
|
||
public partial class ChannelPerceptualHashTests | ||
{ | ||
public class TheSumSquaredDistanceMethod | ||
{ | ||
[Fact] | ||
public void ShouldReturnTheDifference() | ||
{ | ||
//using var image = new MagickImage(Files.ImageMagickJPG); | ||
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux musl (Q8/Q16/Q16-HDRI, x64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux musl (Q8/Q16/Q16-HDRI, x64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux musl (Q8/Q16/Q16-HDRI, x64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux musl (Q8/Q16/Q16-HDRI, x64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux musl (Q8/Q16/Q16-HDRI, x64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux musl (Q8/Q16/Q16-HDRI, x64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / MacOS (Q8/Q16/Q16-HDRI, arm64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / MacOS (Q8/Q16/Q16-HDRI, arm64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / MacOS (Q8/Q16/Q16-HDRI, arm64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / MacOS (Q8/Q16/Q16-HDRI, arm64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / MacOS (Q8/Q16/Q16-HDRI, arm64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / MacOS (Q8/Q16/Q16-HDRI, arm64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / MacOS (Q8/Q16/Q16-HDRI)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / MacOS (Q8/Q16/Q16-HDRI)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / MacOS (Q8/Q16/Q16-HDRI)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / MacOS (Q8/Q16/Q16-HDRI)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / MacOS (Q8/Q16/Q16-HDRI)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / MacOS (Q8/Q16/Q16-HDRI)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux (Q8/Q16/Q16-HDRI, x64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux (Q8/Q16/Q16-HDRI, x64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux (Q8/Q16/Q16-HDRI, x64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux (Q8/Q16/Q16-HDRI, x64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux (Q8/Q16/Q16-HDRI, x64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux (Q8/Q16/Q16-HDRI, x64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux (Q8/Q16/Q16-HDRI, arm64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux (Q8/Q16/Q16-HDRI, arm64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux (Q8/Q16/Q16-HDRI, arm64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux (Q8/Q16/Q16-HDRI, arm64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux (Q8/Q16/Q16-HDRI, arm64)
Check warning on line 16 in tests/Magick.NET.Tests/Statistics/ChannelPerceptualHashTests/TheToStringMethod.cs GitHub Actions / Linux (Q8/Q16/Q16-HDRI, arm64)
|
||
using var image = new MagickImage(Files.FujiFilmFinePixS1ProJPG); | ||
var phash = image.PerceptualHash(); | ||
Assert.NotNull(phash); | ||
|
||
var red = phash.GetChannel(PixelChannel.Red); | ||
Assert.NotNull(red); | ||
|
||
#if Q8 | ||
Assert.Equal("a65e687f9388c0e88f0261ce08eeb361d40a26ce81a1e823ec85b3b8cc3586ec889ad4", red.ToString()); | ||
#elif Q16 | ||
Assert.Equal("a658c87fa088c0588eb561ccb8ed8a61d43a646682939835e986ec98c78f887ae8c67f", red.ToString()); | ||
#else | ||
Assert.Equal("a658c87fa188c0588eb561ccb8ed8861d43a731182e3a83aa2876d48d19488f438dcb5", red.ToString()); | ||
#endif | ||
} | ||
} | ||
} |