当前位置: 首页>>代码示例>>C#>>正文


C# MagickImage.UnsharpMask方法代码示例

本文整理汇总了C#中ImageMagick.MagickImage.UnsharpMask方法的典型用法代码示例。如果您正苦于以下问题:C# MagickImage.UnsharpMask方法的具体用法?C# MagickImage.UnsharpMask怎么用?C# MagickImage.UnsharpMask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageMagick.MagickImage的用法示例。


在下文中一共展示了MagickImage.UnsharpMask方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

 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;
 }
开发者ID:CadeLaRen,项目名称:digiCamControl,代码行数:22,代码来源:Enhance.cs

示例2: GenerateCache

        public void GenerateCache(FileItem fileItem)
        {
            bool deleteFile = false;
            if (fileItem == null)
                return;
            if (!File.Exists(fileItem.FileName))
                return;

            if ((File.Exists(fileItem.LargeThumb) && File.Exists(fileItem.SmallThumb)) && File.Exists(fileItem.InfoFile))
                return;

            if (fileItem.Loading)
                return;

            fileItem.Loading = true;

            PhotoUtils.WaitForFile(fileItem.FileName);
            string filename = fileItem.FileName;
            if (fileItem.IsMovie)
            {
                try
                {
                    string ffmpeg_exe = Path.Combine(Settings.ApplicationFolder, "ffmpeg.exe");
                    if (File.Exists(ffmpeg_exe))
                    {
                        string thumb = Path.Combine(Path.GetDirectoryName(fileItem.FileName),
                            Path.GetFileNameWithoutExtension(fileItem.FileName) + ".thumb.jpg");
                        PhotoUtils.RunAndWait(ffmpeg_exe, String.Format("-i \"{0}\" -ss 00:00:01.000 -f image2 -vframes 1 \"{1}\"", fileItem.FileName, thumb));
                        if (File.Exists(thumb))
                        {
                            deleteFile = true;
                            filename = thumb;
                        }
                    }
                }
                catch (Exception exception)
                {
                    Log.Error("Error get video thumb", exception);
                }
            }
            if (fileItem.IsRaw)
            {
                try
                {
                    string dcraw_exe = Path.Combine(Settings.ApplicationFolder, "dcraw.exe");
                    if (File.Exists(dcraw_exe))
                    {
                        string thumb = Path.Combine(Path.GetTempPath(),
                            Path.GetFileNameWithoutExtension(fileItem.FileName) + ".thumb.jpg");
                        PhotoUtils.RunAndWait(dcraw_exe,
                            string.Format(" -e -O \"{0}\" \"{1}\"", thumb, fileItem.FileName));
                        if (File.Exists(thumb))
                        {
                            deleteFile = true;
                            filename = thumb;
                        }
                    }
                }
                catch (Exception exception)
                {
                    Log.Error("Error get dcraw thumb", exception);
                }
            }

            GetMetadata(fileItem);
            try
            {
                using (MagickImage image = new MagickImage(filename))
                {
                    fileItem.FileInfo.SetSize(image.Width, image.Height);

                    double dw = (double)LargeThumbSize / image.Width;
                    image.FilterType = FilterType.Box;
                    image.Thumbnail((int)(image.Width * dw), (int)(image.Height * dw));

                    if (!ServiceProvider.Settings.DisableHardwareAccelerationNew)
                        image.UnsharpMask(1, 1, 0.5, 0.1);

                    PhotoUtils.CreateFolder(fileItem.LargeThumb);
                    image.Write(fileItem.LargeThumb);
                    fileItem.IsLoaded = true;
                    fileItem.Loading = false;

                    dw = (double)SmallThumbSize / image.Width;
                    image.Thumbnail((int)(image.Width * dw), (int)(image.Height * dw));

                    if (!ServiceProvider.Settings.DisableHardwareAccelerationNew)
                        image.UnsharpMask(1, 1, 0.5, 0.1);

                    PhotoUtils.CreateFolder(fileItem.SmallThumb);
                    image.Write(fileItem.SmallThumb);

                    fileItem.Thumbnail = LoadImage(fileItem.SmallThumb);
                }
                fileItem.SaveInfo();
                SetImageInfo(fileItem);
                if (deleteFile)
                    File.Delete(filename);
                OnMetaDataUpdated(fileItem);
            }
//.........这里部分代码省略.........
开发者ID:CadeLaRen,项目名称:digiCamControl,代码行数:101,代码来源:BitmapLoader.cs

示例3: ExecuteUnsharpMask

 private void ExecuteUnsharpMask(XmlElement element, MagickImage image)
 {
   Hashtable arguments = new Hashtable();
   foreach (XmlAttribute attribute in element.Attributes)
   {
     if (attribute.Name == "amount")
       arguments["amount"] = Variables.GetValue<double>(attribute);
     else 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);
     else if (attribute.Name == "threshold")
       arguments["threshold"] = Variables.GetValue<double>(attribute);
   }
   if (OnlyContains(arguments, "radius", "sigma"))
     image.UnsharpMask((double)arguments["radius"], (double)arguments["sigma"]);
   else if (OnlyContains(arguments, "radius", "sigma", "amount", "threshold"))
     image.UnsharpMask((double)arguments["radius"], (double)arguments["sigma"], (double)arguments["amount"], (double)arguments["threshold"]);
   else if (OnlyContains(arguments, "radius", "sigma", "amount", "threshold", "channels"))
     image.UnsharpMask((double)arguments["radius"], (double)arguments["sigma"], (double)arguments["amount"], (double)arguments["threshold"], (Channels)arguments["channels"]);
   else if (OnlyContains(arguments, "radius", "sigma", "channels"))
     image.UnsharpMask((double)arguments["radius"], (double)arguments["sigma"], (Channels)arguments["channels"]);
   else
     throw new ArgumentException("Invalid argument combination for 'unsharpMask', allowed combinations are: [radius, sigma] [radius, sigma, amount, threshold] [radius, sigma, amount, threshold, channels] [radius, sigma, channels]");
 }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:27,代码来源:MagickImage.cs

示例4: Test_UnsharpMask

    public void Test_UnsharpMask()
    {
      using (MagickImage image = new MagickImage(Files.NoisePNG))
      {
        image.UnsharpMask(7.0, 3.0);

        using (MagickImage original = new MagickImage(Files.NoisePNG))
        {
#if Q8 || Q16
          Assert.AreEqual(0.06476, original.Compare(image, ErrorMetric.RootMeanSquared), 0.00002);
#elif Q16HDRI
          Assert.AreEqual(0.10234, original.Compare(image, ErrorMetric.RootMeanSquared), 0.00001);
#else
#error Not implemented!
#endif
        }
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:18,代码来源:MagickImageTests.cs


注:本文中的ImageMagick.MagickImage.UnsharpMask方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。