opendvp.io.segmask_to_qupath#
- opendvp.io.segmask_to_qupath(path_to_mask, simplify_value=1.0, save_as_detection=True)#
Convert a segmentation mask (TIFF) to QuPath-compatible detections as a GeoDataFrame or GeoJSON file.
This function loads a 2D segmentation mask image, converts it to polygons using spatialdata, and prepares the result for QuPath detection import. Optionally, it can simplify the geometry, export the detections as a GeoJSON file, and/or return the resulting GeoDataFrame.
- Return type:
GeoDataFrame
|None
Parameters#
- path_to_maskstr
Path to the segmentation mask image (must be a .tif file).
- simplify_valuefloat, default 1
Tolerance for geometry simplification. Set to None to disable simplification.
- export_pathstr, optional
If provided, writes the detections to this path as a GeoJSON file.
- return_gdfbool, default False
If True, returns the resulting GeoDataFrame. If False, returns None.
Returns:#
- geopandas.GeoDataFrame or None
The resulting GeoDataFrame if
return_gdf
is True, otherwise None.
Raises:#
- ImportError
If required packages (dask, dask_image, spatialdata) are not installed.
- ValueError
If input types or file extensions are incorrect.
Notes:#
Requires the ‘dask’, ‘dask_image’, and ‘spatialdata’ packages.
The exported GeoJSON is compatible with QuPath for detection import and visualization.