Magnitude and Phase Information of the FFT
http://kr.mathworks.com/help/signal/examples/practical-introduction-to-frequency-domain-analysis.html#zmw57dd0e4405
2D shift
http://www.mathworks.com/matlabcentral/newsreader/view_thread/334354
My Code:
sz = 513;
gv = linspace(-1,1,sz);
[X,Y] = meshgrid(gv,gv);
[th,rh] = cart2pol(X,Y);
for ii=1:sz
for jj=1:sz
if th(ii,jj) < 0
th(ii,jj) = th(ii,jj) + 2*pi;
end
end
end
m = zeros(sz);
m = m + perlinBandAnalyser(sz,1,5, @(n,noise,w) deal(w(n)*noise,0), ones(9,1));
close all;
figure, calcPSD(m, 'show', 'mesh');
figure, imshow(m, []);
ft_m = fft2(m);
ft_IanShift_m = ft_m;
%phase shift
shiftAmount = 0.2*pi;
phase = angle(ft_IanShift_m); % Apply phase shift
amp = abs(ft_IanShift_m);
N = ceil(size(phase)/2);
phase(:,2:N(2),:) = phase(:,2:N(2),:)+ shiftAmount;
phase(:,(N(2)+1):(size(phase,2)),:) = phase(:,(N(2)+1):(size(phase,2)),:)- shiftAmount;
ShiftedImage = amp.*exp(1i*phase); % Recombine magnitude and phase
PhaseStim = real(ifft2(ShiftedImage)); % Perform inverse fourier transform
Range = max(max(max(PhaseStim))) - min(min(min(PhaseStim)));
PhaseStim = uint8(((PhaseStim - min(min(min(PhaseStim))))/Range)*255);
figure, imshow(PhaseStim,[]);
return;
'Cat.Storage > SubCat.Practice' 카테고리의 다른 글
[Directx12] 2. Anatomy of the sample code (1) | 2017.04.14 |
---|---|
[Directx12] 1. Settings (0) | 2017.04.13 |
[Matlab] Define 2D sinc() function (0) | 2016.09.21 |
C++ binary read/write sample (0) | 2016.03.15 |
D3D11 Rendertarget setting example. (0) | 2016.01.06 |