On Tue, 24 Mar 2009 12:08:36 +0100
Wolfgang Hugemann <[email protected]> wrote:

| Hello,
| 
| it has been some time since this issue has been discussed over here.
| This morning, I started with a proof of concept, comparably to that I
| did with the perspective distortion (or rectification). This rest of
| this e-mail is quite technical and probably only relevant to developers, 
| especially Fred Weinhaus and Anthony Thyssen:
| 
| Just to recall the issue: The common barrel distortion of consumer
| cameras at short focal lengths can be described as a modification of the
| radius to the centre, which in turn follos a polynom of fourth order.
| This is the way Harry Deutsch and Panorama tools (and all its 
| offsprings, like PTlens) describe barrel distortion, i.e.:
| 
| r' = a_4 * r^4 + a_3 * r^3 + a_2 * r^2 + a_1 * r + a_0
| 
| Obviously, a_0, a_2, a_3 and a_4 must be close to zero and a_1 must be
| close to 1.
| 
| It would be easy to incorporate such a distortion in IM. This would
| however not make much sense without having the correction parameters for
| a certain make and models of consumer cameras at hand. (These are kept 
| secret by newer versions of PTlens.)
| 
| I have just pointed out a general approach to the problem, using Excel's
| solver and one of the images provided Fred Weinhaus' Website. The files 
| can be downloaded at www.unfallrekonstruktion.de/ImageMagick/pinbarrel.zip.
| 
| The general approach is the same as in PTlens: We possess a photograph
| of an object with some lines that we know to be straight. The user then
| supplies several points on some of these lines, e.g.
| 
| p11, ... , p15 on line 1
| p21, ... , p27 on line 2
| ....
| pn1,....., pnm on line n
| 
| and asks some software to calculate the distortion parameters from this.
| 
| This results in a non-linear optimisation problem, involving the 5
| parameters for the polynominal coefficients and 1 slope parameter for
| each line provided.
| 
| The lines chosen for the calibration will eitehr be nearly horizontal
| or nearly vertical (see http://www.epaperpress.com/ptlens and then chose
| calibration > targets). This means that the slopes of the lines
| will be either near zero or have rather high values. Turning the
| picture by 45° will yield slopes near +1 or -1 and thus work around this
| problem.
| 
| Another problem is that residuals have to be scaled by the inverse of
| the calculated radii, otherwise the optimisation routine would "chose"
| the polynominal coefficient such that the calculated radii r' all turn 
| out very small, thereby producing a (virtually) small residual.
| 
| I more or less solved these problems in the mentioned Excel sheet that I
| invite others to have a look at. (If so, I am ready for further 
| explanations.)
| 
| Possibly, this will, in the end, turn out as a suitable barrel 
| correction tool for IM.
| 
| Greetings from Germany
| Wolfgang
| 
| @ Anthony: I know that I still owe you the rectification examples I
| promised...
| 
Thank you Wolfgang for the zip file, I'll look at it.

however the calculation tool I saw used a photo which was simply equally
spaced blue lines.  Tool then draws a imaginary straight line from
one corner to the other and fines the intersection points of the
photographed lines to this diagonal.

It makes the assumption that the center of the distort is also the center
of the photo, and from this calculates three parameters only. A,B,C
D is also assumed to be  1-A-B-C  D can actually be likened to a general
scaling parameter.

If the program can do this, with the user measuring the intersections
or a more automatic method of determination, that would be fantastic!

IM has the distortion implemented, and will accept the A,B,C parameters
for correcting images.  However I have not had appropriate parameters
or the means to calculate those parameters for my own camera and thus
check on just how good it is working.





  Anthony Thyssen ( System Programmer )    <[email protected]>
 -----------------------------------------------------------------------------
   Take this cheese to sick bay!!!
   The Doctor should have a look at it.
                                 -- StarTrek Voyager "Training"
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/

_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to