A semantic segmentation for an image.
Provide either the mask or mask_path argument to define the segmentation.
Parameters | |
mask | a numpy array with integer values encoding the semantic labels |
mask | the absolute path to the segmentation image on disk |
Method | export |
Exports this instance's mask to the given path. |
Method | get |
Returns the segmentation mask for this instance. |
Method | import |
Imports this instance's mask from disk to its mask attribute. |
Method | to |
Returns a Detections representation of this instance with instance masks populated. |
Method | to |
Returns a Polylines representation of this instance. |
Method | transform |
Transforms this instance's mask according to the provided targets map. |
Instance Variable | mask |
Undocumented |
Instance Variable | mask |
Undocumented |
Property | has |
Whether this instance has a mask. |
Constant | _MEDIA |
Undocumented |
Inherited from _HasID
:
Class Variable | tags |
Undocumented |
Instance Variable | id |
Undocumented |
Method | _id |
Undocumented |
Property | _id |
Undocumented |
Inherited from Label
(via _HasID
, _HasMedia
):
Method | delete |
Deletes the attribute with the given name. |
Method | get |
Gets the value of the attribute with the given name. |
Method | has |
Determines whether the label has an attribute with the given name. |
Method | iter |
Returns an iterator over the custom attributes of the label. |
Method | set |
Sets the value of the attribute with the given name. |
Returns a Detections
representation of this instance with
instance masks populated.
Each "stuff" class will be converted to a single Detection
whose instance mask spans all region(s) of the class.
Each "thing" class will result in one Detection
instance
per connected region of that class in the segmentation.
Parameters | |
maskNone | a dict mapping integer pixel values (2D masks) or RGB hex strings (3D masks) to label strings defining which classes to generate detections for. If omitted, all labels are assigned to their pixel values |
mask | whether the classes are "stuff" (amorphous regions of pixels) or "thing" (connected regions, each representing an instance of the thing). Can be any of the following:
|
Returns | |
a Detections |
Returns a Polylines
representation of this instance.
Each "stuff" class will be converted to a single Polyline
that may contain multiple disjoint shapes capturing the class.
Each "thing" class will result in one Polyline
instance
per connected region of that class.
Parameters | |
maskNone | a dict mapping integer pixel values (2D masks) or RGB hex strings (3D masks) to label strings defining which classes to generate detections for. If omitted, all labels are assigned to their pixel values |
mask | whether the classes are "stuff" (amorphous regions of pixels) or "thing" (connected regions, each representing an instance of the thing). Can be any of the following:
|
tolerance:2 | a tolerance, in pixels, when generating approximate polylines for each region. Typical values are 1-3 pixels |
Returns | |
a Polylines |
Transforms this instance's mask according to the provided targets map.
This method can be used to transform between grayscale and RGB masks, or it can be used to edit the pixel values or colors of a mask without changing the number of channels.
Note that any pixel values not in targets_map will be zero in the transformed mask.
Parameters | |
targets | a dict mapping existing pixel values (2D masks) or RGB hex strings (3D masks) to new pixel values or RGB hex strings. You may convert between grayscale and RGB using this argument |
outpath:None | an optional path to write the transformed mask on disk |
update:False | whether to save the transformed mask on this instance |
Returns | |
the transformed mask |