Why do some tiffs display apparent lens distortion? darktable 3.6.0, Win 10

This situation is intriguing: in a Windows environment I imported a triad of bracketed raw (.CR2) photos from a lens/camera combination that darktable (3.6.0) recognises and created an HDR image therefrom – all straightforward, aside from the HDR being ‘ordinary’ in brilliance and chroma. For comparison I imported those same three raw images into Photomatix in stand-alone mode (i.e. not using it as a LightRoom plug-in). It produced a most attractive combined image but with considerable barrel type distortion. I assumed this was because it does not ‘understand’ the lens/camera optics, relying on LightRoom to provide that correction when processing raw images. So I exported the three raw files as 16 bit tiffs from darktable after ensuring that dt had applied its default lens correction. and re-ran Photomatix.

The output tiff from Photomatix now showed no barrel distortion, when viewed in any other image viewer, while the input .CR2 raw files do show distortion IF the viewer did not have suitable lens correction built-in (e.g. no distortion in FastStone or XnView; distortion in Picture Window Pro 64 and in Windows Photos app). So, nothing really unexpected there.

But what is really unexpected is that the tiffs which I produced as exports from darktable, and that produced by Photomatix do show considerable barrel distortion when imported back into darktable and viewed there in lighttable, but show no distortion when viewed in any external viewer… What is happening here?

(Later)
I now find that any .cr2 image experted from dt 3.6.0 as a 16 bit tiff, and then re-imported shows obvious barrel distortion. Since it is consistent, I have to assume it is expected behaviour; how then do I correct it, since applying the dt lens correction module to the tiff has no effect.

Can you attach some screenshots?

I hope these suffice:
First screenshot shows file view with (among others) the three original .cr2 images and their exported-re-imported tiffs with distortion
Second screen shot is of one of the .cr2 images in lighttable full screen mode, showing no distortion
Third screen shot is of the same image in its re-imported tiff version, showing distortion
Fourth screen shot is of this same tiff viewed with Win Photos app, showing no distortion




If you never opened the cr2 file in darkroom you see the embedded jpg. This can have some lens corrections applied out of cam. So exporting from darktable just exports based on the raw and there might be the correction. To validate this assumption the original cr2 file is needed

I was not aware of this. In the attached screen shot I show, on the right end of the top row, the original tiff of the exported .cr2 image, which .cr2 was possibly never opened in darkroom. At the left hand end of the second row I show a tiff created from the same .cr2 file, but cropped, as you see in the middle image of the top row (no other darkroom action), exported as tiff and re-imported. It is still distorted.

Well maybe apply the lens correction module? that will use lensfun to apply the correction. (if your lens is supported)

Yeah, that’s what I thought, but I have set dt to automatically apply lens correction for that specific lens. I am assuming that this automatic action takes place when the image is first opened in lighttable, at least, but certainly when opened in darkroom. So that correction has already been applied before I exported that cropped version - hasn’t it?

(Later). OK I have now confirmed that explicitly activating and applying the lens correction module to the (cropped) .cr2, exporting as tiff and re-importing shows a distorted tiff identical to the previous exported/re-imported tiff (so no snapshot taken).

Some days after my original posting, essentially asking “what is happening here?”, I am a little surprised to find there is no substantive answer to what I feel is a significant issue and from what, in my experience to date, is the definitive source of detailed guidance on darktable.

Is this situation because a:) the problem is not significant?, b:) I didn’t explain it well?, c:) I’m a stupid dork whose bleating (as evidenced by previous posts) is best ignored?

Could you perhaps share one of the exported tiff files that look OK in viewers but bad in darktable?

Most certainly; how should I do that so that the file is not changed in anyway before interested parties cam download it ?

You should be able to use the upload icon in the forum.

This is one example of an image exported from dt as a .tif that then appears distorted in dt, when re-imported, but not distorted in Win Photos application:

20210706_HIW-Tours-9R_0963_01.tif (84.3 MB)

I think I see some distortion in Windows Photos, but not in Paint 3D (another built-in Windows app) → Windows Photos is the culprit?
Viewed 100% (both in Photos and darktable), I was able to align the corners without issues. Maybe the zoom of Photos causes distortions?

Sorry, I’m not understanding what you are saying. What I see is:

  1. Windows Photos, zoomed to what I guess to be about 100%: no distortion apparent to me. The fence rail in the immediate foreground is, in reality, slightly warped at the extreme left hand end but ‘straight’ elsewhere. This is shown accurately, in my judgment.
  2. FastStone Image Viewer, at 100% (explicitly set in FastStone): appearance is identical to Windows Photos, as best as I can judge by eye. No distortion.
  3. darktable, in darkroom, zoom set to 100%,: gross distortion in the whole length of the fence rail in the immediate foreground - it now appears curved, like an arch, just as shown earlier (but at a much lower magnification) in the screen shots.

There is no connection of the zoomed state of Windows Photos to the appearance of the image in darktable. Thus, it is there, in darktable, that there is something going on and I would like to know what is happening.

Sorry, maybe I made a mistake. I’ll sit down in the evening, and carefully check this again. I’ll make screenshots of the TIFF displayed in Windows Photos and also in darktable, resize the screenshots to the same width, and overlay the two.
A quick shot of what I see in Windows, darktable 3.6.0:


Where I stand in the history makes no difference (tried that, too).
BTW, could you check what modules you have active in darktable with the TIFF loaded? You collapsed the sidebars in your screenshot.
To double check: the TIFF file is 88’438’304 bytes in size - is that correct?

I think you have lens correction enabled for the TIFF file! That gives me a distorted picture as well. But darktable has already corrected it for the raw file, so you’re now you’re overcompensating:

Just to make sure, you don’t apply lens correction on raw and on the tiff again via a preset you defined?

Yes, I’m positive that was the mistake that @LateJunction made. Anthony, you should make the lens-correction module’s preset auto-apply only to raw images.

This should have been suspicious:

after ensuring that dt had applied its default lens correction

It is not applied by default, as far as I know; I had to create my own preset for that – note that normal images is unchecked.

That was total bollocks, sorry. I was simply unable to align the images correctly. But now we know what the problem was: an overly eager lens correction preset. Please uncheck normal images and save; disable the module for any images where it’s already applied but not needed.

Gentlemen, as I opined: “the definitive place to get guidance” (or words to that effect): you have just proved my opinion to be appropriate - thank you !.

Thanks also for the clarification about default application of the lens preset. I have now corrected that assumption in my workflow and specified ‘raw’ images only for that particular lens.

An ancillary question if I may:

Do I need a preset for a camera/lens combination that is known to dt - by which I mean that dt understands what correction needs to be applied for the camera/lens combination it finds in the EXIF data? Or is it that I have to create the preset, and edit it suitably, for that correction to be automatically applied to that combination of ‘hardware’ and image format? The automatic application doesn’t seem to happen in cases where I have not specified a preset.