Initialization functions
- class tomni.annotation_manager.main.AnnotationManager(annotations: List[tomni.annotation_manager.annotations.annotation.main.Annotation])[source]
Bases:
object
- classmethod from_binary_mask(mask: numpy.ndarray, include_inner_contours: bool = False, label: str = '')[source]
Initializes an AnnotationManager object from a binary mask.
- Parameters
cls ('AnnotationManager') – The class itself.
mask (np.ndarray) – Binary mask input.
include_inner_contours (bool, optional) – Include annotations that are contained within another annotation. Defaults to False.
label (str, optional) – A label to assign to the annotations. Defaults to “”.
- Returns
A new AnnotationManager object created from the binary mask.
- Return type
- classmethod from_dicts(dicts: List[dict])[source]
Initializes the class with a list of dictionaries containing annotations.
- Parameters
cls ('AnnotationManager') – The class itself.
dicts (List[dict]) – A list of dicts containing annotations.
- Raises
ValueError – Raised if the input dictionaries are not properly formatted.
Note
Only Polygon and Ellipse annotations are supported.
- Returns
An instance of the AnnotationManager class containing the parsed annotations.
- Return type
- classmethod from_labeled_mask(mask: numpy.ndarray, labels: Union[List[str], str] = '', include_inner_contours: bool = False)[source]
Initializes an AnnotationManager object from a labeled mask. A labeled mask contains components indicated by the same pixel values.
- Parameters
cls ('AnnotationManager') – The class itself.
mask (np.ndarray) – A labeled mask with a maximum number of components limited by max(np.uint32).
labels (Union[List[str], str], optional) – A list of class names to add to Polygon labels. Defaults to “”. Should have the same number of unique pixel values as classes. Class names in order of low pixel value to high pixel value.
include_inner_contours (bool, optional) – Include annotations that are contained within another annotation. Defaults to False.
Example input with multiple pixel values:
[ [0, 0, 2, 1, 1], [0, 0, 2, 0, 0], [0, 0, 2, 0, 0] ]
- Returns
A new AnnotationManager object.
- Return type