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 11:10:17 +0000 (UTC)
Organization: Oxford University
Lines: 18
Message-ID: <gg64up$sn8$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> <gg56bi$fe6$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1227265817 29416 172.30.248.35 (21 Nov 2008 11:10:17 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 21 Nov 2008 11:10:17 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1073021
Xref: news.mathworks.com comp.soft-sys.matlab:502272


> 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.

We don't agree so we should do it and see.

I've found something that seems to work:

>> A = imread('cameraman.tif');
>> subplot(121); imshow(A);
>> B = fftshift(fft2(im2double(A)));
>> B = ifft2(ifftshift(B(71:end-70,71:end-70)));
>> subplot(122); imagesc(real(B)); colormap(gray(255)); axis image off

It reduces the image by 140 pixels in each dimension. You can enlarge by padding with zeros. You can avoid the shifts by working out what they do and cropping the correct regions directly.

You'll note that I take the real component - the output is complex, which is a bad sign. I also use imagesc to display the output image, as it isn't scaled in the [0, 1] range any more, again a bad sign.

Looking at image quality, it is clear cropping high frequencies doesn't simply subsample the image (i.e. take every ith pixel). However, there are some high frequency artifacts. Overall it seems like it won't work well.