0001 function [outs, realOuts] = computeOutputs(ab, examples, extraArg)
0002
0003
0004
0005
0006
0007
0008
0009 if isempty(ab.weakCl)
0010 error('A weak classifier is not specified');
0011 end
0012 if isnan(ab.thresh) && ~ab.perfect
0013 error('AdaBoost classifier has not been trained');
0014 end
0015
0016 if nargin == 1
0017 error('incorrect number of arguments');
0018 elseif nargin == 2
0019 extraArgs = {examples};
0020 else
0021 if iscell(extraArg),
0022 extraArgs = {examples, extraArg{:}};
0023 else
0024 extraArgs = {examples, extraArg};
0025 end
0026 end
0027
0028 wkClOuts = computeOutputs(ab.trndCls{1}, extraArgs{:});
0029 nExamples = numel(wkClOuts);
0030 realOuts = zeros(nExamples, getNumClasses(ab));
0031 sz = size(realOuts);
0032 rowInds = (1:nExamples)';
0033 realOuts(sub2ind(sz, rowInds, wkClOuts)) = ab.clsWeights(1);
0034 for i = 2:length(ab.clsWeights),
0035 wkClOuts = computeOutputs(ab.trndCls{i}, extraArgs{:});
0036 inds = sub2ind(sz, rowInds, wkClOuts);
0037 realOuts(inds) = realOuts(inds) + ab.clsWeights(i);
0038 end
0039 if getNumClasses(ab) == 2
0040 outsPos = (realOuts(:, getPosVal(ab)) - realOuts(:, getNegVal(ab))) >= ab.thresh;
0041 outs(outsPos) = getPosVal(ab);
0042 outs(~outsPos) = getNegVal(ab);
0043 outs = outs';
0044 else
0045 [~, outs] = max(realOuts, [], 2);
0046 end