Diffusion

Syntax: DENSITY\DIFFUSION { x y } z { p1 p2 }
Qualifiers: \PARTIAL, \XPROFILE, \YPROFILE, \BORDER, \AXES, \RESET
Defaults: if z is a matrix: x=[1;2;3;...], y=[1;2;3;...], p1=0, p2=1, \-PARTIAL, \-XPROFILE, \-YPROFILE, \BORDER, \AXES, \RESET

Diffusion is a form of digital halftoning. A threshold is fixed at ½. Data values are interpolated at each pixel location, and then normalized to be between 0 (white) and 1 (black). The resulting binary output value is compared with the original grey level value. The difference is called the error for that location. The signal consisting of past error values is passed through an error filter to produce a correction factor to be added to future input values. Thus, errors are diffused over a weighted neighborhood.

Input variables

If z is a vector, the parameters x and y are expected and must be vectors. x and y are assumed to represent a scattered set of points, where z[i] is the altitude corresponding to the location (x[i],y[i]). A matrix is interpolated on these scattered points by means of a Thiessen triangulation of the plane. The three vectors must be the same length.

If z is a matrix, the parameters x and y default to [1;2;3;...], but if entered they must be vectors. Each matrix element, z[i,j], is associated with the coordinates (x[j],y[i]). The length of x must be equal to the number of columns of z and the length of y must be equal to the number of rows. The vectors x and y are used for scaling the axes.

Changing the range of values

The optional parameters p1 and p2 can be used to broaden or shrink the range of data values. If zmax is the maximum value of the data and zmin is the minimum value of the data, the full colour range will be from a minimum of min = p1*(zmax-zmin)+zmin to a maximum of max = p2*(zmax-zmin)+zmin. If z is a data value and if z < p1*(zmax-zmin)+zmin, that data value is treated as zmin. If z > p1*(zmax-zmin)+zmin, that data value is treated as zmax. The default values are: p1=0 and p2=1.

Example

These examples use the following vectors.

 X=[  1;  0;  1;  0;   .2; .3;   .5;  .8]
 Y=[  5;  5;  0;  0;    1;1.5;  2.5;   4]
 Z=[ 10; 10; 10; 10; -100; 10; -100; 500]
DENSITY\DIFFUSION X Y Z
DENSITY\DIFF\XPRO\YPRO X Y Z

  DITHERING
  BOXES