overlay_agreement

overlay_agreement(image, prediction, truth, alpha=OVERLAY_ALPHA, colours=None)

An image showing what was found, what was missed and what was invented.

Three colours rather than one, because a missed lesion and a false alarm cost different things and a single-colour overlay hides which of the two is being looked at.

Parameters

Name Type Description Default
image np.ndarray one image, as overlay_mask takes it. required
prediction np.ndarray class indices or a one-hot array; anything above class 0 counts as foreground. required
truth np.ndarray the same, for the annotation. required
alpha float how much of the tint shows. OVERLAY_ALPHA
colours dict[str, str] | None keyed hit, missed, false_alarm. Defaults to the engine’s, which the R package reads too, so the two cannot disagree about what red means. None

Returns

Name Type Description
np.ndarray A height x width x 3 array of 0-255 integers.

Raises

Name Type Description
PlatypusError if the shapes do not correspond, or a colour is missing.

import numpy as np image = np.full((4, 4, 3), 0.5) predicted = np.zeros((4, 4), dtype=int); predicted[1:3, 1:3] = 1 actual = np.zeros((4, 4), dtype=int); actual[2:4, 1:3] = 1 shown = overlay_agreement(image, predicted, actual) shown.shape (4, 4, 3) bool((shown[1, 1] != shown[3, 1]).any()) # invented, and missed True

any rather than all: amber and red share their blue channel - both end 3c - so no overlay can separate those two there, and a check that said all would be asserting something the palette cannot deliver.