% Local maximum of mean values of scores in n frames temporal pooling method
% omtp = temppool_mean(om)
% om vector of objective metric scores for each frame
% n number of successive frames which are evaluated
% optional argument: 'ssim' indicates that objective metric is SSIM
% This method emphasizes the influence of the poorest quality section.
% Local maximum is calculated for VQM and MSE, local minimum for SSIM.
function omtp = temppool_localn(om, n, varargin)
    if ~isvector(om)
        error('Input om must be a vector')
    end
    if ~isscalar(n) || n <= 0 || n > length(om)
        error('Input n must be a positive scalar smaller or equal than length(om)');
    end
    if nargin > 3
        error('Too many input arguments');
    end
    [a,b] = size(om);
    if a > b
        om = om';
    end
    meanslocaln = zeros(1, length(om)-n+1);
    for t=1:length(om)-n+1
        meanslocaln = mean(om(t:t+n-1));
    end
    if nargin == 2
        omtp = max(meanslocaln);
    else
        if nargin == 3 && strcmp(varargin{1}, 'min')
            omtp = min(meanslocaln);
        else
            omtp = max(meanslocaln);
        end
    end