Using ImageMagick to plot points

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Sharke

Using ImageMagick to plot points

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using ImageMagick to plot points

Post 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.
Post Reply