Mercurial > forge
changeset 11419:c8b7b87a88a4 octave-forge
cp2tform: avoid svd decomposition for performance (patch by Pantxo Diribarne) (bug #38179).
author | carandraug |
---|---|
date | Tue, 29 Jan 2013 09:17:31 +0000 |
parents | ed31a7de4a80 |
children | 354517fa551d |
files | main/image/inst/cp2tform.m |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/main/image/inst/cp2tform.m Mon Jan 28 20:15:39 2013 +0000 +++ b/main/image/inst/cp2tform.m Tue Jan 29 09:17:31 2013 +0000 @@ -205,10 +205,11 @@ tmp1 = ones(size(u)); A = [-u -v -tmp1 tmp0 tmp0 tmp0 x.*u x.*v x; tmp0 tmp0 tmp0 -u -v -tmp1 y.*u y.*v y]; - [U S V] = svd (A); - tmat = V(:,end); + B = - A(:,end); + A(:,end) = []; + tmat = A\B; + tmat(9) = 1; tmat = reshape (tmat, 3, 3); - tmat = tmat./tmat(end,end); trans = maketform ("projective", tmat); case "polynomial" @@ -289,7 +290,7 @@ %!test -%! npt = 10000; +%! npt = 100000; %! [crw, cap] = coords (npt); %! ttype = 'projective'; %! T = cp2tform (crw, cap, ttype);