Thursday, November 21, 2024

Correcting Lens Distortion for Vintage Lenses

I love using vintage photographic lenses in my digital photography. Like all other lenses, they suffer from a number of imperfections which include lens distortion and transverse chromatic aberrations (TCA). In the age of digital processing, such effects can, however, be fixed in post processing. While flexible frameworks exist for this purpose, these usually include libraries for modern lenses but rarely for vintage glass.

Therefore, I determined the corrections for lens distortion and TCA for my vintage lenses, and I'm sharing the results, so that others may benefit from this work. (Note: one could also digitally correct for vignetting, but I consider vignetting as an artistic feature, so I did not spend the time and effort to implement this.) The corrections are determined for 27 vintage prime lenses on the full frame sensor of the Sony A7Rii.

  • Carl Zeiss Jena Flektogon 20mm f/4
  • Carl Zeiss Jena Flektogon 35mm f/2.4
  • Carl Zeiss Jena Pancolar 50mm f/1.8
  • Carl Zeiss Jena Biotar 58mm f/2
  • Carl Zeiss Jena Tessar 50mm f/2.8
  • Carl Zeiss Jena Sonnar 135mm f/3.5
  • Carl Zeiss Jena Triotar 135mm f/4 (version 2)
  • Meyer-Optik Görlitz Orestegon 29mm f/2.8
  • Meyer-Optik Görlitz Lydith 30mm f/3.5
  • Meyer-Optik Helioplan 40mm f/4.5
  • Meyer-Optik Görlitz Domiplan 50mm f/2.8
  • Meyer-Optik Görlitz Oreston 50mm f/1.8
  • Meyer-Optik Görlitz Orestor 100mm f/2.8
  • Meyer-Optik Görlitz Orestor 135mm f/2.8
  • Meyer-Optik Görlitz Orestegor 200mm f/4
  • Pentacon 50mm f/1.8
  • Schneider-Kreuznach Retina-Curtagon 28mm f/4
  • Schneider-Kreuznach Retina-Curtagon 35mm f/2.8
  • Schneider-Kreuznach Curtagon 35mm f/4
  • Schneider-Kreuznach Retina-Tele-Arton 85mm f/4
  • Schneider-Kreuznach Tele-Xenar 90mm f/3.5
  • Schneider-Kreuznach Retina-Tele-Xenar 135mm f/4
  • Steinheil München Auto-D-Quinaron 35mm f/2.8
  • Steinheil München Culminar 85mm f/2.8
  • Steinheil München Auto-D-Tele-Quinar 135mm f/2.8
  • Voigtländer Color-Ultron 50mm f/1.8
  • Beroflex 400mm f/6.3

The results are available for the "lensfun" library which can be used e.g. in software like Darktable, Rawtherapee, Digikam, Rawstudio, and others (but not in Lightroom). If you just want to go ahead and use the results, please scroll down to the instructions for "Download and Install". 
If you are interested in the underlying concepts and how these corrections are derived (and how you can easily derive your own corrections for other lenses), I give a brief overview with links to more detailed descriptions/instructions, plus figures comparing the distortions of different lenses.


Lens Distortion Model



There are two main types of lens distortion called "barrel" (left) and "pincushion" distortion (right), but also combinations of these two exist. In both cases, a true geometry (blue dashed lines) produces an image (red lines) with a distorted geometry.
While the following describes the distortion model used in lensfun, one should be aware that different models exist (e.g. Adobe uses a slightly different model). Based on the rotational symmetry of typical lenses, the distortion is parameterized only as a function of radius (the distance of a point from the center of the image). The radius is taken as the "normalized" radius, which is the radius of the largest circle that fits into the image, normalized to unity. For example, for a 24mm x 36mm full frame sensor, the circle with 12mm radius is being referred to as r = 1.
The assumption is that a point with true, undistorted radius ru ends up in the image at a different, distorted radius r which can be expressed as a polynomial in ru.
   r =  a ru4  + b ru+ c ru2 + v ru ,
or, after factoring out ru
   r = ru ( a ru3  + b ru+ c ru + v) .
If we define the circle with r = 1 as "undistorted" (so: ru = 1 = r), we get the normalization condition for the coefficients
     a + b + c + v = 1 ,
which translates into
   v = 1 - a - b - c .
Therefore, v can be eliminated and the final relation is
   r = ru ( a ru3  + b ru+ c ru + [1-a-b-c]) ,
with 3 parameters a, b, c.

Lensfun has implemented a lens correction function, based on this model. If for a given lens, the parameters a, b, c are known, lensfun can produce the corresponding distortion correction which can be used e.g. in Darktable (and the other codes mentioned above).

Software

The determination of these distortion parameters a, b, c sounds like a complex task. However, powerful software for this exists already as part of the panorama stitching software package Hugin. A nice and detailed description of the calibration procedure can be found here (including links at the bottom for specifics on the distortion, TCA, and vignetting corrections). In Hugin, there exist a "calibrate lens GUI" which would be the easiest way to determine the corrections. But this requires certain features in the calibration images which, for me, are not easy to find. Therefore, I am using Hugin's Python script lens_calibrate.py (on a Linux system) for which the installation and usage are described here.
This script uses Hugin to determine the TCA correction all by itself, but it needs a little manual input for the distortion correction.

Determination of the Distortion Parameters

A single image can be used for both the distortion and the TCA correction which should be taken at a distance of 8m or more. The former requires two straight lines, one at the very top of the image and another one about one third from the top, while the latter requires many sharp high-contrast edges (if possible black-white transitions). This is one of the images that I'm using (taken with the Meyer-Optik Oreston 2.8/100mm - which exhibits notable pincushion distortion).


For the TCA correction, there are obviously many black-white transitions - and for the distortion correction I am using the upper two horizontal lines. Following the instructions, I am adding a number of points along the two lines (as seen in the screen capture), from which Hugin can compute the distortion correction that makes these straight.


For the first lens it takes a little to understand the details of the procedure, but for subsequent lenses, it's actually pretty quick. And remember: you just have to do this once per lens - then you can correct the images from these lenses for the rest of your life.
After the correction is applied, the image from the Meyer-Optik Orestor 2.8/100mm shows straight, undistorted lines!


Here is a comparison of a 100% crop of the top left corner for the Carl Zeiss Jena Sonnar 3.5/135mm before (left) and after (right) the TCA correction is applied.



Notice how the green and purple edges are gone in the right image.

Comparing Lens Distortions

As discussed in the lens model description, the lens distortion modifies only the radial position of a light ray (i.e. the distance from the center). Therefore, the distortion can be displayed as the radial shift  (rd - r, in microns) as a function of radius, where the normalized radius in the above formulas has been converted to the radius on the full frame sensor (in millimeters). For the full frame sensor the radius of the corners is about 22mm (half of the diagonal).
A positive distortion that is increasing towards larger r, means that the corners are shifted outward, corresponding to pincushion distortion, while barrel distortion corresponds to negative values at larger r.

Distortion of 50-58mm Lenses


The Biotar and Domiplan have almost no distortion. The largest (barrel) distortion is seen for the Pentacon 1.8/50mm and the Meyer Oreston 1.8/50mm (since the Pentacon 50 is a renamed Meyer Oreston, it was expected that the two are identical).

Distortion of 85-100mm Lenses


The Culminar and the Tele-Xenar have almost no distortion while the Meyer Orestor 100mm has a strong pincushion distortion (and I'm very happy that this will be corrected for in the future, which is a strong improvement for this very sharp lens).

Distortion of 135-200mm Lenses


The old Zeiss Triotar (version 2, from 1952), and the Meyer Orestegor 200mm have almost zero distortion. The others have pincushion distortion - the Zeiss Sonnar is still pretty good.

Distortion of 20-35mm Lenses


The Zeiss Flektogons and the Schneider lenses have the least distortion. The Meyers and Steinheil have stronger barrel distortion.

Comparisons with Previous Results

I was curious about the robustness of this procedure, the stability of the results, and if these are reproducible. Would two people with two different different pieces of the same lens model and with two different images (and possibly two slightly different procedures) come up with consistent corrections for a lens type? Fortunately, for one of my lenses (the Zeiss Sonnar 3.5/135mm), lensfun already has a set of distortion corrections (but no TCA) available.
It is very satisfactory to see that the distortion corrections for the two are in perfect agreement, giving confidence that the results are reproducible. 

The TCA corrections will be posted later in another blog entry ... [please come back, and check here]

Download and Install

At some point my calibrations will be included in the lensfun library (I'm currently checking with the Lensfun people). Until then, the .xml file of my lens calibration data can be downloaded here:

          vintage-glass.xml   (version from Nov 20, 2024 - please check again for new versions)

On a Linux system, this file should be copied (using sudo) into the directory  /var/lib/lensfun-updates/version_1/ - from the command line:
    sudo cp vintage-glass.xml /var/lib/lensfun-updates/version_1/.

On Windows system it should be copied it into 
    C:\Program Files\darktable\share\lensfun\version_1

At start, Darktable will automatically find the file and read the new lens data. Please note, that these are made for a full frame sensor, so they will not show up when a APS-C or M43 camera was detected.

I hope this works for you! If not, please let me know.

Saturday, October 26, 2024

Night - Black and White Photography in Ruston, LA

Nighttime is, indeed, the right time, for capturing your favorite places in a different light, literally. I took these photos between 2022 and 2024, most as part of the 30-Day-Creative Gathering in February 2024. 







These and other 69 black and white photos are featured in my new book "Night", available here at Lulu.





Friday, October 18, 2024

D.K. Harrell at the Blueseum Fest 2024 in Ruston, LA

On October 12, 2024, D.K. Harrell headlined the Blueseum Fest at Lincoln Parish Museum in Ruston, LA. 












Thursday, October 17, 2024

In Detail - Photos of Details in Every-Day-Life

 As part of the 30-Day-Creative-Gathering in September 2024, I captured every-day-life details in black and white photography. Here are my favorite five photos from this series.









A book, featuring all 34 photos of this series is available here, at Lulu.








Monday, August 12, 2024

Repairing a Steinheil Auto-D-Tele-Quinar 135mm f/2.8 Lens with Exakta Mount

 


The Steinheil Auto-D-Tele Quinar 1:2.8 f/135mm is a super compact tele lens, made in Germany. This piece was made around 1964/65. It has the legendary "Zebra" look, typical for German lenses of that era, and a fantastic build quality. Optically, wide open, it is at least as sharp as the Meyer-Optik Orestor 2.8/135mm (another highly-regarded legendary lens of that era) - but it has only five aperture blades, as compared to the Orestor's 15 blades.


It seems to be rather rare, but you can always find a few on eBay, where they sell, starting from $70. When I got mine, the optics were in great condition, but the focus was rather stiff and the aperture did not close. Both of these issues should be easy to deal with. From about 20-30 lenses that I work on, a non-functioning aperture was always due to oil on the blades and, as it turns out, this was also the case for this pretty piece (see below). 


There is very little information on this lens on the web, and no repair tutorials. But with some experience on other German lenses from that era, I just gave it a try, and I found that it was pretty. I used the following tools:

  • A lens spanner to remove the name plate (one of the first steps), to get access to the front glass element. If that is not needed, you don't need the spanner.
  • Quality screwdrivers
  • Cotton pads plus lighter fluid (for cleaning the aperture blades) and isopropyl alcohol (I use the 91% version) for cleaning the old grease from the focusing helicoids
The following general rules for lens repairs have worked very well for me.
  • In every step, I take pictures and/or draw sketches to remember the orientation of the pieces. For things that you see clearly, a sketch may be more helpful, while pictures also document those details to which you did not pay attention.
  • Immediately after separating a piece, I try to understand how it was connected, and I try to immediately reconnect it again before proceeding further.
  • Whenever I remove a piece, I clean it and all newly accessible surfaces immediately with cotton pads and isopropyl alcohol, so I have not dirty/oily pieces in my storage container. For small part (screws, springs, ball bearings) I use a storage box with dividers.


I start, removing the back piece which is held by these four screws.


This lever on the back piece is responsible for stopping down the aperture (I recommend to play with the stop-down button and the A/M switch on the back piece to understand the mechanism). In this case, I see that this lever works fine. 


The lever sits in the marked slot which can be moved by hand - or with a wooden tooth pick. Doing so, openes and closes the aperture. So, I see that the aperture itself does work - the problem is only that the oily aperture blades have too much resistance, which the lever can't overcome. This was everything on  the back side, now we turn to the front side of the lens.

I recommend to read everything, because you may not need to do some of the first steps - which I only found out later.


To get access to the front glass (and only for that!), the name ring can be removed using a lens spanner. Be careful, since after removing the ring, the front lens will fall out! If you don't need to access the rear of the front glass, don't remove the ring!


The front part of the lens can simply be unscrewed by hand.


These are the pieces from the front that I have so far. At this point, I cleaned the front glass, put it back, and fixed the name ring.


At this point, you get access to the aperture, and you could start cleaning the blades (which I did - but which would be much easier a few steps ahead).


Now, I removed the three screws (but it turned out that loosening them would have done the job).

 

Then the front part can be unscrewed by hand.


Before removing the focus ring, make sure that it is set to a well-defined position - I picked infinity. After loosening the four silver screws it can be removed. 



I made sure, not to rotate the messing piece, before using a screwdriver to make a little scratch (2.), to note the infinity position.
While normal screws have a single entry point, the focusing helicoids have multiple entry points. For the correct reassemble of the lens, it is therefore crucial to remember the correct one (otherwise, you will not get infinity focus). So, in the next steps, it is critical to proceed very slowly, making sure to document when the pieces separate.


When the messing ring is turned counterclockwise (as seen from the front), the black helicoid (which is guided by two "helicoid keys") moves to the right. But only up to the point where the helicoid keys exit the slots - then it will turn together with the messing ring. It is very important to note where exactly this happens. So, I turn the messing ring very slowly - and take this photo, exactly at the point where the black helicoid piece exits the helicoid keys (the keys can be seen from the back side). For my lens, this happens, when my mark on the messing ring is between the "16" and "22" on the DOF scale.


Then, I hold the messing ring, and turn the black helicoid clockwise (as seen from the front), and note where exactly it exits. 


It exitsa after almost half of a turn, and it turns out that somebody else has already marked this position: It exits exactly when the slot, marked with an "X" is at the place where the messing ring has another scratch. If your lens does not have marks like that, make some (and make sure that you will later not confuse the two slots)!


The black piece actually consists of two pieces (which I discovered accidentally). By pressing on the left side...


...the two pieces separate. Now, the  helicoid and the aperture can be cleaned separately.


I am not a big fan of disassembling apertures, and whenever possible, I try to get away with cleaning the aperture in place. For this, I use the cotton swabs soaked in Zippo lighter fluid and move them, following the orientation of the aperture blades - in this case: clockwise. After moving the soaked swab in circles, wetting the blades, I use the aperture lever to open and close the blades, so that the fluid reaches all the internal parts.


To clean the aperture, it is very important to discard the dirty cotton swabs and repeat this over and over, until no more dirt is visible on the cotton swabs (the picture shows just a fraction of the cotton swabs that I used for this lens). As you proceed, you may notice that the aperture lever moves with less and less resistance.


I turn the messing ring back to where it was at infinity when I made the mark (approximately half a turn clockwise, as seen from the front). From there, I first turn it clockwise to see how far it can be turned before it stops (just to have a reference for later). This happens after approx. half a turn.


Then I rotate it back to the infinity position, from where I turn it clockwise until it exits. For my lens, this happens after about 12 1/3 turns.


I have no pictures of cleaning both of the helicoids. Just a few words: I start removing the big chunks of old grease with wipes or cotton swabs - and then use the cotton swabs with lighter fluid to clean them really well.


Here are all pieces of the lens as far as I disassembled them (except for the screws), everything nice and clean!



When putting the aperture piece into the helicoid, the little metal pin (yellow arrow) needs to sit in the slot.


First, the messing piece is lubed and inserted into the piece with the aperture ring. I am very carefully applying the helicoid grease. If you find that it has to much resistance, better remove some of the grease. I removed and inserted the messing piece multiple times before I was happy with the amount of grease and the way that it rotates. Then the black helicoid piece is lubed and inserted into the messing piece (again, iterating this until the amount of grease seems right) - while inserting this piece, make sure the aperture ring is set to 32 (it took me a while to figure out why the helicoid could not be inserted, until I found that it hit a piece from the aperture ring). For both helicoids, starting from the point where it exited, and back to the original position. The black helicoid is inserted and rotated back to where it started to turn freely (see above). At that point you should look through the back of the  lens to ensure that its slots align exactly with the helicoid keys. Then, carefully turning the messing  ring will cause the slots to "catch" the helicoid keys, and it will start to move back and forth when turning the messing ring.
 

After the helicoids are back in place, I reassembled the focus ring (make sure that the scratch mark is at infinity, and aligned with the ring's scale).


Screw in the next piece, and fasten the three screws.


After inserting the front glass element, the front of the lens is complete.


Reassemble the back piece such that the lever sits inside the slot.


And that's it. Quickly check that the aperture works (in "A" position it should close when pressing the silver stop-down button; and in the "M" position, the aperture should follow the value set on the aperture ring). Mine did! And it is great to see the beautiful lens with a working aperture and a smooth focus ring, looking forward to new photographic adventures!


More of my lens repair tutorials can be found here.