This project has moved and is read-only. For the latest updates, please go here.

Get distance between colors

Jun 17, 2014 at 11:00 AM
Is there any way to compare two colors and get the distance between them?
similar to the command of imagemagick:

compare -metric RMSE xc:Navy xc:blue null:
The return value is: 18844.1 (0.287543)

I tried "CompareTo" but only get 1 or 0
Jun 17, 2014 at 12:10 PM
CompareTo only compares the Width*Height of both images. This is what you are looking for:
using (MagickImage navy = new MagickImage("xc:navy"))
  using (MagickImage blue = new MagickImage("xc:blue"))
    double distance = navy.Compare(blue, Metric.RootMeanSquaredError);
    Console.WriteLine((Quantum.Max * distance).ToString());
Jun 17, 2014 at 12:36 PM
Thanks, that's just what I needed !!