Matt J
Posts:
4,979
Registered:
11/28/09
|
|
Re: sub-pixel shifting of a matrix
Posted:
Feb 6, 2013 5:33 PM
|
|
"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <keubvt$fki$1@newscl01ah.mathworks.com>... > "Paulus Potter" wrote in message <keuaof$amu$1@newscl01ah.mathworks.com>... > > It should be: > > > > Image=conv2(Image,[sx, 1-sx],'same'); > > Result=conv2(Image,[sy; 1-sy],'same'); > > > > This is about twice faster > Result=conv2(Image,[sy; 1-sy]*[sx, 1-sx],'same');
Maybe, but only because there are some funny sub-optimal things happening inside conv2 implementation-wise, and because the interpolation kernel here happens to be small. There's no way the 3rd version below should be the slowest.
Image=rand(2000); kx=rand(1,10); ky=rand(10,1);
tic; Image=conv2(Image,kx,'same'); Result=conv2(Image,[sy; 1-sy],'same'); toc %Elapsed time is 0.045940 seconds.
tic; Result=conv2(Image,ky*kx,'same'); toc %Elapsed time is 0.090292 seconds.
tic; Result=conv2(kx , ky, Image,'same'); toc %Elapsed time is 0.162708 seconds.
|
|