shaderel
Construct cdata
and colormap for shaded
relief
Syntax
[cindx,cimap,climits] = shaderel(X,Y,Z,cmap)
[cindx,cimap,climits] = shaderel(X,Y,Z,cmap,[azim
elev])
[cindx,cimap,climits] = shaderel(X,Y,Z,cmap,[azim
elev],cmapl)
[cindx,cimap,climits] = shaderel(X,Y,Z,cmap,[azim
elev],cmapl,climits)
Description
[cindx,cimap,climits] = shaderel(X,Y,Z,cmap)
constructs the colormap and color indices to allow a surface to be displayed in colored
shaded relief. The colors are proportional to the magnitude of Z
, but
modified by shades of gray based on the surface normals to simulate surface lighting.
This representation allows both large and small-scale differences to be seen.
X
, Y
, and Z
define the
surface. cmap
is the colormap used to create the new shaded colormap
cimap
. cindx
is a matrix of color indices to
cimap
, based on the elevation and surface normal of the
Z
matrix element. climits
contains the color
axis limits.
[cindx,cimap,climits] = shaderel(X,Y,Z,cmap,[azim
elev])
places the light at the specified azimuth and elevation. By default, the direction
of the light is East (90º azimuth) at an elevation of 45º.
[cindx,cimap,climits] = shaderel(X,Y,Z,cmap,[azim
elev],cmapl)
chooses the number of grays to give a cimap
of length
cmapl
. By default, the number of grayscales is chosen to keep the
shaded colormap below 256. If the vector of azimuth and elevation is empty, the default
locations are used.
[cindx,cimap,climits] = shaderel(X,Y,Z,cmap,[azim
elev],cmapl,climits)
uses the color limits to index Z
into
cmap
.
Examples
Display the peaks
surface with a shaded colormap:
[X,Y,Z] = peaks(100); cmap = hot(16); [cindx,cimap,climits] = shaderel(X,Y,Z,cmap); surf(X,Y,Z,cindx) colormap(cimap) shading flat
Tips
This function effectively multiplies two colormaps, one with color based on elevation, the other with a grayscale based on the slope of the surface, to create a new colormap. This produces an effect similar to using a light on a surface, but with all of the visible colors actually in the colormap. Lighting calculations are performed on the unprojected data.
Version History
Introduced before R2006a