Although objects drawn with interpolated shading look good on the
screen, objects which consist of a large number of interpolated patches generally take an unacceptably long time to print. This is not because the PostScript files are excessively large, but rather because most printers are overwhelmed by the computations required to determine the exact shading/coloring of each point. Unlike flat and faceted shading, in which the color of each patch is constant and specified directly in the PostScript code, the PostScript files generated for interpolated shading contain the color information of the patches' vertices. The interpolation calculations are done by the printer. This may result in extremely long print times for graphics using interpolated shading. In many cases, printers "time-out" (i.e., abort the print job) due to the long wait.
There are several possible workarounds for obtaining interpolated shaded figures:
- Approximate Interpolated Shading. Interpolated shading can be approximated by interpolating the actual data used to construct the object, and then plotting the interpolated data using flat shading. The result is an increased number of constant-colored patches. As the number of patches increases, and the size of each patch decreases, the approximation to interpolated shading improves. An M-file that performs data interpolation and re-plots the figure is included at the end of this note.
- Please note that this method may result in large PostScript files. In some UNIX environments, the default lpr command will not print files larger than 1 Mbyte. Files larger than 1 Mbyte can be printed via the lpr -s command (see the man pages for lpr).
- Edit the PostScript File. The default resolution value for interpolated shading is 16 (i.e., 16 different shades per patch). This value can be changed to either 8 or 4 by editing the PostScript file. The result is a decrease in the quality of the image and an increase in printing speed. To change the resolution value, edit the PostScript file and search for the string NI. The search should find the following line of code:
/NI 16 def % NI can be 4 (draft),
8 (medium), or 16 (high-res)
- Change the number to the desired resolution, save the file, and print. Below is a sample M-file to perform data interpolation.
*********************** APP_INT.M **********************
function hfi = app_int(x,y,z,s,dc)
% This function approximates interpolated shading by
% interpolating data and using flat shading. The inputs
% are the data that was used to generate the original
% object, a scale factor, and a string that contains the
% drawing command. The function returns a handle to the new
% object.
%
% Syntax 1:For just Z-Data (e.g., surf(z) =>
% app_int(z,s,dc)
% z = zdata, s = scaling factor and dc = drawing command used
% to create the plot.
%
% Syntax 2: For x,y,z Data ( e.g., surf(x,y,z) ) => app_int
%(x,y,z,s,dc)
%
% Example 1: [x,y,z] = peaks;surf(z);shading interp
% app_int(z,3,'surf') interpolate by a factor of 3
%
% Example 2: [x,y,z ] = peaks; surf(x,y,z); shading interp
% app_int(x,y,z,3,'surf')interpolate by a factor of 3
if ( nargin == 3 )
dc = z;
z = x;
s = y;
[m n] = size(z);
x = 1:n; y = (1:m)';
mscal = m*s;
nscal = n*s;
xi = linspace(1,n,nscal);
yi = linspace(1,m,mscal)';
zi = interp2(x,y,z,xi,yi);
figure;
cmd = ['hfi=' dc '(xi,yi,zi);'];
eval(cmd);
shading flat;
elseif ( nargin == 5 )
[m n] = size(z);
mscal = m*s;
nscal = n*s;
mint = min(min(x));
maxt = max(max(x));
xi = linspace(mint,maxt,mscal);
mint = min(min(y));
maxt = max(max(y));
yi = linspace(mint,maxt,nscal)';
zi = interp2(x,y,z,xi,yi);
figure;
cmd = ['hfi=' dc '(xi,yi,zi);'];
eval(cmd);
shading flat;
end
********************** END OF FILE *********************
- Use a Screen Bitmap. Also note that on workstations, the capture command can be used to produce a bitmap screen image of the current figure window. Since this is only a bitmap copy, the resolution will be of much lesser quality than resolution obtained by applying the print command to the original figure.
- On PC's, <ALT>+<Print Scrn> can be used to send a bitmap screen image to the clipboard. This image will include the window border. Import the image into a graphics package such as MS Paintbrush (included with MS Windows), in order to remove the window borders and print.
(c) Copyright 1994 by The MathWorks, Inc.