Fixing barrel distortion in darktable

Sometimes images have barrel distortion and the lens correction module can not be used. Currently I am having to export the affected images to GIMP and then I use the lens correction option in GIMP which facilitates pin-cushion and barrel distortion fixes using a slider option. Is a similar option available in Darktable and I have just missed it?

1 Like

Do you mean no lens match?? I think the best you can do is try to manually select one that is as close as possible and see how it fairs… not sure beyond that …

Thanks Todd. Some images have barrel distortion and just selecting a lens and hoping it will work is not as good as the controllable fix in GIMP. I wonder if the GIMP filter could be adapted to DT?

There are instructions on how to make a profile for your lens. I think there used to be a nice blog post about it…

2 Likes

Thanks Todd. Making a profile wouldn’t work as the current image that triggered this question is a panorama stitched image with significant distortion. GIMP corrected about 80+% of the problem which made the image acceptable. It would be nice to be able to do this in DT, but it might be a big ask if others don’t see the need for this option.

Strictly speaking, you cannot get a panorama without distortion. You are projection a sphere on a plane, after all. You can use different projections to get the most acceptable distortion (see Hugin), but that’s it. The amount of distortion also depends on the angles of view (hor. and vert.). So all you can do is decide on the type of distortion you want.

I’m not sure if the kind of distortions you get are comparable to the lens barrel or pincushion distortion (i.e. if they fit within the models used within dt lens correction). Your limited success with the GIMP might point in that direction.


As an aside, it might have been useful to mention the stitched panorama part in your original question, as it may have a large influence on the final image: quite a lot has been done already to the image, so we don’t even know if the final distortion is just due to the panorama projection, or if the lens distortion was still present in the stiched images.

3 Likes

I thought I would include an example here of the type of problem I am referring to and how GIMP has improved the image. I feel that DT offers manual vignetting correction in the lens module and offering manual distortion sliders could be a bonus. We might even want to add distortion for artistic effect.
image
image

I would appreciate an option to apply kind of a manual lens correction too. I take pictures with many different vintage manual lenses and an adapter. For all those lenses there are no profiles available. I would prefer to have an option to manually correct barrel or cushion distortions instead of having to create profiles for each lens.

There is a fairly good basic correction algorithm is rt, we could use that without problems, just a) someone interested must do it and b) we wouldn’t want to make the lens module becoming bigger & bigger …

2 Likes

You can trythe rotate and perspective module in manual mode. But results in GIMP might still be better.

c21a8488f36faa407e74b940e6eed3a5e4721989
c21a8488f36faa407e74b940e6eed3a5e4721989.jpeg.xmp (3.8 KB)

What program have You used to stitch the panorama? Hugin?
I always use the stitching program to correct those distortions in a pano. But obviously, workflows are different from person to person, so maybe that’s not practicable for you, even so it feels most natural to me.

I will have a look at it and try to motivate my son to contribute to darktable :wink:. He’s a developer.

2 Likes

Normally I can correct the curvature distortion in the panorama stitching program. I mainly use Microsoft’s ICE but occasionally Hugin. But this image was challenging from the word go as I was in a very tight, narrow alleyway in a medina and wanted to capture some of the vertical view and my wide angle lens just wasn’t wide enough. When it was stitched together the options for correction of curvature was greyed out because of the method chosen automatically by ICE to stitch these challenging images.

@hannoschwalm I appreciate that all improvements require effort and the developers have to prioritize their valuable time. Going out to GIMP is not a deal breaker for me, but I do see value in bringing in the feature from RT. Maybe @Roland_Rainer can talk his son into it. When I retire, I might try and get my head around writing code so that I could do rather than just ask for improvements.