% converts the 8 pchirp parameters to the 8 psuedoperspective parameters
% using the 4 corners of a presumed image as the common points to define
% the relation between the pseudoperspective parameters and the pchirp
% parameters
%
% only used for illustrative purposes (e.g. to show problem with irani
% and peleg's latest method)

function q=approximationatcorners(p)

error('not finished yet')

if nargin==0
  error('p2pseudo: you must have an input argument')
end%if

if length(p) ~= 8
  error('p2pseudo: input vector, p, must have length 8')
end%if

if min(size(p)) ~= 1
  error('p2pseudo: input must be a vector and not a matrix')
end%if

x1=0; y1=0;
x2=0; y2=1;
x3=1; y3=0;
x4=1; y4=1;

x=[x1;x2;x3;x4];
y=[y1;y2;y3;y4];

o=ones(4,1);

u=(p(1)*x+p(2)*y+p(3)*o)./(p(7)*x+p(8)*y+o);
v=(p(4)*x+p(5)*y+p(6)*o)./(p(7)*x+p(8)*y+o);

z=zeros(4,1);
A=[one x y z z z x.^2 x.*y;  z z z o x y x.*y y.^2];  % 8 by 8 matrix
q=pinverse(A)*[u;v];  % pinverse in case rank defficient



