(imPred, imLab, numClass)
| 134 | |
| 135 | |
| 136 | def 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 | |
| 159 | class NotSupportedCliException(Exception): |
nothing calls this directly
no outgoing calls
no test coverage detected