Title: Logo reconstruction using least squares method
1Logo reconstruction using least squares method
Kevin Ryan Nora Matell 3/12/08
2Least squares (LSQR) method the theory
- An iterative method of solving Ax b for an
unknown x - Start with a best guess x, or none at all
- Iteratively minimizes
- Converges to a solution precision of this
solution depends on number of iterations (up to
some limit) - Dont ever need actual A as long as can input
function Ax b
x
b
A
3Least squares (LSQR) method the reality
- An iterative method of solving Ax b for an
unknown x - Start with a best guess x, or with no initial
guess (guesses b) - If A unknown, need both Ax b and Ax b
4Other LSQR-like methods can theoretically solve
problem with just function Ax b (i.e.
bicgstab)
X bicgstab(_at_afun,B) function y afun(x)
sol reshape(x,n,n) n2
(n1)/2 xv-n21n2-1
xzxv(n1)/(n1) xp1,xp2meshgrid(xz,
xz) sc ones(n,n) Loop over
m angles for j0n-1 th
pij/n st sin(th)
ct cos(th) x1 xp1ct-xp2st
Generate the x1,x2-coordinates for
x2 xp1stxp2ct the grid points in the
xp1,xp2 grid. s interp2(xv,xv,sol,x
1,x2,'cubic') s(isnan(s))0
Get rid of all NaNs from extrapolation.
sc(,j1) sum(s,2) Sum along each
ray end scsc/max(sc)
yreshape(sc,nn1,1) end
Input function Ax b and nn x 1 b matrix
Function Ax b
5However, solution does not converge depends on
first choice of x matrix
No initial guess
Initial guess of actual x
6Problem we are trying to use A to iterate
Conditioning an indicator of how much error will
be in a solution after solving iteratively
completely ill-conditioned 0 completely
well-conditioned 1 Our A 5.89 x
10-19
7However, LSQR does work (well) if you can give it
both A and b
Input function Ax b, Ax b and nn x 1 b
matrix
Solve by LSQR x lsqr(_at_afun, b,tol)
function y afun(x,transp_flag) if
strcmp(transp_flag,'transp') y A'x
y A'x elseif strcmp(transp_flag,'n
otransp') y Ax y A x
end end
Function uses sparse A matrix (calculated
earlier), x is iterative x
8Precision of solution depends on tolerance for
error in solution Same input A and B used here
Smaller tolerance does not always mean better
reconstruction
Tolerance 0.50.019 seconds
Tolerance 0.00010.572 seconds
Tolerance 0.10.030 seconds
9LSQR is relatively fast Same input A and b
used here 63 rays, 89 angles, 63 elements on
each side of reconstruction
LSQR
Brute force
199.14 seconds
0.89 seconds.
10Original logo
LSQR reconstruction