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


C# MagickImage.Sharpen方法代码示例

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


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

示例1: sharpen

 public static void sharpen(string image_path, string output_path, double radius = 5, double sigma = 30)
 {
     using (MagickImage image = new MagickImage(image_path)) {
         image.Sharpen(radius, sigma);
         image.Write(output_path);
     }
 }
开发者ID:Neonarg,项目名称:TempestNotifier,代码行数:7,代码来源:Image.cs

示例2: ExecuteSharpen

 private void ExecuteSharpen(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 (arguments.Count == 0)
     image.Sharpen();
   else if (OnlyContains(arguments, "channels"))
     image.Sharpen((Channels)arguments["channels"]);
   else if (OnlyContains(arguments, "radius", "sigma"))
     image.Sharpen((double)arguments["radius"], (double)arguments["sigma"]);
   else if (OnlyContains(arguments, "radius", "sigma", "channels"))
     image.Sharpen((double)arguments["radius"], (double)arguments["sigma"], (Channels)arguments["channels"]);
   else
     throw new ArgumentException("Invalid argument combination for 'sharpen', allowed combinations are: [] [channels] [radius, sigma] [radius, sigma, channels]");
 }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:23,代码来源:MagickImage.cs

示例3: Draw

        public MagickImage Draw()
        {
            MainForm.ProgressStart("Rendering background ...");

            // Check which terrain file is used
            string texMpk = string.Format("{0}\\tex{1}.mpk", this.textureZoneDataDirectory, this.textureZoneId);
            string lodMpk = string.Format("{0}\\lod{1}.mpk", this.textureZoneDataDirectory, this.textureZoneId);

            // Get the tile dimension
            double tileWidth = 512.0;
            string tileTemplate = "";

            MPAK mpak = new MPAK();
            if (File.Exists(texMpk))
            {
                mpak.Load(texMpk);

                if (mpak.Files.Where(f => f.Name.ToLower() == "tex00-00.dds").Count() > 0)
                {
                    tileTemplate += "tex0{0}-0{1}.dds";
                    tileWidth = 512.0;
                }
            }

            if (string.IsNullOrEmpty(tileTemplate))
            {
                mpak.Load(lodMpk);

                if (mpak.Files.Where(f => f.Name.ToLower() == "lod00-00.dds").Count() > 0)
                {
                    tileTemplate += "lod0{0}-0{1}.dds";
                    tileWidth = 256.0;
                }
            }

            if (string.IsNullOrEmpty(tileTemplate))
            {
                MainForm.Log(string.Format("Zone {0}: No background textures found!", zoneConfiguration.ZoneId), MainForm.LogLevel.error);
                return null;
            }

            // original size
            double orginalWidth = tileWidth * 8;
            double resizeFactor = (double)zoneConfiguration.TargetMapSize / (double)orginalWidth; // 0 - 1

            MagickImage map = new MagickImage(Color.Transparent, zoneConfiguration.TargetMapSize, zoneConfiguration.TargetMapSize);

            int lastWidth = 0;
            int x = 0;
            for (int col = 0; col <= 7; col++)
            {
                int y = 0;
                for (int row = 0; row <= 7; row++)
                {
                    string filename = string.Format(tileTemplate, col, row);

                    using (MagickImage mapTile = new MagickImage(mpak.GetFile(filename).Data))
                    {
                        int newSize = Convert.ToInt32(mapTile.Width * resizeFactor);
                        mapTile.Resize(newSize, newSize);

                        map.Composite(mapTile, x, y, CompositeOperator.SrcOver);

                        // Calculate new y
                        y += mapTile.Height;
                        lastWidth = mapTile.Height;
                    }
                }

                x += lastWidth;

                int percent = 100 * col / 8;
                MainForm.ProgressUpdate(percent);
            }

            MainForm.ProgressStartMarquee("Merging ...");

            // Remove rounding fails
            map.Trim();

            // Flip if set
            if (this.flipX) map.Flop();
            if (this.flipY) map.Flip();

            // Sharpen (tested a lot, seems to be the best values)
            map.Sharpen(4, 3);

            MainForm.ProgressReset();

            return map;
        }
开发者ID:Merec,项目名称:DAoC-MapCreator,代码行数:91,代码来源:MapBackground.cs

示例4: ApplyPreviewImageMagick

        public static void ApplyPreviewImageMagick(string source, string destination, double maxWidth = 0d, double maxHeight = 0d) {
            using (var image = new MagickImage(source)) {
                if (maxWidth > 0d || maxHeight > 0d) {
                    var k = Math.Max(maxHeight / image.Height, maxWidth / image.Width);
                    image.Interpolate = PixelInterpolateMethod.Bicubic;
                    image.FilterType = FilterType.Lanczos;
                    image.Sharpen();
                    image.Resize((int)(k * image.Width), (int)(k * image.Height));
                    image.Crop(CommonAcConsts.PreviewWidth, CommonAcConsts.PreviewHeight, Gravity.Center);
                }

                image.Quality = 95;
                image.Density = new MagickGeometry(96, 96);
                if (File.Exists(destination)) {
                    try {
                        File.Delete(destination);
                    } catch (UnauthorizedAccessException) {
                        Thread.Sleep(200);
                        File.Delete(destination);
                    }
                }

                image.Write(destination);
            }
        }
开发者ID:gro-ove,项目名称:actools,代码行数:25,代码来源:ImageUtils.cs

示例5: processImgForScanning

        private Bitmap processImgForScanning(Bitmap imgInput)
        {
            using (MemoryStream memstream = new MemoryStream())
            {
                imgInput.Save(memstream, ImageFormat.Tiff);
                MagickImage img = new MagickImage(memstream.ToArray());

                if (sharpen)
                {
                    img.Sharpen((int)sharpenIntX.Value, (int)sharpenIntY.Value, Channels.All);
                }

                if (autoGamma)
                {
                    img.AutoGamma();
                }

                if (enhance)
                {
                    img.Enhance();
                }

                if (contrast)
                {
                    img.Contrast();
                }

                if (autoLevel)
                {
                    img.AutoLevel();
                }

                if (autoOrient)
                {
                    img.AutoOrient();
                }

                if (despeckle)
                {
                    img.Despeckle();
                }

                if (medianFilter)
                {
                    img.MedianFilter((int)medianInt.Value);
                }

                if (unsharpmask)
                {
                    img.Unsharpmask(6.8, 4, 4,0);
                }

                if (wtThreshold)
                {
                    img.LinearStretch((float)0.9, 0.1);
                    //img.WhiteThreshold((int)wtThresInt.Value);
                    //img.ReduceNoise();
                    //img.Grayscale(PixelIntensityMethod.Brightness);
                }

                if (invert)
                {
                    img.Negate();
                }

                return img.ToBitmap();
            }
        }
开发者ID:dynamicdeploy,项目名称:ReceiptOCR,代码行数:68,代码来源:Form1.cs

示例6: Test_Sharpen

    public void Test_Sharpen()
    {
      using (MagickImage image = new MagickImage(Files.NoisePNG))
      {
        image.Sharpen(10, 20);
        image.Clamp();

        using (MagickImage original = new MagickImage(Files.NoisePNG))
        {
          Assert.AreEqual(0.06675, image.Compare(original, ErrorMetric.RootMeanSquared), 0.00001);
        }
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:13,代码来源:MagickImageTests.cs


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