Class that contains setting for the morphology operation.
 private MorphologySettings CreateMorphologySettings(XmlElement element)
 {
   if (element == null)
     return null;
   MorphologySettings result = new MorphologySettings();
   result.Channels = Variables.GetValue<Channels>(element, "channels");
   result.ConvolveBias = Variables.GetValue<Nullable<Percentage>>(element, "convolveBias");
   result.ConvolveScale = Variables.GetValue<MagickGeometry>(element, "convolveScale");
   result.Iterations = Variables.GetValue<Int32>(element, "iterations");
   result.Kernel = Variables.GetValue<Kernel>(element, "kernel");
   result.KernelArguments = Variables.GetValue<String>(element, "kernelArguments");
   result.Method = Variables.GetValue<MorphologyMethod>(element, "method");
   result.UserKernel = Variables.GetValue<String>(element, "userKernel");
   return result;
 }
        private MorphologySettings CreateMorphologySettings(XmlElement element)
        {
            if (element == null)
            {
                return(null);
            }
            MorphologySettings result = new MorphologySettings();

            result.Channels        = Variables.GetValue <Channels>(element, "channels");
            result.ConvolveBias    = Variables.GetValue <Nullable <Percentage> >(element, "convolveBias");
            result.ConvolveScale   = Variables.GetValue <MagickGeometry>(element, "convolveScale");
            result.Iterations      = Variables.GetValue <Int32>(element, "iterations");
            result.Kernel          = Variables.GetValue <Kernel>(element, "kernel");
            result.KernelArguments = Variables.GetValue <String>(element, "kernelArguments");
            result.Method          = Variables.GetValue <MorphologyMethod>(element, "method");
            result.UserKernel      = Variables.GetValue <String>(element, "userKernel");
            return(result);
        }
    public void Test_Morphology()
    {
      using (MagickImage image = new MagickImage(Files.Builtin.Logo))
      {
        ExceptionAssert.Throws<MagickOptionErrorException>(delegate ()
        {
          image.Morphology(MorphologyMethod.Smooth, "Magick");
        });

        image.Morphology(MorphologyMethod.Dilate, Kernel.Square, "1");

        image.Morphology(MorphologyMethod.Convolve, "3: 0.3,0.6,0.3 0.6,1.0,0.6 0.3,0.6,0.3");

        MorphologySettings settings = new MorphologySettings();
        settings.Method = MorphologyMethod.Convolve;
        settings.ConvolveBias = new Percentage(50);
        settings.Kernel = Kernel.DoG;
        settings.KernelArguments = "0x2";

        image.Read(Files.Builtin.Logo);

        ExceptionAssert.Throws<ArgumentNullException>(delegate ()
        {
          image.Morphology(null);
        });

        image.Morphology(settings);

        QuantumType half = (QuantumType)((Quantum.Max / 2.0) + 0.5);
        ColorAssert.AreEqual(new MagickColor(half, half, half), image, 120, 160);
      }
    }