Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Embedded Image Resizing using FFT
Date: Fri, 21 Nov 2008 02:28:02 +0000 (UTC)
Organization: Xoran Technologies
Lines: 34
Message-ID: <gg56bi$fe6$1@fred.mathworks.com>
References: <gg4co5$2cu$1@fred.mathworks.com> <gg4jc2$bck$1@fred.mathworks.com> <gg4kn6$2va$1@fred.mathworks.com> <gg4mdj$sjg$1@fred.mathworks.com> <gg4o3u$qfh$1@fred.mathworks.com> <gg4pkl$h47$1@fred.mathworks.com> <gg53fl$f0n$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1227234482 15814 172.30.248.37 (21 Nov 2008 02:28:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 21 Nov 2008 02:28:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:502221



> Have you tried this? There are scale factors to consider. In practice fft2 isn't too bad:
> >> A = rand(1000,1000,3);
> >> tic; imresize(A, 1/2); toc
> Elapsed time is 0.606730 seconds.
> >> tic; fft2(A); toc
> Elapsed time is 0.519417 seconds.
#############################

Here's what I tried.

First the data prep.
>>A=rand(1000,1000); A=single(A);
>>[xx,yy]=ndgrid(1:.5:1000,1:.5:1000); xx=single(xx); yy=single(yy);

These are the operations you would do to upsample by a factor of 2 using the frequency based method.

>>tic;B=fft2(A); C=ifft2(B,2000,2000);toc
Elapsed time is 1.184620 seconds.

Conversely, these are the operations you would do to upsample by straight linear interpolation. I'm using my own C-coded linear interpolation routine because MATLAB's interp2 is handicapped (it is implemented as an mfile).

>> >> tic; z=linterpcpp(A,xx,yy);toc
Elapsed time is 0.142840 seconds.


#####################
> Forgetting speed for a minute, I think a benefit of the frequency domain approach---simply cropping the unwanted high frequencies out---is that it gives you the best possible resizing (if someone can work out whether it's possible and how) because it keeps all the frequencies which will be visible in the smaller (assuming this is for downsampling) image. You don't need to work out any optimal smoothing filter for the spatial domain.
#######################


I don't think so. As far as I can tell, cropping frequencies (say by an integer factor 2) is equivalent to decimating the image by the same factor f(n,m)-->f(2n,2m).
This is known to give bad results.