Petr Sladek (sladep1) & Milan Kratochvil (kratom4) at CTU Prague
A - collineation matrix, U - mesh matrix (set of x-y points)
%For images you can use this mesh: % meshgrid: see also meshgrid function % U(:,:,1) = [ 1 2 3 4 ....n sizen % 1 2 3 4 ....n % ... % 1 2 3 4 ....n //rows: sizem. % % U(:,:,2) = [ 1 1 1 1 ....1 //cols: sizen % 2 2 2 2 ....2 % ... % m m m m ....m m=sizem. %
%function [Y] = collin (A,U); % input is a U = m x n x 2 matrix [m n a] = size(U); % create m*n x 3 matrix (column only): % x y 1 X = ones(3,m*n); % this shoud produce very fast code: % mesh is reshaped into row vector X(1,:) = reshape(U(:,:,1),1,m*n); X(2,:) = reshape(U(:,:,2),1,m*n); % collination has one component same... Y3=A(3,:)*X; % allocate cY=zeros(2,m*n); % apply row-wise transformation % column result: cY(1,:) = ((A(1,:)*X)./Y3)'; cY(2,:) = ((A(2,:)*X)./Y3)'; % back to m-n matrix: Y = reshape(cY',m,n,2);