Median stacking in the Darktable - noise reduction

How could I perform median stacking images with Darktable? I search for the script for a simple straight solution for this.

Let’s say capture the beautiful night scene of the city on a phone and stack raw files to get excellent clean, noise-free images. I know Photoshop can do that, but I looking for open source solution running well under Linux.

DT wont do it … Likely GIMP will or you can use one or two LUA scripts that will invoke enfuse or hugin and likely there you can manage that. I don’t do it so I don’t have hands on experience…you may get a better answer but you can’t do it natively in DT.

I would go for the HDR feature in darktable, if you have the camera mounted on a tripod.

GIMP is the answer if you want noise reduction. Simply open the images as a stack and for three images set the top two layers to 33% opacity and bottom layer to 100%. For five images set the opacity of top four layers to 20% and bottom layer to 100%.

I have personally given up on this technique as DT is so good at handling noise from even a single shot.

DT’s strength is not handling multiple images. Even PS will not do this with RAW files which is DT’s main focus. Respectfully, use the right tool for the job which is GIMP.

1 Like

You may be able to do it using Lua, taking one of the other scripts as an example.
The required ImageMagick command can be found in
https://patdavid.net/2013/05/noise-removal-in-photos-with-median_6/

Edit: actually, it seems there’s already a script by @wpferguson:

Docs for the script:
https://darktable-org.github.io/luadocs/lua.scripts.manual/scripts/contrib/image_stack/

2 Likes

That looks like a nice script and will let the OP get the median blending that they were asking for…

Thank you guys, then I look on something else than Darktable.

We told you it is available as a plugin (Lua script). We can help you get it installed (it can be done from within darktable, from the user insurance, no magic is involved).

I for one may take you up on this offer. I have not yet mastered lua scripts and have only used a couple of the built in scripts. What the OP wants to do I have done with GIMP, but it would be nice to do this in DT. I will make time to test it out and call out for help if needed. Lua scripts can be daunting to people who have grown up in a Windows world like me.

I also wish I could do nice exposure merging in DT. I still depend upon Adobe’s Lightroom for this. LR can align hand-held images and even remove people walking across the scene. That is one nice trick in LR. But at the end of 2023 Adobe will no longer provide a download link for my perpetual LR6 licence so I may lose that capability one day.

You can still download and archive LR, right?

Note: I don’t use Lua, but went through the installation process to write this.

To get the scripts:
https://darktable-org.github.io/luadocs/lua.scripts.manual/installation/

  1. Get git for your OS (how: read the docs linked above)
  2. Enable the script manager, and install scripts:
    image
  3. You’ll see many console windows popping up for a few moments, don’t be scared. Just wait until it’s over.
  4. Make sure action = start/stop scripts is selected with category = contrib, and switch (arrow keys) to the page of the desired script:
    image
    image
  5. Click the desired script, so it starts. You’ll see:
    image
  6. Select your images, then in the lighttable’s export module, select target storage = image stack, set the executables (you’ll have to get two tools, see darktable lua documentation - image_stack). You’ll need to set the paths to the executables only once.
    image
  7. Set the other params as desired. See the script’s docs for details: darktable lua documentation - image_stack.
1 Like

I would recommend anyone with perpetual licences for Adobe products to download and safely store a version of the install files because after december 31 they may not be available. They won’t from Adobe and Adobe may prevent archival storage sites on the internet storing them if they really want to force everyone to pay a subscription. I only found this issue out about downloading because my Windows computer died and I had to download the Master Collection of Adobe programs and LR6. The Adobe online help was excellent and provided all the links I needed but confirmed download support would cease at the end of the year.

And thanks for the good info in your reply.

Thank you, finally, you gave me a truly nice answer with proper instructions. I’ll try that!

I don’t use Lua scripts very much, but the few I tend to use (EnfuseAdvanced and export scripts to Gimp and Hugin) always work as they should. Now I wanted to try the Image Stack script, but I run into a few problems. I have Imagemagick and Align_Image_Stack installed. When I export images with target storage “image stack”, I get an error message saying “ERROR: Convert executable not found”. A bit weird, as Imagemagick and Align_Image_stack should be the only dependencies, and I have those. I can’t find that I have anything called Convert, though.
Then I found this thread, and especially @kofa 's reply here:

In this screenshot, there is the section “select executable(s)”. As you can see below, I don’t have this:
Image stack

Any ideas on how to solve this?
Darktable version is 4.2.1 from OBS, Linux Mint.

Morrn, @hpbirkeland!

I may be on thin ice here, but let’s try anyway :slight_smile:
in darktable/preferences/Lua options do you have set any executable for GMic CLI?

Have fun!
Claes i Lund, Sverige

No, there is nothing about GMic CLI in Lua options.

So I dug a bit deeper on my own and found out I had to install two extra packages, imagemagick-6.q16 and imagemagick-6.q16hdri.

It’s working now, but I still don’t have the “select executable(s)” section. Maybe that’s a Windows thing?

1 Like

convert is one of the ImageMagick commands:

kofa@eagle:~/bin$ which convert
/usr/bin/convert
kofa@eagle:~/bin$ ls -l /etc/alternatives/convert
lrwxrwxrwx 1 root root 24 Jul 28  2022 /etc/alternatives/convert -> /usr/bin/convert-im6.q16
kofa@eagle:~/bin$ convert --version
Version: ImageMagick 6.9.11-60 Q16 x86_64 2021-01-25 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP(4.5) 
Delegates (built-in): bzlib djvu fftw fontconfig freetype heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png tiff webp wmf x xml zlib

Yes, so it’s a bit strange that a normal installation of imagemagick does not include convert, but certainly not a darktable problem, so no point in complaining here😀

It should include convert.exe, but it won’t be on your windows path.

G’MIC has a median blending mode - I remember reading an article by Pat David on its use for noise reduction.

If blending in GIMP (using Normal mode), the percentage opacities should be set to: 100/n for the top layer, 100/n-1 for the second layer, 100/n-2 for the third layer, and so on. Where “n” is the number of layers. The bottom layer will obviously be at 100% opacity.