MCPcopy Create free account
hub / github.com/FreeformRobotics/OTS / intersectionAndUnion

Function intersectionAndUnion

utils.py:136–156  ·  view source on GitHub ↗
(imPred, imLab, numClass)

Source from the content-addressed store, hash-verified

134
135
136def intersectionAndUnion(imPred, imLab, numClass):
137 imPred = np.asarray(imPred).copy()
138 imLab = np.asarray(imLab).copy()
139
140 imPred += 1
141 imLab += 1
142 # Remove classes from unlabeled pixels in gt image.
143 # We should not penalize detections in unlabeled portions of the image.
144 imPred = imPred * (imLab > 0)
145
146 # Compute area intersection:
147 intersection = imPred * (imPred == imLab)
148 (area_intersection, _) = np.histogram(
149 intersection, bins=numClass, range=(1, numClass))
150
151 # Compute area union:
152 (area_pred, _) = np.histogram(imPred, bins=numClass, range=(1, numClass))
153 (area_lab, _) = np.histogram(imLab, bins=numClass, range=(1, numClass))
154 area_union = area_pred + area_lab - area_intersection
155
156 return (area_intersection, area_union)
157
158
159class NotSupportedCliException(Exception):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected