MCPcopy Create free account
hub / github.com/AiEson/CrossMatch / encode_segmap

Function encode_segmap

LA/code/dataloaders/utils.py:83–97  ·  view source on GitHub ↗

Encode segmentation label images as pascal classes Args: mask (np.ndarray): raw segmentation label image of dimension (M, N, 3), in which the Pascal classes are encoded as colours. Returns: (np.ndarray): class map with dimensions (M,N), where the value at a

(mask)

Source from the content-addressed store, hash-verified

81
82
83def encode_segmap(mask):
84 """Encode segmentation label images as pascal classes
85 Args:
86 mask (np.ndarray): raw segmentation label image of dimension
87 (M, N, 3), in which the Pascal classes are encoded as colours.
88 Returns:
89 (np.ndarray): class map with dimensions (M,N), where the value at
90 a given location is the integer denoting the class index.
91 """
92 mask = mask.astype(int)
93 label_mask = np.zeros((mask.shape[0], mask.shape[1]), dtype=np.int16)
94 for ii, label in enumerate(get_pascal_labels()):
95 label_mask[np.where(np.all(mask == label, axis=-1))[:2]] = ii
96 label_mask = label_mask.astype(int)
97 return label_mask
98
99
100def decode_seg_map_sequence(label_masks, dataset="pascal"):

Callers

nothing calls this directly

Calls 1

get_pascal_labelsFunction · 0.85

Tested by

no test coverage detected