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_path
str Raster image path.
- rgb_band_index
tupleof3ints RGB band index in tuple.
- display_size
tupleof2numbers Size of RGB plot.
- roi_coords
listoflistsoftuplesof2numbersorNone,optional ROI vertex coordinate pairs in tuples in a list.
- roi_color
strortupleof3floats,optional ROI color in name string or RGB values.
- roi_linewidth
int,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_path
strorNone,optional Save RGB preview image to the path, if None, no file output. The default is None.
- dpi
int,optional DPI of the RGB preview image. The default is 150.
- raster_path
- Return type:
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)], ... ])