本文整理汇总了C#中ImageMagick.MagickImage.Posterize方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.Posterize方法的具体用法?C# MagickImage.Posterize怎么用?C# MagickImage.Posterize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageMagick.MagickImage
的用法示例。
在下文中一共展示了MagickImage.Posterize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: threshold
public static void threshold(string image_path, string output_path, int brightness = 20, int contrast = 20, int posterize = 2)
{
using (MagickImage image = new MagickImage(image_path)) {
image.BrightnessContrast(brightness, contrast);
image.ColorSpace = ColorSpace.Gray;
image.Posterize(posterize);
image.Normalize();
image.Write(output_path);
}
}
示例2: ExecutePosterize
private void ExecutePosterize(XmlElement element, MagickImage image)
{
Hashtable arguments = new Hashtable();
foreach (XmlAttribute attribute in element.Attributes)
{
if (attribute.Name == "channels")
arguments["channels"] = Variables.GetValue<Channels>(attribute);
else if (attribute.Name == "levels")
arguments["levels"] = Variables.GetValue<Int32>(attribute);
else if (attribute.Name == "method")
arguments["method"] = Variables.GetValue<DitherMethod>(attribute);
}
if (OnlyContains(arguments, "levels"))
image.Posterize((Int32)arguments["levels"]);
else if (OnlyContains(arguments, "levels", "channels"))
image.Posterize((Int32)arguments["levels"], (Channels)arguments["channels"]);
else if (OnlyContains(arguments, "levels", "method"))
image.Posterize((Int32)arguments["levels"], (DitherMethod)arguments["method"]);
else if (OnlyContains(arguments, "levels", "method", "channels"))
image.Posterize((Int32)arguments["levels"], (DitherMethod)arguments["method"], (Channels)arguments["channels"]);
else
throw new ArgumentException("Invalid argument combination for 'posterize', allowed combinations are: [levels] [levels, channels] [levels, method] [levels, method, channels]");
}
示例3: Test_Posterize
public void Test_Posterize()
{
using (MagickImage image = new MagickImage(Files.FujiFilmFinePixS1ProJPG))
{
image.Posterize(5);
#if Q8
ColorAssert.AreEqual(new MagickColor("#3f7fbf"), image, 300, 150);
ColorAssert.AreEqual(new MagickColor("#3f3f7f"), image, 495, 270);
ColorAssert.AreEqual(new MagickColor("#3f3f3f"), image, 445, 255);
#elif Q16 || Q16HDRI
ColorAssert.AreEqual(new MagickColor("#3fff7fffbfff"), image, 300, 150);
ColorAssert.AreEqual(new MagickColor("#3fff3fff7fff"), image, 495, 270);
ColorAssert.AreEqual(new MagickColor("#3fff3fff3fff"), image, 445, 255);
#else
#error Not implemented!
#endif
}
}