PTOptimizer is part of panarama tools, a great software for aligning and stitching several partially overlapping photos in order to get a bigger photo.
PTOptimizer is also used by Hugin, a Panorama photo stitcher.
PTOptimizer calculates the alignment (orientation and possibly position) and other parameters of the individual photos so that this is best consistent
with the positions of all the control points in the images.

When you have only a small or medium number of images and control points, PTOptimizer does the optimization in a fairly short time.

However if you have a large number of images (several hundrets or even thousand) and control points, PTOptimizer typically needs much time for the
optimization of the parameters. You may need to wait several days until PTOptimizer has finished.

I have developed a version of PTOptimizer that dramatically decreases the processing time for large panoramas.
This is possible by exploiting the sparseness of the mathematical optimization problem.
The original PTOptimizer uses the well proven Levenberg Marquardt optimizer lmdif that is part of the minpack software (developed in in march 1980 by
Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More, argonne national laboratory). This lmdif function performs internally a "dense" QR decomposition
of the jacobian matrix. With dense I mean that no advantage is taken when only a small number of the matrix entries is nonzero like in the image alignment
optimization problem. I have taken the code of lmdif and replaced the dense QR decompositions by sparse ones using the software package SuiteSparse
(by Timothy A. Davis). I called my sparse Levenberg Marquardt optimizer lmdif_sparse.

For a large example panorama (with 1351 images and 273471 control points) my version of PTOptimizer speeds up the optimization by a factor of more than 100 compared
to the original PTOptimizer. The smaller the panorama the smaller will be the speed gain factor, but I think it's worth using the sparse Levenberg
Marquardt optimizer except you have only a few tens of images.

My version of PTOptimizer can be downloaded as part of the libpano library. It is a modified version of libpano13-2.9.20_rc3:

Download libpano13-2.9.20_rc3_mod-2021-04-12.zip (3.5 MBytes)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.