Lens correction profiles - marcapelini/RTProfileSelector GitHub Wiki

Besides selecting a custom processing profile based on Exif fields, RTProfileSelector has the ability to also automatically apply a distortion correction amount for a given lens and focal length. This is done by RTPS as the last step after assigning a processing profile. RawTherapee already has support for real lens profiles (Adobe lens correction profiles), and hopefully will soon be able to use LensFun lens calibration profiles as well. However, if all you need is some crude form of distortion correction "profiles" that you can easily create yourself, for your own lenses and cameras, and that are automatically applied the first time you open a photograph in RawTherapee, RTPS ini-based lens profiles may fit the bill.


So, how do you create your own simple distortion profile files? First you need to shoot a number of test photos covering a range of focal lengths with a given zoom lens (if you're profiling a prime lens, of course you will need only one photo!).

  • Your subject must be at a reasonable distance ("infinity") from the camera
  • The subject must have both horizontal and vertical lines, especially near the edges of the frame, so that you can use these lines as guides to be sure the amount of correction applied properly corrects a particular photo
  • The photos must cover the whole range of focal lengths of your lens (that is just one photo for a prime, of course). The more intermediate focal length samples you have, the greater the precision you will achieve in your final profile. Be sure you have sample photos for both ends of a zoom lens, which typically are the ones with the greatest distortion levels.

Lets take as an example the Panasonic 12-32mm F3.5-5.6, which is a small Micro 4/3 lens which I have and love, but which has some pretty strong barrel distortion at the wider focal lengths.

  • Open your test photos in RawTherapee. They will initially have no distortion correction applied:

  • For each test image, adjust the distortion correction amount as best as you can and take note of both the focal length and the amount of correction. If you like, start by clicking the "Auto Distortion Correction" button, which may help you get ballpark values. In my experience, some fine adjustment is often needed after the auto correction.

  • Under the "Lens Profiles" folder, create a file named lens.LENS ID.ini, where LENS ID is the value for the Exif field "Lens ID", or, in the case of a fixed-lens camera (such as a compact camera), the "Camera Model Name". Remember that you can get these values by enabling the ViewExifKeys entry in RTPS's configuration file.

Here is my lens distortion profile for the 12-32mm lens. Notice that the keys are the focal lengths from my test shots, and the values are the amount of distortion correction that I had to apply:

My profile above ended up with 12 different entries, each with the amount that I though would best correct the distortion levels I was seeing at the given focal length. There's no need to shoot as many photos as I did, but the more samples you have, the more accurate the correction will be. RTPS will interpolate over any missing focal lengths, so, if I happen to shoot a photo at 19mm (which is not listed in the profile above), RTPS will calculate the amount to be applied as "-0.050".

That's all there is to it! Now every time I open a photo taken with the 12-32mm lens, at any focal length (not just the ones in the profile), the distortion correction amount in RT will be automatically assigned a value to correct the lens intrinsic distortion.

By the way, notice that in the image above there's also a file named "lens.DML-LX5.ini". This is my profile for the Panasonic LX-5, a lovely compact camera that I had. Since it was a fixed-lens camera, there was no "Lens ID" Exif field that I could use. When the "Lens ID" is missing in the Exif, RTPS will assume the photo was taken with a fixed-lens camera, and will look for a profile named "lens.Camera Model Name.ini".


Previous page: ISO Profiles