Page 1 of 1

Using ImageMagick to plot points

Posted: 2010-04-03T21:36:21-07:00
by Sharke
I'm looking for a quick and easy way to plot pixels in various colors on a 2D plane, according to mathematical formulas, within a C program. It's something that used to keep me occupied for hours as a kid on my old 8-bit machines and I'm inclined to experiment with it again. I've been looking for an easy interface to do this for ages but nothing I've seen seems to suit my purposes, in terms of being relatively quick and easy to get into.

Is ImageMagick for me?

Re: Using ImageMagick to plot points

Posted: 2010-04-03T22:25:24-07:00
by fmw42
It can be done with limitations. For example to graph y=f(x)=x^2 one builds a gradient to represent the x coordinate axis, then graphs it with a script that Anthony built. So for example:

convert -size 1x100 gradient: -rotate 90 -fx 'u*u' miff:- | im_profile - square_graph.gif

Image

The -fx function has many mathematical functions to apply to an image (in this case the gradient).

see
http://www.imagemagick.org/script/fx.php
http://www.imagemagick.org/Usage/transf ... dient_math
http://www.imagemagick.org/Usage/transf ... luate_math

and you can get the im_profile script at
http://www.imagemagick.org/Usage/scripts/

However, it only allows one color and one function.

For more flexibility, get the unix tool GNUPLOT.