Page 1 of 1

How to work with SparseColor in .NET?

Posted: 2009-12-21T22:13:21-07:00
by venkat
Hi
can anybody help me how to access SparseColor with .NET wrapper?
i am unable to work with SparseColor.
i am able to work in command prompt.
( convert -size 100x100 xc: -sparse-color Bilinear "30,10 red 10,80 blue 70,60 lime 80,20 yellow" "c:\sample\img1_1.jpg")[ It is working fine.]
or
( convert -size 100x100 xc: -sparse-color Bilinear "30,10 ,250,0,0 10,80 ,0,0,250 ,70,60 ,0,250,0 ,80,20 ,110,50,60" "c:\sample\img1_2.jpg")
[Note: if i give color in RGB format like above it is giving result different but it is not giving any exception]

But i am unable to work with SparseColor in .Net.
How i can pass params to SparseColor in .NET?

Thanks

Re: How to work with SparseColor in .NET?

Posted: 2009-12-21T22:17:42-07:00
by fmw42
rgb colors probably need to be specified as rgb(xxx,yyy,zzy), hex values or color names, see http://www.imagemagick.org/script/color.php
and also on http://www.imagemagick.org/Usage/canvas/#sparse_channel as per the gray using percents.

Note it is possible that -sparse color has not been folded, yet, into your API as it is relatively new to command line.

Re: How to work with SparseColor in .NET?

Posted: 2009-12-22T00:19:22-07:00
by venkat
fmw42 wrote:rgb colors probably need to be specified as rgb(xxx,yyy,zzy), hex values or color names, see http://www.imagemagick.org/script/color.php
and also on http://www.imagemagick.org/Usage/canvas/#sparse_channel as per the gray using percents.

Note it is possible that -sparse color has not been folded, yet, into your API as it is relatively new to command line.

yes you are correct. Thanks
how i can work in .NET?
when and where i can get .NET wrapper?

Re: How to work with SparseColor in .NET?

Posted: 2010-03-30T18:58:15-07:00
by anthony
fmw42 wrote:rgb colors probably need to be specified as rgb(xxx,yyy,zzy), hex values or color names, see http://www.imagemagick.org/script/color.php
and also on http://www.imagemagick.org/Usage/canvas/#sparse_channel as per the gray using percents.

Note it is possible that -sparse color has not been folded, yet, into your API as it is relatively new to command line.
Fred is correct. You are better of specifing a color. If you want to specify values directly they are normalized color values. That is 1,1,1 is white .5,.5,.5 is pure gray It is done this way so arguments are correct regardless of the IM compile time Quality setting.

Internally colors are converted to normalized values during the command line API handling before being passed to the actual sparse color library function as a list of floats. Other API's can use the same number string to array routine too so it may or may not be in that form.

NOTE all numbers are floats, so sub-pixel locations can be specified, or even locations outside the image proper,
which is very useful at times.

Also BOTH spare color and distorts from Command line API allow you to use % escapes so you can specify pixel locations in terms of %h or %w and can use %[fx:....] maths for calculating the values. the results of these are inserted back into the argument 'string' before being passed for locations and colors.

I have even used this to generate RANDOMIZED sparse color images, such as in
Fractured Mirror Distorted Image Example
http://www.imagemagick.org/Usage/mappin ... ace_mirror