C# Imagemagick subtraction syntax
Posted: 2017-08-06T04:18:58-07:00
Dear all,
Could anyone point me how to do a subtraction between two images? I can't seem to find good documentation in C# (or similar) for this. Is it using the method FX or composite?
This is my code:
- Simple gaussian blur and difference between the original image and the gaussian blurred image.
Thank you,
Manuel.
Could anyone point me how to do a subtraction between two images? I can't seem to find good documentation in C# (or similar) for this. Is it using the method FX or composite?
This is my code:
- Simple gaussian blur and difference between the original image and the gaussian blurred image.
Code: Select all
class Program
{
static void Main(string[] args)
{
// Definir variables
byte sigma;
short radius;
int originalX;
int originalY;
//Reading the file
using (MagickImageCollection images = new MagickImageCollection())
{
//First image
MagickImage raw = new MagickImage(@"D:\test01.jpg");
images.Add(raw);
// Record original size
originalX = raw.Width;
originalY = raw.Height;
// Gaussian Blur
Console.WriteLine("Please enter sigma value for Gaussian blur:");
radius = short.Parse(Console.ReadLine());
Console.WriteLine("Please enter radius value for Gaussian blur:");
sigma = byte.Parse(Console.ReadLine());
// Speed up
raw.Scale(new Percentage(10));
raw.GaussianBlur(radius,sigma);
raw.Resize(originalX,originalY);
// Write
raw.Write(@"D:\test01_gaussianblur.jpg");
// Second image
MagickImage blur = new MagickImage(@"D:\test01_gaussianblur.jpg");
images.Add(blur);
using (MagickImage flattened = images.Combine(); My doubt is here, how can i perform a subtraction?
{
flattened.Write(@"D:\test01_flattened.jpg");
}
}
Console.ReadLine();
}
}
}
Manuel.