% PUMA (Phase Unwrapping via MAxflow) 
%   demo2 - High phase rate Gaussian Hill with a quarter set to zero.
%   The clique potential is given by Q(v(x)) =x^0.5; the employed cliques are
%   given by vectors [0 1] and [1 0].
%   For further details about using PUMA please see puma_ho.m file

% José Bioucas-Dias and Gonçalo Valadão (2007)
% 
% data generation

M=150;
N=100;
mx=75; my=50;
mask = ones(M,N); mask(1:mx,1:my)=0;
% build Gaussian elevation
z=gaussele(M,N,14*pi,10,15).*mask;

% set coherence = 1 (no noise)
co=1;
% generate insarpair
[x1 x2] = insarpair(ones(M,N), co*ones(M,N), z, 0);
eta = angle(x1.*conj(x2));

hold off
xx = 1:150;
yy = 1:100;
colormap(gray);
imagesc(xx,yy,eta)
title('Interferogram');
drawnow;


% PUMA processing
p=0.5; % Clique potential exponent
figure;
[unwph,iter,erglist] = puma_ho(eta,p);


figure;
surfl(unwph);shading interp; colormap(gray);
title('Puma solution');


