cls_ConfusionMatrix.m
347 Bytes
function M = cls_ConfusionMatrix(GT, T)
%calculate the classes (unique elements in the GT array)
C = unique(GT);
nc = length(C); %calculate the number of classes
M = zeros(nc); %allocate space for the confusion matrix
%for each class
for ci = 1:nc
for cj = 1:nc
M(ci, cj) = nnz((GT == C(ci)) .* (T == C(cj)));
end
end