Wednesday, 13 May 2015

image processing - Fourier Decomposition


Hello everyone have a look at this video of Fourier Decomposition of an image(otherwise you can also refer the image which shows few plots of different extracted waves from an image) . We also know that a Fourier series is given as


$$\frac {a_0} 2 + \sum \limits _{m=1} ^\infty (a_m \cos \frac {2 \pi m t} T + b_m \sin \frac {2 \pi m t} T)$$


1.In the given video at bottom middle there is plot of extracted waves.My doubt is whether these waves means cosine (or sine) functions from the Fourier series formula?


2.What is mean by bases functions(or images)? Whether the plot of Extracted waves are called as bases functions here?


Note:Although above Fourier Formula is for 1D signal and video is of 2D image,please keep in mind Fourier series formula for 2D signal.



Answer




Here the part of source code from the description of the video on youtube. (I have cut a small part of it and have written some comments for sake of clarity):


% Read initial image.

I = imread('cameraman.tif');
...
% Calculate amplitudes of frequency components.
FT_I = fftn(I);
ABS_FT_I = abs(FT_I);

% Initialize some global variables.
FT_new = zeros(size(FT_I));
FT_cur = zeros(size(FT_new));
newIm = zeros(size(FT_new));

...
% Demo loop.
n = 1;
nWaves = 1;
while n < % termination condition here.

% Choosing values of demo's parameters.
if n > 20; nWaves = 10; end
if n > 200; nWaves = 100; end
if n > 2000; nWaves = 1000; end


% Nullify global temporary variable.
FT_cur = 0*FT_cur

% Accumulate 'extracted waves' in frequency domain.
for p = 1:nWaves*2

% Find indices of frequency components with max amplitude.
[a,b] = find(ABS_FT_I == max(ABS_FT_I(:)), 1, 'first');
ABS_FT_I(a,b) = 0;


% Append them to the temporary buffer.
FT_cur(a,b) = FT_I(a,b);
end

% Create 'extracted waves' in spatial domain.
I_cur = ifftn(FT_cur);

% Concatenate all parts of an video frame.
canvas = cat(2, real(I - newIm - I_cur), zeros(size(I)), newIm);

canvasShow = canvas;
canvasShow(:,1:N(2)) = canvasShow(:,1:N(2)) + I_cur;
subplot(2,1,2);

% Plot the real part of the video frame.
% And as result the real part of 'extracted waves'.
imagesc(real(canvasShow), viewRange);
...
end


According to source code, the plot of extracted waves is the real part of the Inverse Fourier Transform of the sum of nWaves spectral components $F(s,t)$ with maximum amplitude: \begin{equation} f(x,y) = \frac{1}{NM}\sum\limits_{s,t\in U}Re\big(F(s,t)e^{2\pi i(sx/N + ty/M)}\big) \end{equation} where $f(x,y)$ is the value of the $(x,y)$ pixel of the extracted waves image in the spatial domain, $F(s,t)$ is the value of the $(s,t)$ component in the frequency domain, $U$ is first nWaves frequency components with $\max|F(s,t)|$. So these waves aren't cosine nor sine. They are non trivial linear combination of sine and cosine waves.



It's hard to tell without knowing the procedure, that have been used to create those images. But if the procedure is the same as in the video presentation, then it isn't technically correct to call those images Basis Functions.


No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...