Magic of Fourier Transform ???
1 view (last 30 days)
Show older comments
Hello everyone,i am doing my project in image processing.. i have done video sementation using the Fourier transform . I applied 3-D fft on video (gray image(2D)+no of video frames(1D)=3D) and Obtained magnitude and phase spectrum and reconstructed video frames back from the phase spectrum only . i am doing coding part using Matlab software
1. I have found that moving part pixel intensity values becomes dominant (means its intensity values are increased so much) compared to stationary part intensities in reconstructed frames of original frames .(e.g.in waterfall and traffic on road, water part and moving car's intensity values are increased respectively compared to the stationary background). i want to know how did this happen?
2. can i say here that moving part is only detected and no stationary part,due to the " intraframe 'phase ' modulation of moving part pixels" and "no modulation of stationary part pixels as it has no 'movement'"...and it was phase modulation ??
i am adding my matlab code so that u can check my code,run it and check variable values in the workspace
i'm hoping i will get explanation about the basic concepts related to it. Thanks in advance
clc;
clear all;
close all;
%read video file
video = VideoReader('H:\amit\amit_project\database\video23.avi');
T= video.NumberOfFrames ; %number of frames%
frameHeight = video.Height; %frame height
frameWidth = video.Width ; %frameWidth
get(video); %return graphics properties of video
i=1;
for t=10:10:250
f0(:,:,:,i)= read(video, t);
f1=f0(:,:,:,i);
f2=rgb2gray(f1); %convert colour frame into gray
f3(:,:,:,i)=f1;
I(:,:,i)=f2;
i=i+1;
end
%Take the 3-D Fourier Transform
f=fftn(I);
%Get the phase spectrum
phase=angle(f);
%Reconstrut frames by applying 3-D Inverse Fourier Transform on phase spectrum only
reconstruct=(ifftn(exp(1*j*phase)));
%Although moving part has large value, stationary part also has some
%normal value so to detect only moving part we will set some theshold
%and then reconstruct the frames
for m=1:i-1
reconstruct(:,:,m)=abs(reconstruct(:,:,m));
figure,
subplot(2,2,1),imshow(f3(:,:,:,m));title(['Video Frame :' num2str(m)]);
subplot(2,2,2),imshow(reconstruct(:,:,m),[]);title(['Averaged Frame :' num2str(m)]);
H = fspecial('disk',4);
avg(:,:,m) = imfilter(reconstruct(:,:,m),H);%Frame smoothing using circular average filtering
%calculate mean value
meanvalue=mean2(avg(:,:,m));
bw = im2bw(avg(:,:,m),2*meanvalue);
subplot(2,2,3),imshow(bw,[]);title(['Binary Frame :' num2str(m)]);
I2 = f3(:,:,:,m);
I2(bw) = 255;
subplot(2,2,4),imshow(I2,[]);title(['segmented Frame :' num2str(m)]);
end
0 Comments
Answers (2)
Image Analyst
on 31 May 2014
Well let's take a simple case to try to understand this. Let's say that you have an image of a round spot on a uniform background in 2D. Now it's well known and I'm sure you know that the Fourier Transform of that is a sombrero function (decaying Bessel function) centered at the origin. As you move the spot around, the real part of the FT is still a Sombrero function but the phase changes. I always like to relate this back to optics - say you have a plate with a open disk in it and insert it into a collimated plane wave laser beam. The diffraction pattern on a distance wall (or closer if you use a lens) is the Fourier transform. It will look the same as you move the plate around - it's still a sombrero function. What is changing is the phase.
3 Comments
Image Analyst
on 31 May 2014
I don't know what that means. What happened? The image changes from frame to frame so the Fourier Transform changes from frame to frame. I don't think there's any processing modulating the phase, it just changes because the image changed - something moved in it, like a car. Even if there was a modulation of the phase, what are you referring to when you ask if that modulation caused it?
Alfonso Nieto-Castanon
on 31 May 2014
Edited: Alfonso Nieto-Castanon
on 31 May 2014
Reconstructing the video using only phase information is just the same as whitening the spatio-temporal spectrum. Since natural images tend to have a 1/f spectrum the net effect will be some form of high-pass filtering (roughly multiplying by f in fourier domain or taken the first derivative in the original domain). This will emphasize image borders (hp in the spatial domain) as well as moving parts (hp in the temporal domain). Would that explain what you are observing?
3 Comments
Alfonso Nieto-Castanon
on 2 Jun 2014
1. I have found that moving part pixel intensity values becomes dominant (means its intensity values are increased so much) compared to stationary part intensities in reconstructed frames of original frames .(e.g.in waterfall and traffic on road, water part and moving car's intensity values are increased respectively compared to the stationary background). i want to know how did this happen?
Moving parts are relatively emphasized as a result of the roughly high-pass filter operation effected by whitening
2. can i say here that moving part is only detected and no stationary part,due to the " intraframe 'phase ' modulation of moving part pixels" and "no modulation of stationary part pixels as it has no 'movement'"...and it was phase modulation ??
No (unless you clarify what you mean by "intraframe phase modulation of moving/stationary part pixels", and it all somehow turns out to make sense; to be clear you may approximately characterize the effect of movement over time as a phase modulation of spatial frequency components but not of individual pixels)
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!