public void Deepfry() { image.Resize((Percentage)50); image.AddNoise(NoiseType.MultiplicativeGaussian); image.Modulate((Percentage)100, (Percentage)300, (Percentage)100); image.Resize((Percentage)200); }
public static void AddNoise(string path, List <NoiseType> noiseTypes, double attenMin, double attenMax, bool monoChrome) { if (noiseTypes.Count < 1) { return; } MagickImage img = IOUtils.ReadImage(path); if (img == null) { return; } NoiseType chosenNoiseType = GetRandomNoiseType(noiseTypes); PreProcessing(path, "- Noise Type: " + chosenNoiseType.ToString()); Random rand = new Random(); double att = (double)rand.Next((int)attenMin, (int)attenMax + 1); Program.Print("-> Using attenuate factor " + att); if (monoChrome) { MagickImage noiseImg = new MagickImage(MagickColors.White, img.Width, img.Height); noiseImg.AddNoise(chosenNoiseType, att); noiseImg.ColorSpace = ColorSpace.LinearGray; noiseImg.Write(Path.Combine(IOUtils.GetAppDataDir(), "lastnoiseimg.png")); img.Composite(noiseImg, CompositeOperator.Multiply); } else { img.AddNoise(chosenNoiseType, att); } img.Write(path); PostProcessing(img, path, path); }
public static MagickImage PerlinNoise(int width, int height) { using var noise1 = new MagickImage(MagickColors.Black, width / 160, height / 160); using var noise2 = new MagickImage(MagickColors.Black, width / 80, height / 80); using var noise3 = new MagickImage(MagickColors.Black, width / 40, height / 40); using var noise4 = new MagickImage(MagickColors.Black, width / 20, height / 20); using var noise5 = new MagickImage(MagickColors.Black, width / 10, height / 10); using var noise6 = new MagickImage(MagickColors.Black, width / 1, height / 1); noise1.AddNoise(NoiseType.Random); noise2.AddNoise(NoiseType.Random); noise3.AddNoise(NoiseType.Random); noise4.AddNoise(NoiseType.Random); noise5.AddNoise(NoiseType.Random); noise1.VirtualPixelMethod = VirtualPixelMethod.Tile; noise2.VirtualPixelMethod = VirtualPixelMethod.Tile; noise3.VirtualPixelMethod = VirtualPixelMethod.Tile; noise4.VirtualPixelMethod = VirtualPixelMethod.Tile; noise5.VirtualPixelMethod = VirtualPixelMethod.Tile; noise6.VirtualPixelMethod = VirtualPixelMethod.Tile; var geometry = new MagickGeometry(width, height) { FillArea = true }; noise1.Evaluate(Channels.Default, EvaluateOperator.Multiply, 0.5); noise1.Evaluate(Channels.Default, EvaluateOperator.Add, 0.25); noise1.Resize(geometry); noise2.Evaluate(Channels.Default, EvaluateOperator.Multiply, 0.25); noise2.Evaluate(Channels.Default, EvaluateOperator.Add, 0.375); noise2.Resize(geometry); noise3.Evaluate(Channels.Default, EvaluateOperator.Multiply, 0.125); noise3.Evaluate(Channels.Default, EvaluateOperator.Add, 0.4375); noise3.Resize(geometry); noise4.Evaluate(Channels.Default, EvaluateOperator.Multiply, 0.0625); noise4.Evaluate(Channels.Default, EvaluateOperator.Add, 0.46875); noise4.Resize(geometry); noise5.Evaluate(Channels.Default, EvaluateOperator.Multiply, 0.03125); noise5.Evaluate(Channels.Default, EvaluateOperator.Add, 0.484375); noise5.Resize(geometry); noise6.Evaluate(Channels.Default, EvaluateOperator.Multiply, 0.015625); noise6.Evaluate(Channels.Default, EvaluateOperator.Add, 0.49921875); noise6.Resize(geometry); noise1.Composite(noise2, CompositeOperator.Plus); noise1.Composite(noise3, CompositeOperator.Plus); noise1.Composite(noise4, CompositeOperator.Plus); noise1.Composite(noise5, CompositeOperator.Plus); noise1.Composite(noise6, CompositeOperator.Plus); noise1.AutoLevel(); return((MagickImage)noise1.Clone()); }
public override bool OverrideTextureFlakes(string textureName, Color color) { using (var image = new MagickImage(new MagickColor(color) { A = 250 }, 256, 256)) { image.AddNoise(NoiseType.Poisson, Channels.Alpha); return(OverrideTexture(textureName, image.ToByteArray(MagickFormat.Png))); } }
public Task SaveTextureFlakes(string filename, Color color) { var image = new MagickImage(new MagickColor(color) { A = 250 }, 256, 256); image.AddNoise(NoiseType.Poisson, Channels.Alpha); return(SaveAndDispose(filename, image)); }
static MagickImage pencilImage(int width = 256, int height = 256) { //convert -size 256x256 xc: +noise Random -virtual-pixel tile -motion-blur 0x20+135 -charcoal 1 pencil_tile.gif MagickImage result = new MagickImage(new MagickColor("white"), width, height); result.AddNoise(NoiseType.Random); result.MotionBlur(0, 20, 135); result.Charcoal(1, 1); result.Threshold(new Percentage(50)); return(result); }
public override void Apply(MagickImage image) { using var noise = new MagickImage(MagickColors.Black, image.Width, image.Height); noise.AddNoise(NoiseType.Random); noise.VirtualPixelMethod = VirtualPixelMethod.Tile; noise.Blur(0, 5); noise.AutoLevel(); var green = noise.Separate(Channels.Green).First(); image.Composite(green, CompositeOperator.SrcOver); }
public void ShouldCreateDifferentImagesEachRun() { using (IMagickImage imageA = new MagickImage(MagickColors.Black, 10, 10)) { using (IMagickImage imageB = new MagickImage(MagickColors.Black, 10, 10)) { imageA.AddNoise(NoiseType.Random); imageB.AddNoise(NoiseType.Random); Assert.AreNotEqual(0.0, imageA.Compare(imageB, ErrorMetric.RootMeanSquared)); } } }
public void ShouldCreateDifferentImagesEachRun() { TestHelper.ExecuteInsideLock(() => { using (var imageA = new MagickImage(MagickColors.Black, 10, 10)) { using (var imageB = new MagickImage(MagickColors.Black, 10, 10)) { imageA.AddNoise(NoiseType.Random); imageB.AddNoise(NoiseType.Random); Assert.NotEqual(0.0, imageA.Compare(imageB, ErrorMetric.RootMeanSquared)); } } }); }
public void ShouldUseTheRandomSeed() { MagickNET.SetRandomSeed(1337); using (var first = new MagickImage(Files.Builtin.Logo)) { first.AddNoise(NoiseType.Laplacian); ColorAssert.NotEqual(MagickColors.White, first, 46, 62); using (var second = new MagickImage(Files.Builtin.Logo)) { second.AddNoise(NoiseType.Laplacian, 2.0); ColorAssert.NotEqual(MagickColors.White, first, 46, 62); Assert.False(first.Equals(second)); } } MagickNET.ResetRandomSeed(); }