Fred's ImageMagick Scripts



    Licensing:

    Copyright © Fred Weinhaus

    My scripts are available free of charge for non-commercial use, ONLY.

    For use of my scripts in commercial (for-profit) environments or non-free applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net.

    If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or for-profit environment.

    Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php

PLOT3D


Generates a 3D plot of a single channel or grayscale image.

Download Script

last modified: May 02, 2015



USAGE: plot3D [-w width] [-h height] [-c channel] [-a autolevel] [-ti title] [-f format] [-s skip] [-pn pan] [-tl tilt] [-xy xyplane] [-b box] [-tc tics] [-lb label] [-g grid] [-k key] [-xs xscale] [-ys yscale] [-xo xoffset] [-yo yoffset] [-z zlog] [-lc linecolor] [-p palettefile] infile [outfile]

USAGE: plot3D [-help]

-w ... width .......... width of output image; default=500
-h ... height ........ height of output image: default=500
-c ... channnel ...... channel of input image to use; options are: red, green,
...................... blue, alpha, cyan, magenta, yellow, black, gray, color;
...................... (gray is image converted to grayscale),
...................... (color is full color image; format=1,5 only);
...................... default=gray
-a ... autolevel ..... apply -auto-level to the input image; on or off;
...................... default=off
-ti .. title ......... title to use for the graph; default=no title
-f ... format ........ format (type) of graph; choices are:
...................... 1 (pseudocolor),
...................... 2 (pseudocolor with image at bottom),
...................... 3 (pseudocolor with contours at top),
...................... 4 (pseudocolor with lines overlaid)
...................... 5 (lines only); default=1
-s ... skip .......... pixel skip amount for format=4 and 5; integer>0;
...................... default=3
-pn .. pan ........... pan angle for plot; clockwise rotation; 0<integer<360;
...................... default=330
-tl .. tilt .......... tilt angle for plot; 0 is face on to the image, i.e.,
...................... looking down the z axis. 90 is the z axis in the plane
...................... of the output image; 0<integer<90; default=60
-xy .. xyplane ....... location of xy axes (and grid with tics and lines);
...................... top or bottom; default=top
-b ... box ........... box around graph; full, axes (only), none;
...................... default=full
-tc .. tics .......... show tics; on or off; default=on
-lb .. label ......... show x,y,z axes labels; on or off; default=on
-g ... grid .......... show grid lines; xy, back, off; xy is only on the
...................... xy plane, back is also the back faces; default=xy
-k ... key ........... show palette color key; on or off; default=on
-p ... palettefile ... colorizing palette; choices are RGB1, RGB2, gray or
...................... or user supplied text file listing the r,g,b colors;
...................... default=RGB1
-lc .. linecolor ..... overlay line color for format=4; colorname or hex;
...................... default=white
-xs .. xscale ........ scaling factor for the graph in the horizontal output
...................... dimension; float>0; default=1
-ys .. yscale ........ scaling factor for the graph in the vertical output
...................... dimension; float>0; default=1
-xo .. xoffset ....... offset for the graph in the horizontal output
...................... dimension; positive (up) or negative (down) float;
...................... default=0
-yo .. yoffset ....... offset for the graph in the vertical output
...................... dimension; positive (up) or negative (down) float;
...................... default=0
-z ... zlog .......... apply log scaling to z (intensity) data; on or off;
...................... default=off; only valid for format=1,4,5
outfile ...............if not specified, outfile will be named from the
...................... infile name with _graph.gif appended

PURPOSE: To generate a 3D plot of a single channel or grayscale image.

DESCRIPTION: PLOT3D generates a 3D plot of a single channel or grayscale image. The plot will be in pseudocolor or line format. A color image may be used to see each channel plotted on the same graph.

ARGUMENTS:

-w width ... WIDTH of output image. The default=500.

-h height ... HEIGHT of output image: The default=500.

-c channnel ... CHANNEL of input image to use. The options are: red, green, blue, alpha, cyan, magenta, yellow, black, gray, color. (gray is image converted to grayscale). (color is full color image; format=1,5 only). The default=gray.

-a autolevel ... AUTOLEVEL is used to apply -auto-level to the input image. Choices are on or off. The default=off.

-ti title ... TITLE to use for the graph. The default is no title.

-f format ... FORMAT (type) of graph to create. The choices are: 1 (pseudocolor), 2 (pseudocolor with image at bottom), 3 (pseudocolor with contours at top), 4 (pseudocolor with lines overlaid), 5 (lines only). The default=1.

-s skip ... SKIP is the pixel skip amount for format=4 and 5. Values are integer>0. The default=3.

-pn pan ... PAN angle for the plot. Clockwise rotation. Values are 0

-tl tilt ... TILT angle for plot. 0 is face on to the image, i.e., looking down the z axis. 90 is the z axis in the plane of the output image. Values are 0

-xy xyplane ... XYPLANE is the location of xy axes (and grid with tics and lines). Choices are: top or bottom. The default=top.

-b box ... BOX around graph. Choices are: full, axes (only), none. The default=full.

-tc tics ... show TICS. Choices are: on or off. The default=on.

-lb label ... show x,y,z axes LABELs. Choices are on or off. The default=on.

-g grid ... show GRID lines. Choices are xy, back, off. xy is only on the on the xy plane, back is also the back faces. The default=xy.

-k key ... show palette color KEY. Choices are: on or off. The default=on.

-p palettefile ... PALETTEFILE is the colorizing palette. Choices are RGB1, RGB2, gray user supplied text file listing the r,g,b colors. The default=RGB1. RGB1 colors (black, dark-violet, blue, cyan, green, yellow, orange, red). RGB2 colors (red, yellow, green, cyan, blue, magenta). The text file should be either 3 or 4 space delimited values in the range 0-255 (or 0 to 1) with one set per row. The first column can be left off if equal spacing of the colors is desired. It can also be simply a range from 0 incremented by 1 for equal spacing of the colors. Otherwise, the first column is the intensity level where each color should show in the palette.

-lc linecolor ... LINECOLOR is the overlay line color for format=4. Values may be gnuplot colornames or hex values. The default=white.

-xs xscale ... XSCALE is the scaling factor for the graph in the horizontal output dimension. Value are floats>0. The default=1.

-ys yscale ... YSCALE is the scaling factor for the graph in the vertical output dimension. Values are floats>0. The default=1.

-xo xoffset ... XOFFSET is the offset for the graph in the horizontal output dimension. Value may be positive (up), zero, or negative (down) floats. The default=0.

-yo yoffset ... YOFFSET is the offset for the graph in the vertical output dimension. Values may be positive (up), zero, or negative (down) floats. The default=0.

-z zlog ... ZLOG is used to apply log scaling to z (intensity) data. Choices are: on or off. The default=off. This argument is only valid for format=1,4,5.

REQUIREMENTS: Needs GNUPLOT (4.6). I cannot guarantee it will work on older versions, but it may. Also libgd may be needed by GNUPLOT for proper rendering of fonts in PNG output.

CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk.


EXAMPLES


Example 1 -- Variations of Format=1 (Grayscale)

Original
(Grayscale Normalized Cross Correlation Surface from
http://www.fmwconcepts.com/imagemagick/normcrosscorr/index.php)

Arguments:
-ti "3D Plot" -pn 30

Arguments:
-ti "3D Plot" -pn 330
(-pn 330 is default)

Arguments:
-ti "3D Plot" -xy bottom

Arguments:
-ti "3D Plot" -xy bottom -g back

Arguments:
-ti "3D Plot" -xy bottom -g off

Arguments:
-ti "3D Plot" -xy bottom -g off -b axes defaults

Arguments:
-ti "3D Plot" -xy bottom -g xy -b none -tc off -lb off -k off

Arguments:
-ti "3D Plot" -p RGB2

Arguments:
-ti "3D Plot" -p gray

Arguments:
-ti "3D Plot" -p test_palette.txt

Palette Files (all produces the same results)

     0      0    0
    0  255    0
255      0    0

0       0       0    0
1       0   255    0
2   225       0    0

    0       0       0    0
128       0   255    0
255   225       0    0

Arguments:
-ti "3D Plot" -pn 0 -tl 0



Example 2 -- Format=2 (Grayscale)

Original
(Grayscale Normalized Cross Correlation Surface from
http://www.fmwconcepts.com/imagemagick/normcrosscorr/index.php)

Arguments:
-f 2 -ti "3D Plot" -h 750 -tl 70



Example 3 -- Format=3 (Grayscale)

Original
(Grayscale Normalized Cross Correlation Surface from
http://www.fmwconcepts.com/imagemagick/normcrosscorr/index.php)

Arguments:
-f 3 -ti "3D Plot"



Example 4 -- Format=4 (Grayscale)

Original
(Grayscale Normalized Cross Correlation Surface from
http://www.fmwconcepts.com/imagemagick/normcrosscorr/index.php)

See List of Acceptable Colornames at
Gnuplot Color Names

Arguments:
-f 4 -ti "3D Plot" -s 3



Example 5 -- Format=5 (Grayscale)

Original
(Grayscale Normalized Cross Correlation Surface from
http://www.fmwconcepts.com/imagemagick/normcrosscorr/index.php)

Arguments:
-f 5 -ti "3D Plot" -s 3



Example 6 -- Format=1 (Color)

Original
(Peudocolor Normalized Cross Correlation Surface from
http://www.fmwconcepts.com/imagemagick/normcrosscorr/index.php)

Arguments:
-c color -f 1 -ti "3D Plot" -a on -h 750 -ys 1.15 -yo -0.02



Example 7 -- Format=5 (Color)

Original
(Peudocolor Normalized Cross Correlation Surface from
http://www.fmwconcepts.com/imagemagick/normcrosscorr/index.php)

Arguments:
-c color -f 1 -ti "3D Plot" -a on -h 750 -ys 1.15 -yo -0.02 -s 3



What the script does is as follows:

  • It feeds an input image to GNUPLOT to generate the output image

See the script for further details