swectral.roispec#
- swectral.roispec(image_path, roi_coordinates, as_type='float32')[source]#
Extract spectra from a spectral image in a (multi-)polygon region of interest (ROI) defined with vertex coordinate pairs.
- Parameters:
- image_path
str Spectral image path.
- roi_coordinates
listoflistoftupleof2 (intorfloat) Coordinates of the ROI polygons. Structure:
[ [ (x1, y1), (x2, y2), ..., (xn, yn), (x1, y1) ], # Polygon 1 [ (x1, y1), (x2, y2), ..., (xm, ym), (x1, y1) ], # Polygon 2 ... ]
Each inner list represents a polygon (for multipart geometries), and each tuple is a vertex coordinate.
- as_type
typeorstr,optional Desired numeric data type for the extracted spectral values. Supports
numpynumeric dtypes. Default is ‘float32’.
- image_path
- Returns:
numpy.ndarrayArray of pixel spectra in the specified ROI, each row represents the spectrum values of a pixel.
- Return type:
Examples
>>> roispec("/image1.tif", [[(0, 0), (10, 0), (0, 10), (0, 0)]])