No speed up in Separable Convolution
<p>I'm implementing separable convolution to speed up 2D Gaussian convolution.</p>

<pre><code>clear all;
close all;

im = randi([0,255],1024,1024);

win = 7;
window = fspecial('gaussian',win,win/6);

[U, S, V] = svd(window);
v = U(:,1) * sqrt(S(1,1));
h = V(:,1)' * sqrt(S(1,1));

out1 = filter2(window, im);
out2 = filter2(h, filter2(v, im));
norm(out1 - out2)

tic
for i = 1:1000
    out1 = filter2(window, im);
end
toc

tic
for i = 1:1000
    out2 = filter2(h, filter2(v, im));
end
toc
</code></pre>

<p>The separable version is supposed to be faster by win*win/(win + win) = 2.5 times, but it is actually slower:</p>

<pre><code>ans =
2.6250e-12

Elapsed time is 5.486270 seconds.
Elapsed time is 8.769868 seconds.
</code></pre>

<p>Was there any hidden implementation inside filter2?</p>