MagickImage.SparseColors() how does it work?
Posted: 2014-07-03T06:53:13-07:00
Hello there, everyone!
I couldn't find anything in Magick.NET documentation about SparseColors() method and it get's me confused.
I'm trying to recreate the effect of convert -sparse-color shepards "..." command line parameter. As far as I understand it gets a list of {X,Y COLOR} objects.
MagickImage.SparseColors() asks for Channel, SparseColorMethod and an array of double coordinates in his parameters.
What I did is the following:
And this code is not working (because colors are not specified, I guess). Question is how do I specify them?
I couldn't find anything in Magick.NET documentation about SparseColors() method and it get's me confused.
I'm trying to recreate the effect of convert -sparse-color shepards "..." command line parameter. As far as I understand it gets a list of {X,Y COLOR} objects.
MagickImage.SparseColors() asks for Channel, SparseColorMethod and an array of double coordinates in his parameters.
What I did is the following:
Code: Select all
var coords = GetCoords(points);
image.SparseColor(Channels.All, SparseColorMethod.Shepards, coords);
Code: Select all
private double[] GetCoords(Point[] points)
{
var list = new List<double>();
for (var i = 0; i < points.Length; i++)
{
var p = points[i];
var c = colors[i];
list.Add(p.X);
list.Add(p.Y);
}
return list.ToArray();
}