コード例 #1
0
ファイル: Enhance.cs プロジェクト: CadeLaRen/digiCamControl
 public string Execute(FileItem item, string infile, string dest, ValuePairEnumerator configData)
 {
     var conf = new EnhanceViewModel(configData);
     dest = Path.Combine(Path.GetDirectoryName(dest), Path.GetFileNameWithoutExtension(dest) + ".jpg");
     using (MagickImage image = new MagickImage(infile))
     {
         if (conf.Normalize)
             image.Normalize();
         if (conf.AutoGamma)
             image.AutoGamma();
         image.BrightnessContrast(new Percentage(conf.Brightness), new Percentage(conf.Contrast));
         if (conf.SContrast > 0)
             image.SigmoidalContrast(true, conf.SContrast);
         if (conf.Edge)
             image.AdaptiveSharpen();
         if (conf.Sharpen > 0)
             image.UnsharpMask(1.5, 1.5, conf.Sharpen/100.0, 0.2);
         image.Format = MagickFormat.Jpeg;
         image.Write(dest);
     }
     return dest;
 }
コード例 #2
0
ファイル: MagickImage.cs プロジェクト: dlemstra/Magick.NET
 private void ExecuteSigmoidalContrast(XmlElement element, MagickImage image)
 {
   Hashtable arguments = new Hashtable();
   foreach (XmlAttribute attribute in element.Attributes)
   {
     if (attribute.Name == "contrast")
       arguments["contrast"] = Variables.GetValue<double>(attribute);
     else if (attribute.Name == "midpoint")
       arguments["midpoint"] = Variables.GetValue<double>(attribute);
     else if (attribute.Name == "sharpen")
       arguments["sharpen"] = Variables.GetValue<Boolean>(attribute);
   }
   if (OnlyContains(arguments, "contrast"))
     image.SigmoidalContrast((double)arguments["contrast"]);
   else if (OnlyContains(arguments, "contrast", "midpoint"))
     image.SigmoidalContrast((double)arguments["contrast"], (double)arguments["midpoint"]);
   else if (OnlyContains(arguments, "sharpen", "contrast"))
     image.SigmoidalContrast((Boolean)arguments["sharpen"], (double)arguments["contrast"]);
   else if (OnlyContains(arguments, "sharpen", "contrast", "midpoint"))
     image.SigmoidalContrast((Boolean)arguments["sharpen"], (double)arguments["contrast"], (double)arguments["midpoint"]);
   else
     throw new ArgumentException("Invalid argument combination for 'sigmoidalContrast', allowed combinations are: [contrast] [contrast, midpoint] [sharpen, contrast] [sharpen, contrast, midpoint]");
 }
コード例 #3
0
    public void Test_SigmoidalContrast()
    {
      using (MagickImage image = new MagickImage(Files.NoisePNG))
      {
        image.SigmoidalContrast(true, 8.0);

        using (MagickImage original = new MagickImage(Files.NoisePNG))
        {
          Assert.AreEqual(0.07361, original.Compare(image, ErrorMetric.RootMeanSquared), 0.00001);
        }
      }
    }