本文整理汇总了C#中ImageMagick.MagickImage.Threshold方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.Threshold方法的具体用法?C# MagickImage.Threshold怎么用?C# MagickImage.Threshold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageMagick.MagickImage
的用法示例。
在下文中一共展示了MagickImage.Threshold方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteThreshold
private void ExecuteThreshold(XmlElement element, MagickImage image)
{
Percentage percentage_ = Variables.GetValue<Percentage>(element, "percentage");
image.Threshold(percentage_);
}
示例2: Test_Compare
public void Test_Compare()
{
MagickImage first = new MagickImage(Files.SnakewarePNG);
MagickImage second = first.Clone();
MagickErrorInfo same = first.Compare(second);
Assert.IsNotNull(same);
Assert.AreEqual(0, same.MeanErrorPerPixel);
double distortion = first.Compare(second, ErrorMetric.Absolute);
Assert.AreEqual(0, distortion);
first.Threshold(new Percentage(50));
MagickErrorInfo different = first.Compare(second);
Assert.IsNotNull(different);
Assert.AreNotEqual(0, different.MeanErrorPerPixel);
distortion = first.Compare(second, ErrorMetric.Absolute);
Assert.AreNotEqual(0, distortion);
MagickImage difference = new MagickImage();
distortion = first.Compare(second, ErrorMetric.RootMeanSquared, difference);
Assert.AreNotEqual(0, distortion);
Assert.AreNotEqual(first, difference);
Assert.AreNotEqual(second, difference);
}
示例3: Test_BitDepth
public void Test_BitDepth()
{
using (MagickImage image = new MagickImage(Files.RoseSparkleGIF))
{
Assert.AreEqual(8, image.BitDepth());
image.Threshold((Percentage)50);
Assert.AreEqual(1, image.BitDepth());
}
}
示例4: Test_Threshold
public void Test_Threshold()
{
using (MagickImage image = new MagickImage(Files.ImageMagickJPG))
{
using (MemoryStream memStream = new MemoryStream())
{
image.Threshold(new Percentage(80));
image.CompressionMethod = CompressionMethod.Group4;
image.Format = MagickFormat.Pdf;
image.Write(memStream);
}
}
}
示例5: Test_Compare
public void Test_Compare()
{
MagickImage first = new MagickImage(Files.ImageMagickJPG);
ExceptionAssert.Throws<ArgumentNullException>(delegate ()
{
first.Compare(null);
});
MagickImage second = first.Clone();
MagickErrorInfo same = first.Compare(second);
Assert.IsNotNull(same);
Assert.AreEqual(0, same.MeanErrorPerPixel);
double distortion = first.Compare(second, ErrorMetric.Absolute);
Assert.AreEqual(0, distortion);
first.Threshold(new Percentage(50));
MagickErrorInfo different = first.Compare(second);
Assert.IsNotNull(different);
Assert.AreNotEqual(0, different.MeanErrorPerPixel);
distortion = first.Compare(second, ErrorMetric.Absolute);
Assert.AreNotEqual(0, distortion);
MagickImage difference = new MagickImage();
distortion = first.Compare(second, ErrorMetric.RootMeanSquared, difference);
Assert.AreNotEqual(0, distortion);
Assert.AreNotEqual(first, difference);
Assert.AreNotEqual(second, difference);
second.Dispose();
first.Opaque(MagickColors.Black, MagickColors.Green);
first.Opaque(MagickColors.White, MagickColors.Green);
second = first.Clone();
second.FloodFill(MagickColors.Gray, 0, 0);
distortion = first.Compare(second, ErrorMetric.Absolute, Channels.Green);
Assert.AreEqual(0, distortion);
distortion = first.Compare(second, ErrorMetric.Absolute, Channels.Red);
Assert.AreNotEqual(0, distortion);
}
示例6: Test_CannyEdge_HoughLine
public void Test_CannyEdge_HoughLine()
{
using (MagickImage image = new MagickImage(Files.ConnectedComponentsPNG))
{
image.Threshold(new Percentage(50));
ColorAssert.AreEqual(MagickColors.Black, image, 150, 365);
image.Negate();
ColorAssert.AreEqual(MagickColors.White, image, 150, 365);
image.CannyEdge();
ColorAssert.AreEqual(MagickColors.Black, image, 150, 365);
image.Crop(260, 180, 215, 200);
image.Settings.FillColor = MagickColors.Red;
image.Settings.StrokeColor = MagickColors.Red;
image.HoughLine();
ColorAssert.AreEqual(MagickColors.Red, image, 105, 25);
}
}