swectral.raster_rgb_preview#

swectral.raster_rgb_preview(raster_path, rgb_band_index, display_size, roi_coords=None, roi_color='red', roi_linewidth=3, *, normalize=True, output_path=None, dpi=150, show_image=True)[source]#

Display a raster image in RGB plot with optional ROI frames.

Parameters:
raster_pathstr

Raster image path.

rgb_band_indextuple of 3 ints

RGB band index in tuple.

display_sizetuple of 2 numbers

Size of RGB plot.

roi_coordslist of lists of tuples of 2 numbers or None, optional

ROI vertex coordinate pairs in tuples in a list.

roi_colorstr or tuple of 3 floats, optional

ROI color in name string or RGB values.

roi_linewidthint, optional

Line with of ROI polygon edges. The default is 3.

normalizebool, optional

Whether normalize RGB band values to the range of 0~255. The default is True.

output_pathstr or None, optional

Save RGB preview image to the path, if None, no file output. The default is None.

dpiint, optional

DPI of the RGB preview image. The default is 150.

Return type:

None

Examples

Generate RGB preview:

>>> raster_rgb_preview("image.tif", rgb_band_index=(192, 124, 64))

Generate preview and save preview image to file:

>>> raster_rgb_preview("image.tif", rgb_band_index=(192, 124, 64), output_path="/image_rgb.png")

Preview with ROI frames:

>>> raster_rgb_preview(
... "image.tif",
... rgb_band_index=(192, 124, 64),
... roi_coords=[
...     [(0, 0), (10, 0), (10, 10), (0, 10), (0, 0)],
...     [(30, 30), (30, 40), (40, 30), (30, 30)],
... ])