private void ExecuteGaussianBlur(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 == "radius") arguments["radius"] = Variables.GetValue<double>(attribute); else if (attribute.Name == "sigma") arguments["sigma"] = Variables.GetValue<double>(attribute); } if (OnlyContains(arguments, "radius", "sigma")) image.GaussianBlur((double)arguments["radius"], (double)arguments["sigma"]); else if (OnlyContains(arguments, "radius", "sigma", "channels")) image.GaussianBlur((double)arguments["radius"], (double)arguments["sigma"], (Channels)arguments["channels"]); else throw new ArgumentException("Invalid argument combination for 'gaussianBlur', allowed combinations are: [radius, sigma] [radius, sigma, channels]"); }
public static void blur(string image_path, string output_path, double width = 2, double sigma = 2) { using (MagickImage image = new MagickImage(image_path)) { image.GaussianBlur(width, sigma); image.Write(output_path); } }
public void Test_GaussianBlur() { using (MagickImage gaussian = new MagickImage(Files.Builtin.Wizard)) { gaussian.GaussianBlur(5.5, 10.2); using (MagickImage blur = new MagickImage(Files.Builtin.Wizard)) { blur.Blur(5.5, 10.2); double distortion = blur.Compare(gaussian, ErrorMetric.RootMeanSquared); #if Q8 Assert.AreEqual(0.00066, distortion, 0.00001); #elif Q16 Assert.AreEqual(0.0000033, distortion, 0.0000001); #elif Q16HDRI Assert.AreEqual(0.0000011, distortion, 0.0000001); #else #error Not implemented! #endif } } }