private void ExecuteThreshold(XmlElement element, MagickImage image) { Percentage percentage_ = Variables.GetValue<Percentage>(element, "percentage"); image.Threshold(percentage_); }
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); }
public void Test_BitDepth() { using (MagickImage image = new MagickImage(Files.RoseSparkleGIF)) { Assert.AreEqual(8, image.BitDepth()); image.Threshold((Percentage)50); Assert.AreEqual(1, image.BitDepth()); } }
public void Test_Threshold() { using (MagickImage image = new MagickImage(Files.ImageMagickJPG)) { using (MemoryStream memStream = new MemoryStream()) { image.Threshold(new Percentage(80)); image.CompressionMethod = CompressionMethod.Group4; image.Format = MagickFormat.Pdf; image.Write(memStream); } } }
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); }
public void Test_CannyEdge_HoughLine() { using (MagickImage image = new MagickImage(Files.ConnectedComponentsPNG)) { image.Threshold(new Percentage(50)); ColorAssert.AreEqual(MagickColors.Black, image, 150, 365); image.Negate(); ColorAssert.AreEqual(MagickColors.White, image, 150, 365); image.CannyEdge(); ColorAssert.AreEqual(MagickColors.Black, image, 150, 365); image.Crop(260, 180, 215, 200); image.Settings.FillColor = MagickColors.Red; image.Settings.StrokeColor = MagickColors.Red; image.HoughLine(); ColorAssert.AreEqual(MagickColors.Red, image, 105, 25); } }