help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mean filter


From: Søren Hauberg
Subject: Re: Mean filter
Date: Thu, 21 Jul 2005 13:44:49 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050404)

Francesco Potorti` wrote:
I'm looking for a *fast* implementation of a mean filter.


function m = meanfilter (x, ws)
    l = length(x);
    a = cumsum(prepad(x, l+1));
    b = a(ws+1:l)-a(1:l-ws);
    m = b/ws;
endfunction

Thanks, I hadn't thought of that implementation - it's nice :-)
Unforunaly it doesn't appear to be fast enough:

a = rand(1,100000);
f = ones(1,100)/100;

tic; m1 = meanfilter(a, 100); toc
ans = 0.15448

tic; m2 = conv(a, f); toc
ans = 0.12615

Thanks,
Søren



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]