swectral.resample_roi#
- swectral.resample_roi(coord_lists, resolution, coverage_ratio, random_state=None)[source]#
Randomly resample a multi-part ROI into a list of new multi-part ROIs.
Each generated sub-ROI is represented as a multi-part structure (list of polygons). The resampling follows a grid-based approach where squares must be strictly contained within the original multi-part ROI.
- Parameters:
- coord_lists
listoflistoftupleof2 (floatorint) Coordinates of the input multi-part ROI. Structure: [[(x1, y1), …], [Polygon 2 coords], …]
- resolution
floatorint The side length of the square grid cells used for resampling.
- coverage_ratio
float The target fraction of the total ROI area to resample (0.0 to 1.0).
- random_state
int,optional Random state for reproducibility. Defaults to None.
- coord_lists
- Returns:
- Return type:
Examples
>>> roi = [[(0, 0), (10, 0), (10, 10), (0, 10), (0, 0)]] >>> samples = resample_roi(roi, resolution=2, coverage_ratio=0.3)