%
% WVvsAF.m
%
% P. Flandrin

Ns = 64;
Na = floor(Ns/6);

tt = linspace(0,2*pi,100);
r = floor(4*Na/4);
P = zeros(Ns,Ns-1);
for m = Ns/2-Na:Ns/2+Na
	for n = Ns/2-fix(sqrt(r^2-(m-Ns/2)^2)):Ns/2+fix(sqrt(r^2-(m-Ns/2)^2))
		P(m,n) = 1;
	end
end

figure(1)
dt = floor(Ns/3);
df = .2;
sig1 = atoms(Ns,[Ns/2-dt,.25-df,Na,1]);
sig2 = atoms(Ns,[Ns/2+dt,.25+df,Na,1]);
wv = tfrwv(sig1+sig2,1:Ns,Ns);
figure(2)
clf
subplot(2,3,1)
imagesc(flipud(wv+abs(wv)));
axis('square')
title(['Wigner-Ville'])
colormap(jet)
set(gca,'YTick',[]);set(gca,'XTick',[])
pause
af1 = ambifunb(sig1+sig2);
af = real(af1) + abs(real(af1));
figure(2)
subplot(2,3,2)
imagesc(flipud(af));
axis('square')
title(['ambiguité'])
colormap(jet)
set(gca,'YTick',[]);set(gca,'XTick',[])
hold on
plot([1 Ns-1],[Ns/2 Ns/2],'y')
plot([Ns/2 Ns/2],[1 Ns],'y')
hold off
pause

figure(1)
dt = floor(Ns/9)
df = .07;
sig1 = atoms(Ns,[Ns/2-dt,.25-df,Na,1]);
sig2 = atoms(Ns,[Ns/2+dt,.25+df,Na,1]);
wv = tfrwv(sig1+sig2,1:Ns,Ns);
figure(2)
subplot(2,3,4)
imagesc(flipud(wv+abs(wv)));
axis('square')
title(['Wigner-Ville'])
colormap(jet)
set(gca,'YTick',[]);set(gca,'XTick',[])
pause
af2 = ambifunb(sig1+sig2);
af = real(af2) + abs(real(af2));
figure(2)
subplot(2,3,5)
imagesc(flipud(af));
axis('square')
title(['ambiguité'])
colormap(jet)
set(gca,'YTick',[]);set(gca,'XTick',[])
hold on
plot([1 Ns-1],[Ns/2 Ns/2],'y')
plot([Ns/2 Ns/2],[1 Ns],'y')
hold off
pause

subplot(232)
hold on
plot(Ns/2+r*cos(tt),Ns/2+r*sin(tt),'y')
hold off

subplot(235)
hold on
plot(Ns/2+r*cos(tt),Ns/2+r*sin(tt),'y')
hold off

pause

tf = ifft2(P.*af1);
subplot(233)
imagesc(abs(imag(tf))');
axis('square')
title(['Wigner-Ville lissée'])
colormap(jet)
set(gca,'YTick',[]);set(gca,'XTick',[])
pause

tf = ifft2(P.*af2);
subplot(236)
imagesc(abs(imag(tf))');
axis('square')
title(['Wigner-Ville lissée'])
colormap(jet)
set(gca,'YTick',[]);set(gca,'XTick',[])
