Using LensFun distortion correction info in RT

Hello,

I’m trying to understand how to map the distortion correction values available in LensFun database to RT’'s slider.

For example, the distortion of the Olympus lens M.Zuiko Digital ED 9-18mm f/4.0-5.6 at 9mm is described in LensFun database as follows:
> distortion model=“ptlens” focal=“9” a="-0.00243" b="-0.05248" c=“0.0576”

Does anyone know how the a-b-c values should be mapped to the scale of [-0.5,+0.5] available in RT’s user interface?

Thanks.

I think it’s not that easy and often not possible.

I saw in the old forum many request about integrating lensfun in rawtherapee, what about a kickstarter project to try to finally make it possible?

yeah, I know about the current activity on this topic (issue 2543) but it seems to be standing still. I don’t have the knowledge to contribute to it so I’m looking for a workaround and thought I could manually map the values from LensFun for the specific set of lenses that I have.

LCPs use a, b, and c distortion coefficients, so you can hack your own LCP in a text editor.

Thanks for the suggestion. I tried this and it seems like some conversion needs to be applied from LensFun’s coefficients to LCP’s. This is what I did:

  1. Selected a file captured with the said Olympus lens at 9mm.

  2. Downloaded an LCP profile using Adobe’s downloading tool.

  3. Opened RT and applied the profile.

  4. Correction looks good, and very similar to the result of the Auto Distortion Correction.

  5. Removed and cleaned unnecessary parts from the LCP profile and verified that the output of RT is still good. I ended up with a profile having (for a focal length of 9mm):

              <stCamera:PerspectiveModel rdf:parseType="Resource">
                 <stCamera:Version>2</stCamera:Version>
                 <stCamera:FocalLengthX>0.5</stCamera:FocalLengthX>
                 <stCamera:FocalLengthY>0.5</stCamera:FocalLengthY>
                 <stCamera:ImageXCenter>0.5</stCamera:ImageXCenter>
                 <stCamera:ImageYCenter>0.5</stCamera:ImageYCenter>
                 <stCamera:RadialDistortParam1>-0.015393</stCamera:RadialDistortParam1>
                 <stCamera:RadialDistortParam2>-0.008221</stCamera:RadialDistortParam2>
                 <stCamera:RadialDistortParam3>0.000662</stCamera:RadialDistortParam3>
              </stCamera:PerspectiveModel>
  1. Opened LensFun database and found the following values, which are very different than the values in the elements stCamera:RadialDistortParam1-2-3 in the downloaded LCP file.

distortion model=“ptlens” focal=“9” a=“-0.00243” b=“-0.05248” c=“0.0576”

  1. Duplicated the LCP file and set the coefficients according to LensFun.

  2. Applied it to my image in RT and indeed the correction is incorrect.

So it looks like some conversion needs to be done when coping LensFun’s a-b-c coefficients to an LCP file.

Does anyone know what this conversion might be?

Thanks.

Attachments:

The LCP profile as downloaded, after cleaning, and after updating coefficients according to lensfun a-b-c values.

Olympus 9-18 - v1 - downloaded.txt (18.6 KB)

Olympus 9-18 - v2 - cleaned.txt (1.9 KB)

Olympus 9-18 - v3 - lensfun.txt (1.9 KB)

RAW file: link

The image before correction:

After correction by the cleaned LCP file (good result):

After correction by the LCP file with lensfun a-b-c values as-is (bad result):

@TooWaBoo manually made LCPs for the Samyang 8mm, perhaps he can offer some advice.

@assaft why don’t you just make a proper LCP for your lens/camera? LCPs are capable of more accurate distortion correction than using just three single distortion coefficients.
http://rawpedia.rawtherapee.com/How_to_get_LCP_and_DCP_profiles#Make_your_own_using_Adobe_Lens_Profile_Creator

The photo you’re using is not the best kind of shot for checking lens distortion correction. Take a photo of a flat surface with long straight horizontal and diagonal lines, for example a large brick wall, that makes seeing anomalies easier.

1 Like

I tried to avoid creating the profiles myself, as I’m a little afraid of screwing up something. But I decided to give it a try.

I’d like to ask for a clarification about one point from the guidelines. These are two instructions given in the file:

  1. For prime lenses, shoot at (1 × minimum focus distance) and (5 × minimum
    focus distance) focus distance positions.

  2. Distance the camera so that the chart fits within the image frame. The entire
    checkerboard pattern must fit within the image frame and be completely
    unclipped in the captured image.

The problem is that if I’m using an A3 chart and profiling a 50mm lens, shooting such that the full checkerboard is covered means that I can’t shoot at the minimum focus distance (e.g. 20cm), as this will result in the board being out of focus). I assume that the board shouldn’t be out of focus, so is that means that I have to use a relatively small board for normal-long lenses?

Thanks.

I see your dilemma. How about trying with what they call “Landscape Letter” under the heading Procedures/Printing the Calibration Chart?

Don’t sweat it, those are guidelines not absolute requirements. The image must be sharp, the chart must be evenly lit and needs to fill the frame, either as one shot or as a series of shots where you move the chart. The rest is not as important. If you can’t see the whole chart at your lens’s minimal focus distance, print a smaller (or larger) chart and step back (or closer). Don’t worry that you’re not shooting at exactly the minimal focus distance, it’s not that important.