Blame view

matlab/cls_ConfusionMatrix.m 347 Bytes
3e63cf17   David Mayerich   added matlab file...
1
2
3
4
5
6
7
8
9
10
11
12
13
  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