matplotlib.colors.
LightSource
(azdeg=315, altdeg=45, hsv_min_val=0, hsv_max_val=1, hsv_min_sat=1, hsv_max_sat=0)¶Create a light source coming from the specified azimuth and elevation. Angles are in degrees, with the azimuth measured clockwise from north and elevation up from the zero plane of the surface.
The shade()
is used to produce “shaded” rgb values for a data array.
shade_rgb()
can be used to combine an rgb image with
The shade_rgb()
The hillshade()
produces an illumination map of a surface.
Specify the azimuth (measured clockwise from south) and altitude (measured up from the plane of the surface) of the light source in degrees.
Parameters:  azdeg : number, optional
altdeg : number, optional


Notes
For backwards compatibility, the parameters hsv_min_val,
hsv_max_val, hsv_min_sat, and hsv_max_sat may be supplied at
initialization as well. However, these parameters will only be used if
“blend_mode=’hsv’” is passed into shade()
or shade_rgb()
.
See the documentation for blend_hsv()
for more details.
blend_hsv
(rgb, intensity, hsv_max_sat=None, hsv_max_val=None, hsv_min_val=None, hsv_min_sat=None)¶Take the input data array, convert to HSV values in the given colormap, then adjust those color values to give the impression of a shaded relief map with a specified light source. RGBA values are returned, which can then be used to plot the shaded image with imshow.
The color of the resulting image will be darkened by moving the (s,v) values (in hsv colorspace) toward (hsv_min_sat, hsv_min_val) in the shaded regions, or lightened by sliding (s,v) toward (hsv_max_sat hsv_max_val) in regions that are illuminated. The default extremes are chose so that completely shaded points are nearly black (s = 1, v = 0) and completely illuminated points are nearly white (s = 0, v = 1).
Parameters:  rgb : ndarray
intensity : ndarray
hsv_max_sat : number, optional
hsv_min_sat : number, optional
hsv_max_val : number, optional
hsv_min_val: number, optional


Returns:  rgb : ndarray

blend_overlay
(rgb, intensity)¶Combines an rgb image with an intensity map using “overlay” blending.
Parameters:  rgb : ndarray
intensity : ndarray


Returns:  rgb : ndarray

blend_soft_light
(rgb, intensity)¶Combines an rgb image with an intensity map using “soft light” blending. Uses the “pegtop” formula.
Parameters:  rgb : ndarray
intensity : ndarray


Returns:  rgb : ndarray

direction
¶The unit vector direction towards the light source
hillshade
(elevation, vert_exag=1, dx=1, dy=1, fraction=1.0)¶Calculates the illumination intensity for a surface using the defined azimuth and elevation for the light source.
This computes the normal vectors for the surface, and then passes them
on to shade_normals
Parameters:  elevation : arraylike
vert_exag : number, optional
dx : number, optional
dy : number, optional
fraction : number, optional
Returns —— intensity : ndarray


shade
(data, cmap, norm=None, blend_mode='overlay', vmin=None, vmax=None, vert_exag=1, dx=1, dy=1, fraction=1, **kwargs)¶Combine colormapped data values with an illumination intensity map (a.k.a. “hillshade”) of the values.
Parameters:  data : arraylike
cmap :
norm :
blend_mode : {‘hsv’, ‘overlay’, ‘soft’} or callable, optional
vmin : scalar or None, optional
vmax : scalar or None, optional
vert_exag : number, optional
dx : number, optional
dy : number, optional
fraction : number, optional
Additional kwargs are passed on to the *blend_mode* function. 

Returns:  rgba : ndarray

shade_normals
(normals, fraction=1.0)¶Calculates the illumination intensity for the normal vectors of a surface using the defined azimuth and elevation for the light source.
Imagine an artificial sun placed at infinity in some azimuth and elevation position illuminating our surface. The parts of the surface that slope toward the sun should brighten while those sides facing away should become darker.
Parameters:  fraction : number, optional


Returns:  intensity : ndarray

shade_rgb
(rgb, elevation, fraction=1.0, blend_mode='hsv', vert_exag=1, dx=1, dy=1, **kwargs)¶Take the input RGB array (ny*nx*3) adjust their color values to given the impression of a shaded relief map with a specified light source using the elevation (ny*nx). A new RGB array ((ny*nx*3)) is returned.
Parameters:  rgb : arraylike
elevation : arraylike
fraction : number
blend_mode : {‘hsv’, ‘overlay’, ‘soft’} or callable, optional
vert_exag : number, optional
dx : number, optional
dy : number, optional
Additional kwargs are passed on to the *blend_mode* function. 

Returns:  shaded_rgb : ndarray
