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


C# MagickImage.Compare方法代码示例

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


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

示例1: Test_Image_ByteArray

    public void Test_Image_ByteArray()
    {
      using (Image img = Image.FromFile(Files.Coders.PageTIF))
      {
        byte[] bytes = null;
        using (MemoryStream memStream = new MemoryStream())
        {
          img.Save(memStream, ImageFormat.Tiff);
          bytes = memStream.GetBuffer();
        }

        using (MagickImage image = new MagickImage(bytes))
        {
          image.CompressionMethod = CompressionMethod.Group4;

          using (MemoryStream memStream = new MemoryStream())
          {
            image.Write(memStream);
            memStream.Position = 0;

            using (MagickImage before = new MagickImage(Files.Coders.PageTIF))
            {
              using (MagickImage after = new MagickImage(memStream))
              {
                Assert.AreEqual(0.0, before.Compare(after, ErrorMetric.RootMeanSquared));
              }
            }
          }
        }
      }
    }
开发者ID:levesque,项目名称:Magick.NET,代码行数:31,代码来源:TiffTests.cs

示例2: Test_Clone_Area

    private static void Test_Clone_Area(MagickImage area, MagickImage part)
    {
      Assert.AreEqual(area.Width, part.Width);
      Assert.AreEqual(area.Height, part.Height);

      Assert.AreEqual(0.0, area.Compare(part, ErrorMetric.RootMeanSquared));
    }
开发者ID:marinehero,项目名称:Magick.NET,代码行数:7,代码来源:MagickImageTests.cs

示例3: CompareImages

        public void CompareImages([CallerMemberName] string testName = "")
        {
            string expectedPath = Path.Combine(testDirectory, testName + ".expected.png");
            string actualPath = Path.Combine(testDirectory, testName + ".wpf.out.png");
            MagickImage expected = new MagickImage(expectedPath);
            MagickImage actual = new MagickImage(actualPath);
            MagickErrorInfo error = expected.Compare(actual);

            Assert.IsNull(error);
        }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:10,代码来源:TestBase.cs

示例4: Compare

        public double Compare(MagickImage leftImage, MagickImage rightImage, out MagickImage diffImage)
        {
            // See:
            // [1] https://stackoverflow.com/questions/5132749/diff-an-image-using-imagemagick
            // [2] https://stackoverflow.com/questions/20582620/how-to-compare-2-images-ignoring-areas#26584462

            // resize image to the same size - ImageMagick requires both images to be of the same size
            rightImage.Crop(leftImage.BaseWidth, leftImage.BaseHeight);

            // apply the mask to the screenshot
            rightImage.Composite(leftImage, CompositeOperator.DstIn);

            // compare masked screenshot against reference image
            diffImage = new MagickImage();
            return rightImage.Compare(leftImage, ErrorMetric.Absolute, diffImage);
        }
开发者ID:nimeshjm,项目名称:EPiServer-test-automation,代码行数:16,代码来源:ScreenShotService.cs

示例5: saveResult

        public void saveResult(string FilePath1, string FilePath2, string outFilePath)
        {
            MagickImageCollection images = new MagickImageCollection();
            // Add the first image
            MagickImage first = new MagickImage(FilePath1);

             //   images.Add(first);

            // Add the second image
            MagickImage second = new MagickImage(FilePath2);
               // images.Add(second);

            /*
            first.Composite(second, 0, 0, CompositeOperator.ModulusAdd);
            first.Write(outFilePath + "compos.png");

            */
            MagickImage third = new MagickImage();
            first.Compare(second, ErrorMetric.Absolute, third);
            third.Write(outFilePath + "third.bmp");
        }
开发者ID:a-mironov-parc,项目名称:KTAutotests,代码行数:21,代码来源:ImageHelper.cs

示例6: Test_GaussianBlur

    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
        }
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:23,代码来源:MagickImageTests.cs

示例7: Test_Composite_ChangeMask

    public void Test_Composite_ChangeMask()
    {
      using (MagickImage background = new MagickImage("xc:red", 100, 100))
      {
        background.BackgroundColor = Color.White;
        background.Extent(200, 100);

        IDrawable[] drawables = new IDrawable[]
        {
          new DrawablePointSize(50),
          new DrawableText(135, 70, "X")
        };

        using (MagickImage image = background.Clone())
        {
          image.Draw(drawables);
          image.Composite(background, Gravity.Center, CompositeOperator.ChangeMask);

          using (MagickImage result = new MagickImage(MagickColor.Transparent, 200, 100))
          {
            result.Draw(drawables);
            Assert.AreEqual(0.073, result.Compare(image, ErrorMetric.RootMeanSquared), 0.001);
          }
        }
      }
    }
开发者ID:marinehero,项目名称:Magick.NET,代码行数:26,代码来源:MagickImageTests.cs

示例8: Test_Compare

    public void Test_Compare()
    {
      MagickImage first = new MagickImage(Files.SnakewarePNG);
      MagickImage second = first.Clone();

      MagickErrorInfo same = first.Compare(second);
      Assert.IsNotNull(same);
      Assert.AreEqual(0, same.MeanErrorPerPixel);

      double distortion = first.Compare(second, ErrorMetric.Absolute);
      Assert.AreEqual(0, distortion);

      first.Threshold(new Percentage(50));
      MagickErrorInfo different = first.Compare(second);
      Assert.IsNotNull(different);
      Assert.AreNotEqual(0, different.MeanErrorPerPixel);

      distortion = first.Compare(second, ErrorMetric.Absolute);
      Assert.AreNotEqual(0, distortion);

      MagickImage difference = new MagickImage();
      distortion = first.Compare(second, ErrorMetric.RootMeanSquared, difference);
      Assert.AreNotEqual(0, distortion);
      Assert.AreNotEqual(first, difference);
      Assert.AreNotEqual(second, difference);
    }
开发者ID:marinehero,项目名称:Magick.NET,代码行数:26,代码来源:MagickImageTests.cs

示例9: Test_Compare

    public void Test_Compare()
    {
      MagickImage first = new MagickImage(Files.ImageMagickJPG);

      ExceptionAssert.Throws<ArgumentNullException>(delegate ()
      {
        first.Compare(null);
      });

      MagickImage second = first.Clone();

      MagickErrorInfo same = first.Compare(second);
      Assert.IsNotNull(same);
      Assert.AreEqual(0, same.MeanErrorPerPixel);

      double distortion = first.Compare(second, ErrorMetric.Absolute);
      Assert.AreEqual(0, distortion);

      first.Threshold(new Percentage(50));
      MagickErrorInfo different = first.Compare(second);
      Assert.IsNotNull(different);
      Assert.AreNotEqual(0, different.MeanErrorPerPixel);

      distortion = first.Compare(second, ErrorMetric.Absolute);
      Assert.AreNotEqual(0, distortion);

      MagickImage difference = new MagickImage();
      distortion = first.Compare(second, ErrorMetric.RootMeanSquared, difference);
      Assert.AreNotEqual(0, distortion);
      Assert.AreNotEqual(first, difference);
      Assert.AreNotEqual(second, difference);

      second.Dispose();

      first.Opaque(MagickColors.Black, MagickColors.Green);
      first.Opaque(MagickColors.White, MagickColors.Green);

      second = first.Clone();
      second.FloodFill(MagickColors.Gray, 0, 0);

      distortion = first.Compare(second, ErrorMetric.Absolute, Channels.Green);
      Assert.AreEqual(0, distortion);

      distortion = first.Compare(second, ErrorMetric.Absolute, Channels.Red);
      Assert.AreNotEqual(0, distortion);
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:46,代码来源:MagickImageTests.cs

示例10: Test_LevelColors

    public void Test_LevelColors()
    {
      using (MagickImage image = new MagickImage(Files.MagickNETIconPNG))
      {
        image.LevelColors(MagickColors.Fuchsia, MagickColors.Goldenrod);
        ColorAssert.AreEqual(new MagickColor("#ffffbed24bc3fffa"), image, 42, 75);
        ColorAssert.AreEqual(new MagickColor("#ffffffff0809"), image, 62, 75);
      }

      using (MagickImage first = new MagickImage(Files.MagickNETIconPNG))
      {
        first.LevelColors(MagickColors.Fuchsia, MagickColors.Goldenrod, Channels.Blue);
        first.InverseLevelColors(MagickColors.Fuchsia, MagickColors.Goldenrod, Channels.Blue);
        first.Alpha(AlphaOption.Background);

        using (MagickImage second = new MagickImage(Files.MagickNETIconPNG))
        {
          second.Alpha(AlphaOption.Background);
#if Q8
          Assert.AreEqual(0.0, first.Compare(second, ErrorMetric.RootMeanSquared));
#elif Q16 || Q16HDRI
          Assert.AreEqual(0.0, 0.00000001, first.Compare(second, ErrorMetric.RootMeanSquared));
#else
#error Not implemented!
#endif
        }
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:28,代码来源:MagickImageTests.cs

示例11: saveResult

        public double saveResult(MagickImage StandartIM, MagickImage CurrentIM, string outFilePath, string outCurFilePath)
        {
            MagickImage resultImage = new MagickImage();
            var compareResult = StandartIM.Compare(CurrentIM, ErrorMetric.Absolute, resultImage);

            if (compareResult != 0)
            {
                CreateScreenDirectory(Path.GetDirectoryName(outFilePath));
                CreateScreenDirectory(Path.GetDirectoryName(outCurFilePath));
                resultImage.Write(outFilePath);
                CurrentIM.Write(outCurFilePath);
                Console.Out.WriteLine("Погрешность= " + compareResult + " Изображения не совпадают" + outFilePath);

            }
            else
            {
                Console.Out.WriteLine("Изображения совпадают");

            }
            return compareResult;
        }
开发者ID:a-mironov-parc,项目名称:KTAutotests,代码行数:21,代码来源:Page.cs

示例12: Test_RandomSeed

    public void Test_RandomSeed()
    {
      using (MagickImage first = new MagickImage("plasma:red", 10, 10))
      {
        using (MagickImage second = new MagickImage("plasma:red", 10, 10))
        {
          Assert.AreNotEqual(0.0, first.Compare(second, ErrorMetric.RootMeanSquared));
        }
      }

      MagickNET.SetRandomSeed(1337);

      using (MagickImage first = new MagickImage("plasma:red", 10, 10))
      {
        using (MagickImage second = new MagickImage("plasma:red", 10, 10))
        {
          Assert.AreEqual(0.0, first.Compare(second, ErrorMetric.RootMeanSquared));
        }
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:20,代码来源:MagickNETTests.cs

示例13: 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

示例14: Test_SigmoidalContrast

    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);
        }
      }
    }
开发者ID:dlemstra,项目名称:Magick.NET,代码行数:12,代码来源:MagickImageTests.cs

示例15: Test_SelectiveBlur

    public void Test_SelectiveBlur()
    {
      using (MagickImage image = new MagickImage(Files.NoisePNG))
      {
        image.SelectiveBlur(5.0, 2.0, Quantum.Max / 2);

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


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