Lens distortion documentation
Posted: 2011-11-28T18:44:20-07:00
I've been using IM for a while to process my digital images (following some great pointers on photo blogs and forums) and have just added lens correction into my processing pipeline. To calculate the lens parameters for barrel distortion I followed http://www.imagemagick.org/Usage/lens/ to determine the correction coefficients a, b and c.
The trick with hugin works brilliantly. It is wonderful to see straight lines snap into place after calculating the parameters and applying the IM filter. But there are a couple of odd points in the documentation. Quote:
More trivial, but adding to my confusion the example given is:
In fact I found the description of how to set up hugin a bit confusing too, but the supplied example PTO file made everything clear. Overall the page was a great find.
The trick with hugin works brilliantly. It is wonderful to see straight lines snap into place after calculating the parameters and applying the IM filter. But there are a couple of odd points in the documentation. Quote:
What lens theory is that? This seems to imply a and b should always be zero. In fact for the lens I used all of a, b, c seemed highly significant, suggesting fairly mathematically complex barrel distortion. In this case setting a=c=0 certainly fails.The coefficients a and c are set to zero, i.e. the distortion is described only by the second-order term b (as predicted by lens theory).
More trivial, but adding to my confusion the example given is:
where the 4th coefficient d is chosen so that the coefficients sum to 1. But clearly -0.019966+0.980034 is not 1! In fact as the main IM docs state that if d is omitted it will be calculated and supplied automatically, which seems like a safer option.convert DSCN0001.jpg -distort barrel "0.0 -0.019966 0.0 0.980034" DSCN0001_pt.jpg
In fact I found the description of how to set up hugin a bit confusing too, but the supplied example PTO file made everything clear. Overall the page was a great find.