Use this light source to adjust the colors of the *rgb* input array to give the impression of a shaded relief map with the given *elevation*. Parameters ---------- rgb : array-like An (M, N, 3) RGB array, assumed to be in the range of 0 to 1.
(self, rgb, elevation, fraction=1., blend_mode='hsv',
vert_exag=1, dx=1, dy=1, **kwargs)
| 4034 | return rgb0 |
| 4035 | |
| 4036 | def shade_rgb(self, rgb, elevation, fraction=1., blend_mode='hsv', |
| 4037 | vert_exag=1, dx=1, dy=1, **kwargs): |
| 4038 | """ |
| 4039 | Use this light source to adjust the colors of the *rgb* input array to |
| 4040 | give the impression of a shaded relief map with the given *elevation*. |
| 4041 | |
| 4042 | Parameters |
| 4043 | ---------- |
| 4044 | rgb : array-like |
| 4045 | An (M, N, 3) RGB array, assumed to be in the range of 0 to 1. |
| 4046 | elevation : array-like |
| 4047 | An (M, N) array of the height values used to generate a shaded map. |
| 4048 | fraction : number |
| 4049 | Increases or decreases the contrast of the hillshade. Values |
| 4050 | greater than one will cause intermediate values to move closer to |
| 4051 | full illumination or shadow (and clipping any values that move |
| 4052 | beyond 0 or 1). Note that this is not visually or mathematically |
| 4053 | the same as vertical exaggeration. |
| 4054 | blend_mode : {'hsv', 'overlay', 'soft'} or callable, optional |
| 4055 | The type of blending used to combine the colormapped data values |
| 4056 | with the illumination intensity. For backwards compatibility, this |
| 4057 | defaults to "hsv". Note that for most topographic surfaces, |
| 4058 | "overlay" or "soft" appear more visually realistic. If a |
| 4059 | user-defined function is supplied, it is expected to combine an |
| 4060 | (M, N, 3) RGB array of floats (ranging 0 to 1) with an (M, N, 1) |
| 4061 | hillshade array (also 0 to 1). (Call signature |
| 4062 | ``func(rgb, illum, **kwargs)``) |
| 4063 | Additional kwargs supplied to this function will be passed on to |
| 4064 | the *blend_mode* function. |
| 4065 | vert_exag : number, optional |
| 4066 | The amount to exaggerate the elevation values by when calculating |
| 4067 | illumination. This can be used either to correct for differences in |
| 4068 | units between the x-y coordinate system and the elevation |
| 4069 | coordinate system (e.g. decimal degrees vs. meters) or to |
| 4070 | exaggerate or de-emphasize topography. |
| 4071 | dx : number, optional |
| 4072 | The x-spacing (columns) of the input *elevation* grid. |
| 4073 | dy : number, optional |
| 4074 | The y-spacing (rows) of the input *elevation* grid. |
| 4075 | **kwargs |
| 4076 | Additional kwargs are passed on to the *blend_mode* function. |
| 4077 | |
| 4078 | Returns |
| 4079 | ------- |
| 4080 | `~numpy.ndarray` |
| 4081 | An (m, n, 3) array of floats ranging between 0-1. |
| 4082 | """ |
| 4083 | # Calculate the "hillshade" intensity. |
| 4084 | intensity = self.hillshade(elevation, vert_exag, dx, dy, fraction) |
| 4085 | intensity = intensity[..., np.newaxis] |
| 4086 | |
| 4087 | # Blend the hillshade and rgb data using the specified mode |
| 4088 | lookup = { |
| 4089 | 'hsv': self.blend_hsv, |
| 4090 | 'soft': self.blend_soft_light, |
| 4091 | 'overlay': self.blend_overlay, |
| 4092 | } |
| 4093 | if blend_mode in lookup: |
no test coverage detected