xrspatial.multispectral.true_color#
- xrspatial.multispectral.true_color(r, g, b, nodata=1, c=10.0, th=0.125, name='true_color')[source]#
Create true color composite from a combination of red, green and blue bands satellite images.
A sigmoid function will be used to improve the contrast of output image. The function is defined as
normalized_pixel = 1 / (1 + np.exp(c * (th - normalized_pixel)))
wherec
andth
are contrast and brightness controlling parameters.- Parameters
r (xarray.DataArray) – 2D array of red band data.
g (xarray.DataArray) – 2D array of green band data.
b (xarray.DataArray) – 2D array of blue band data.
nodata (int, float numeric value) – Nodata value of input DataArrays.
c (float, default=10) – Contrast and brighness controlling parameter for output image.
th (float, default=0.125) – Contrast and brighness controlling parameter for output image.
name (str, default='true_color') – Name of output DataArray.
- Returns
true_color_agg – 3D array true color image with dims of [y, x, band]. All output attributes are copied from red band image.
- Return type
xarray.DataArray of the same type as inputs
Examples
>>> from xrspatial.datasets import get_data >>> data = get_data('sentinel-2') # Open Example Data >>> red = data['Red'] >>> green = data['Green'] >>> blue = data['Blue'] >>> from xrspatial.multispectral import true_color >>> # Generate true color image >>> true_color_img = true_color(r=red, g=green, b=blue) >>> true_color_img.plot.imshow()