Mapping Toolbox | ![]() ![]() |
Construct cdata and colormap for colored shaded relief
Syntax
[cindx,cimap,clim] = shaderel(X,Y,Z,cmap) [cindx,cimap,clim] = shaderel(X,Y,Z,cmap,[azim elev]) [cindx,cimap,clim] = shaderel(X,Y,Z,cmap,[azim elev],cmapl) [cindx,cimap,clim] = shaderel(X,Y,Z,cmap,[azim elev],cmapl,clim)
Description
[cindx,cimap,clim] = 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. clim
contains the color axis limits.
[cindx,cimap,clim] = 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,clim] = 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,clim] = shaderel(X,Y,Z,cmap,[azim elev],cmapl,clim) uses the color limits to index Z
into cmap
.
Remarks
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 color map. 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.
Examples
Display the peaks
surface with a shaded colormap:
[X,Y,Z] = peaks(100); cmap = hot(16); [cindx,cimap,clim] = shaderel(X,Y,Z,cmap); surf(X,Y,Z,cindx); colormap(cimap); caxis(clim) shading flat
See Also
caxis |
Pseudocolor axis scaling |
colormap |
Color lookup table |
light |
Create a Light object see online MATLAB Function Reference) |
meshlsrm |
Project 3-D lighted shaded relief of a regular matrix map |
surf |
3-D shaded surface plot (see online MATLAB Function Reference) |
surflsrm |
Project 3-D lighted shaded relief of a general matrix map |
![]() | setpostn | showaxes | ![]() |