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_listslist of list of tuple of 2 (float or int)

Coordinates of the input multi-part ROI. Structure: [[(x1, y1), …], [Polygon 2 coords], …]

resolutionfloat or int

The side length of the square grid cells used for resampling.

coverage_ratiofloat

The target fraction of the total ROI area to resample (0.0 to 1.0).

random_stateint, optional

Random state for reproducibility. Defaults to None.

Returns:
list of list of tuple of 2 (float or int)

The coordinates of the resampled square sub-ROIs in the same structure as the input coord_lists.

Return type:

list[list[tuple[Union[int, float], Union[int, float]]]]

Examples

>>> roi = [[(0, 0), (10, 0), (10, 10), (0, 10), (0, 0)]]
>>> samples = resample_roi(roi, resolution=2, coverage_ratio=0.3)