% do a majority vote over all cells in an image function [labout,truelab] = majorityimagevote(a,w) imlab = getident(a,'image'); ll = unique(imlab); n = length(ll); lab = zeros(n,1); truelab = []; for i=1:n I = find(imlab==ll(i)); out = a(I,:)*w; truelab(i,:) = getlab(a(I(1),:)); [mx,J]=max(+out,[],2); lab(i) = mode(J); end classll = getlabels(w); labout = classll(lab,:); truelab = char(truelab);