@node Dither, Do, Device, Commands @iftex @syntax Dither. @end iftex @example Syntax: DITHER x y min max fac @end example @pindex Dither @findex 2-dimensional graphics, dither Generates a dithered represention of an image read by the IMAGE command (@pxref{Image}). The vectors x and y are set to points whose density is proportional to the image's intensity (only values between min and max are considered). Any pixels whose value is @code{NaN} are ignored, as are any whose value equals the SM variable @code{$missing_data}; by default this is some very large number. The dithering algorithm used is Floyd-Steinberg, and each pixel of the image is represented by (up to) fac*fac points, where (of course) all fac*fac points are only used for intensities greater than equal to max. Even the case fac == 1 can produce nice output for suitably sampled images. The resulting vectors are usually plotted as @code{ptype 1 1}. An example of dithering an image would be: @example IMAGE image_file DITHER x y 0 3000 4 PTYPE 1 1 POINTS x y @end example @noindent Of course, you can be more sophisticated; for example: @example define min 3000 define max 60000 define gamma 2 set ii = image[*,*] set ii=(ii < $min ? 0 : ii > $max ? 1 : (ii-$min)/($max - $min) set image[*,*] = (1 + $gamma)*ii/(1 + $gamma*ii) dither x y 0 1 4 define v local foreach v (x y) @{ set $v=$v + 0.5*random(dimen($v)) @} POINTS x y @end example @noindent or @example DITHER x y 0 3000 1 expand 0.3 + IMAGE(x,y)/3000 PTYPE 4 3 POINTS x y @end example See also IMAGE for reading images, CONTOUR for contouring them, IMAGE CURSOR for using cursors to get values from images, MINMAX for finding the minimum and maximum of images, and Arithmetic for extracting cross-sections of images.