medial_lines
Compute medial lines for the input GeoDataFrame polygon geometries.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gdf
|
GeoDataFrame
|
GeoDataFrame containing polygons to compute medial lines for. |
required |
num_points
|
int
|
Number of resampled points in the input polygons. |
500
|
delta
|
float
|
Distance between resampled polygon points. Ignored
if |
0.3
|
simplify_level
|
float
|
Level of simplification to apply to the input geometries before computing medial lines. This helps to reduce noise from the voronoi triangulation. |
30.0
|
parallel
|
bool
|
Whether to run the computation in parallel. |
False
|
num_processes
|
int
|
Number of processes to use for parallel computation. |
1
|
Returns:
Type | Description |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: GeoDataFrame containing the computed medial lines. |
Note
Returns an empty GeoDataFrame if the input is empty.
Examples:
>>> from histolytics.spatial_geom.medial_lines import medial_lines
>>> from histolytics.data import cervix_tissue
>>> import geopandas as gpd
>>>
>>> # Create a simple polygon
>>> cervix_tis = cervix_tissue()
>>> lesion = cervix_tis[cervix_tis["class_name"] == "cin"]
>>>
>>> # Compute medial lines for the largest lesion segmentation
>>> medials = medial_lines(lesion, num_points=500, simplify_level=50)
>>> ax = cervix_tis.plot(column="class_name", figsize=(5, 5), aspect=1, alpha=0.5)
>>> medials.plot(ax=ax, color="red", lw=1, alpha=0.5)
>>> ax.set_axis_off()