lazyslide.cv.Mask

lazyslide.cv.Mask#

class Mask(mask, prob_map=None, class_names=None)#

Bases: ABC

classmethod from_polygons(polygons, bounding_box=None, class_col=None, classes_order=None)#

Create a mask from polygon.

Parameters:
polygonsgpd.GeoDataFrame

GeoDataFrame containing polygon.

bounding_boxtuple, optional

Bounding box to define the mask size (xmin, ymin, xmax, ymax).

class_colstr, optional

The column name in polygons that contain class labels.

classes_orderlist, optional

Order of classes in the mask.

Returns:
Mask

An instance of the appropriate Mask subclass.

to(T)#

Convert the mask to the specified type.

Parameters:
T{“binary”, “multilabel”, “multiclass”, “instance”} or Mask type

The mask type to convert to.

Returns:
Mask

An instance of the specified format.