// Copyright (c) Six Labors and contributors. // Licensed under the Apache License, Version 2.0. using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing.Processors; using SixLabors.Primitives; using Xunit; namespace SixLabors.ImageSharp.Tests.Processing.Binarization { public class BinaryThresholdTest : BaseImageOperationsExtensionTest { [Fact] public void BinaryThreshold_CorrectProcessor() { this.operations.BinaryThreshold(.23f); BinaryThresholdProcessor p = this.Verify>(); Assert.Equal(.23f, p.Threshold); Assert.Equal(NamedColors.White, p.UpperColor); Assert.Equal(NamedColors.Black, p.LowerColor); } [Fact] public void BinaryThreshold_rect_CorrectProcessor() { this.operations.BinaryThreshold(.93f, this.rect); BinaryThresholdProcessor p = this.Verify>(this.rect); Assert.Equal(.93f, p.Threshold); Assert.Equal(NamedColors.White, p.UpperColor); Assert.Equal(NamedColors.Black, p.LowerColor); } [Fact] public void BinaryThreshold_CorrectProcessorWithUpperLower() { this.operations.BinaryThreshold(.23f, NamedColors.HotPink, NamedColors.Yellow); BinaryThresholdProcessor p = this.Verify>(); Assert.Equal(.23f, p.Threshold); Assert.Equal(NamedColors.HotPink, p.UpperColor); Assert.Equal(NamedColors.Yellow, p.LowerColor); } [Fact] public void BinaryThreshold_rect_CorrectProcessorWithUpperLower() { this.operations.BinaryThreshold(.93f, NamedColors.HotPink, NamedColors.Yellow, this.rect); BinaryThresholdProcessor p = this.Verify>(this.rect); Assert.Equal(.93f, p.Threshold); Assert.Equal(NamedColors.HotPink, p.UpperColor); Assert.Equal(NamedColors.Yellow, p.LowerColor); } } }