A script to merge several DNG files into one (digital ND filter, HDR tool, noise reducer)

On my Fuji (which has a Sony sensor), I found it is best to shoot in the lowest ISO possible (200), stacking 16 ISO 800 is worse than 4 ISO 200.
That shouldn't be the case, especially if those two ISO settings have different conversion gains, which would give less pre-gain read noise in the 16 ISO 800 images. Any non-fixed post-gain read noise should be weaker in the 16 ISO 800 RAWs.
 
That shouldn't be the case, especially if those two ISO settings have different conversion gains, which would give less pre-gain read noise in the 16 ISO 800 images. Any non-fixed post-gain read noise should be weaker in the 16 ISO 800 RAWs.
It did not really seem logical to me either, but that's what I observed.
 
  • Why do high-end cameras not do this out of the box? Is this not a very straightformward way to improve the capabilities of a camera?
IIRC Canons starting from 5DM3 can do multiexposure stacking, with average, median, min and max filtering, with one raw file as result so it can be used in PP-less competitions.
Why? There is negligible user demand for this feature. If it exists already and you don't know about it, then even less tech savvy people won't.
You are right.

Canon seems to offer this feature on their high-end cameras. Not sure how easy it would be to make them stack 20 pictures in a row. It does not seem like they offer this easy feature on cheaper cameras.

https://support.usa.canon.com/kb/index?page=content&id=ART170176&cat=8035B&actp=LIST

I believe Olympus has this as well on high-end cameras.

With mean stacking, you can get awesome quality even out of very bad and small sensors (I tested the iPhone 7), so it is very useful to have this on lower-end cameras as well.

I use a Fuji X-T2, I only have JPEG multi exposure stacking. For me this feature is very useful.
Sony implemented this as well in their PlayMemories Smooth Reflection App, which supports an arbitrarily-large number of frames and generates a single raw output. Unfortunately Sony removed support for their app ecosystem in the most recent generations of their cameras.
I think this is not smart decision from Sony. Computational photography is disrupting the photo business. Pretty sure in the future, that features which are mostly software (like smartphone bokeh effects) will play a bigger role for professional photographers in the not-so-far future. They should open up their cameras for app developers just like smartphones are open.
 
  • Why do high-end cameras not do this out of the box? Is this not a very straightformward way to improve the capabilities of a camera?
IIRC Canons starting from 5DM3 can do multiexposure stacking, with average, median, min and max filtering, with one raw file as result so it can be used in PP-less competitions.
Why? There is negligible user demand for this feature. If it exists already and you don't know about it, then even less tech savvy people won't.
You are right.

Canon seems to offer this feature on their high-end cameras. Not sure how easy it would be to make them stack 20 pictures in a row. It does not seem like they offer this easy feature on cheaper cameras.

https://support.usa.canon.com/kb/index?page=content&id=ART170176&cat=8035B&actp=LIST

I believe Olympus has this as well on high-end cameras.

With mean stacking, you can get awesome quality even out of very bad and small sensors (I tested the iPhone 7), so it is very useful to have this on lower-end cameras as well.

I use a Fuji X-T2, I only have JPEG multi exposure stacking. For me this feature is very useful.
Sony implemented this as well in their PlayMemories Smooth Reflection App, which supports an arbitrarily-large number of frames and generates a single raw output. Unfortunately Sony removed support for their app ecosystem in the most recent generations of their cameras.
I think this is not smart decision from Sony. Computational photography is disrupting the photo business. Pretty sure in the future, that features which are mostly software (like smartphone bokeh effects) will play a bigger role for professional photographers in the not-so-far future. They should open up their cameras for app developers just like smartphones are open.
I asked a Sony USA rep about this at a trade show and he said Sony removed PlayMemories app support because there wasn't enough demand to justify ongoing development/support.
 
Hello,

I had thought about such a tool using imagemagick provided it does align the images, which imagemagick can do I guess.

Otherwise, this would have very iittle benefit for me, i can stack easily with good results !
Yes, stacking the mosaic raws should give you quite similar results as stacking the processed JPGs. Mosaic raw stacking should be slightly better quality and it might save you some time and some disk space if you want to be able to edit non-destructively later. But yes, this tool has very limited functionality.
So this would have great benefit for handheld shots.
You are very right.

Stacking tripod shots is nice; you can get insane quality from a mediocre sensor or to simulate an ND filter.

Stacking handheld shots is even more useful because you don't need to bring that stupid tripod.
But there is more.... much more (imho) !!!

Only stack automatically the images which are the sharpest. Again this is usefull for handheld shots.

This would mean:

1: align the pictures

2: divide the image in areas and compare for instance rhe contrast between the different images, you will easily detect the images which are blurry (due to camera shake).

3: stack only the sharp images

Your tool would be much more usefull, just my opinion.

Precisions for point 2: why dividing in areas ? Because for instance an object may enter in the scene , changing the global contrast. So if you see over 10 areas, 8 ar sharper and 2 are not, you can consider that the image is sharper than the other image. This is just to give the main idea.
I did some research; There is free software that seems to do what you are suggesting, one would only have to connect the dots using a small script.

dng_validate from Adobe's DNG SDK can generate demosaic RGBs in the camera's native color space

align_image_stack from Hugin/panotools could align these pictures

enfuse/enblend from Hugin could stack them up, and they can be weighted according to exposure, sharpness, etc.

Exiftool can manage all the necessary tags to make a DNG from the stacked TIFs.

If I find some time, I will try to do this. It seems really interesting.
 
https://drive.google.com/open?id=1yYAq_KV2ZeKYVOENfvQSIs0k-0R5FM5f

6D and it's own stacker + the DNG stacker from the script here.

6D is able to merge 9 images but it slows down the burst rate a lot.
Seems like there is no visible difference. I would advise to use the internal stacker of the 6D because it's less effort and the file size is slightly slower.



dng_stacker, cropped and clarity increased in Lightroom to make noise more visible
dng_stacker, cropped and clarity increased in Lightroom to make noise more visible



Canon 6d, cropped and clarity increased in Lightroom to make noise more visible
Canon 6d, cropped and clarity increased in Lightroom to make noise more visible
 
fyi, you might want to use hugin_stacker instead of imagemagick for stacking as it's about an order of magnitude faster.
 
  • Why do high-end cameras not do this out of the box? Is this not a very straightformward way to improve the capabilities of a camera?
IIRC Canons starting from 5DM3 can do multiexposure stacking, with average, median, min and max filtering, with one raw file as result so it can be used in PP-less competitions.
Why? There is negligible user demand for this feature. If it exists already and you don't know about it, then even less tech savvy people won't.
While the Canon's do have a multiple exposure, the resulting file is not a raw file any longer.

I tested out the feature myself and discovered Canon's implementation bake in the white balance and clip whites, so Anton's script actually is better in the sense it retains the full flexibility of working with true bayer data.
 
Last edited:
Hi Anton,

I find this a good idea. Being myself a software developer and passionate about photography, I've thought about writing a frame averaging software a lot of time, but I didn't find the time to do so.

The best digital camera ever made, the Phase One IQ4 medium format platform, now implements this feature on the camera. It averages many RAW files into a single one. Some links:

https://www.dtcommercialphoto.com/the-phase-one-iq4-now-has-automatic-frame-averaging/

https://captureintegration.com/phase-one-iq4-long-awaited-frame-averaging-nearly-available/

Key points for me are:
  • It must work on RAW data without changing anything else.
  • It must produce a single lightweight RAW file to be further worked as usual.
This is exactly what Phase One did, and what you also achieved if I understand well.

Frame alignment is not so important in this use case in my modest opinion. This is more a technique to be used when on a tripod and without moving subjects (with the exception of water). Of course with frame alignment one could extend the potential use cases...

The important results achieved are:
  • Avoid using ND filters (they often lower the IQ of the image) but having the same final "long exposure" effect.
  • Lowering the noise a lot.
I will give a try.

Thanks for spending your time on this and for sharing your solution.

Regards,
marco

--
http://photography.marcoristuccia.com
 
Last edited:
  • Why do high-end cameras not do this out of the box? Is this not a very straightformward way to improve the capabilities of a camera?
IIRC Canons starting from 5DM3 can do multiexposure stacking, with average, median, min and max filtering, with one raw file as result so it can be used in PP-less competitions.
Why? There is negligible user demand for this feature. If it exists already and you don't know about it, then even less tech savvy people won't.
While the Canon's do have a multiple exposure, the resulting file is not a raw file any longer.

I tested out the feature myself and discovered Canon's implementation bake in the white balance and clip whites, so Anton's script actually is better in the sense it retains the full flexibility of working with true bayer data.
Checked with Hraw and highlight clipping.

Single file
Single file

Stacked in Canon
Stacked in Canon

With white balance on (Canon stacked has already white balance baked in) I don't find any difference.

Single file
Single file

Stacked in Canon
Stacked in Canon
 
Last edited:
  • Why do high-end cameras not do this out of the box? Is this not a very straightformward way to improve the capabilities of a camera?
IIRC Canons starting from 5DM3 can do multiexposure stacking, with average, median, min and max filtering, with one raw file as result so it can be used in PP-less competitions.
Why? There is negligible user demand for this feature. If it exists already and you don't know about it, then even less tech savvy people won't.
While the Canon's do have a multiple exposure, the resulting file is not a raw file any longer.

I tested out the feature myself and discovered Canon's implementation bake in the white balance and clip whites, so Anton's script actually is better in the sense it retains the full flexibility of working with true bayer data.
Checked with Hraw and highlight clipping.

Single file
Single file

Stacked in Canon
Stacked in Canon

With white balance on (Canon stacked has already white balance baked in) I don't find any difference.

Single file
Single file

Stacked in Canon
Stacked in Canon
I am not sure what your example is showing, if the highlights were blown in raw in a single capture, then a stack's highlights will be blown.

My highlight headroom test consisted of taking a single capture of a static scene in which the highlight started to blow out in the jpeg preview but were recoverable in raw. However the same exact scene captured with the multiple exposure facility set to average created a "raw" file with unrecoverable highlights.

As for white balance, if its baked in, then its no longer a raw.

My conclusion was that Canon's implementation of "raw" multiple exposure for the Canon 5DMIV is flawed, whereas Anton's method resolves issues I've encountered around keeping raw data raw.
 
  • Why do high-end cameras not do this out of the box? Is this not a very straightformward way to improve the capabilities of a camera?
IIRC Canons starting from 5DM3 can do multiexposure stacking, with average, median, min and max filtering, with one raw file as result so it can be used in PP-less competitions.
Why? There is negligible user demand for this feature. If it exists already and you don't know about it, then even less tech savvy people won't.
While the Canon's do have a multiple exposure, the resulting file is not a raw file any longer.

I tested out the feature myself and discovered Canon's implementation bake in the white balance and clip whites, so Anton's script actually is better in the sense it retains the full flexibility of working with true bayer data.
Checked with Hraw and highlight clipping.

Single file
Single file

Stacked in Canon
Stacked in Canon

With white balance on (Canon stacked has already white balance baked in) I don't find any difference.

Single file
Single file

Stacked in Canon
Stacked in Canon
I am not sure what your example is showing, if the highlights were blown in raw in a single capture, then a stack's highlights will be blown.

My highlight headroom test consisted of taking a single capture of a static scene in which the highlight started to blow out in the jpeg preview but were recoverable in raw. However the same exact scene captured with the multiple exposure facility set to average created a "raw" file with unrecoverable highlights.

As for white balance, if its baked in, then its no longer a raw.

My conclusion was that Canon's implementation of "raw" multiple exposure for the Canon 5DMIV is flawed, whereas Anton's method resolves issues I've encountered around keeping raw data raw.
Raw samples?

I can't find any practical difference in the highlights between my two pictures. Hraw shows that the stacked one has more clipped highlights (due to baked in white balance I guess) but when the single raw file has been white balanced in darktable the same amount of highlights are clipped.

Raw samples here https://drive.google.com/open?id=1HTzYT7SLeQrTD-YUoxGhbyX1JhHXbPcq
 
Last edited:
  • Why do high-end cameras not do this out of the box? Is this not a very straightformward way to improve the capabilities of a camera?
IIRC Canons starting from 5DM3 can do multiexposure stacking, with average, median, min and max filtering, with one raw file as result so it can be used in PP-less competitions.
Why? There is negligible user demand for this feature. If it exists already and you don't know about it, then even less tech savvy people won't.
While the Canon's do have a multiple exposure, the resulting file is not a raw file any longer.

I tested out the feature myself and discovered Canon's implementation bake in the white balance and clip whites, so Anton's script actually is better in the sense it retains the full flexibility of working with true bayer data.
Checked with Hraw and highlight clipping.

Single file
Single file

Stacked in Canon
Stacked in Canon

With white balance on (Canon stacked has already white balance baked in) I don't find any difference.

Single file
Single file

Stacked in Canon
Stacked in Canon
I am not sure what your example is showing, if the highlights were blown in raw in a single capture, then a stack's highlights will be blown.

My highlight headroom test consisted of taking a single capture of a static scene in which the highlight started to blow out in the jpeg preview but were recoverable in raw. However the same exact scene captured with the multiple exposure facility set to average created a "raw" file with unrecoverable highlights.

As for white balance, if its baked in, then its no longer a raw.

My conclusion was that Canon's implementation of "raw" multiple exposure for the Canon 5DMIV is flawed, whereas Anton's method resolves issues I've encountered around keeping raw data raw.
Raw samples?

I can't find any practical difference in the highlights between my two pictures. Hraw shows that the stacked one has more clipped highlights (due to baked in white balance I guess) but when the single raw file has been white balanced in darktable the same amount of highlights are clipped.

Raw samples here https://drive.google.com/open?id=1HTzYT7SLeQrTD-YUoxGhbyX1JhHXbPcq
As indicated above it was clipping in JPEG preview, not raw on single capture.

I also noticed if I set white balance to the "wrong" color balance when shot multiple exposure the "raw" stack could not correct white balance suffciently after the fact in lightroom compared to the same scene shot as a single raw exposure.

I cannot account for what you are seeing vs my experience, only as I stated above, the Canon 5dm4 multiple exposures did not behave as raw and I reported the behavior to Canon.

One aside, when you've captured a multiple exposure raw in camera, and go to in camera raw develop to jpeg, is your white balance correction greyed out?
 
Last edited:
As indicated above it was clipping in JPEG preview, not raw on single capture.

I also noticed if I set white balance to the "wrong" color balance when shot multiple exposure the "raw" stack could not correct white balance suffciently after the fact in lightroom compared to the same scene shot as a single raw exposure.

I cannot account for what you are seeing vs my experience, only as I stated above, the Canon 5dm4 multiple exposures did not behave as raw and I reported the behavior to Canon.

One aside, when you've captured a multiple exposure raw in camera, and go to in camera raw develop to jpeg, is your white balance correction greyed out?
I understand the stacked one is not "raw" due to the baked WB. The DNG script is a better choice to get the real thing and to stack more than 9 raw files. But in some cases it is easier for me to stack the raw files in camera than to load the raw files into Ubuntu, move them to VirtualBox and Windows 10, convert them and then move them back to Ubuntu again. My 7D or M5 don't have the in camera stacking feature so if I use them and want stacked raw files I will use the DNG script. The in camera stacking with 6D is also way slower than the normal burst rate.

Anyway, I never tried "wrong" colour white balance so I had to try. 10 000 Kelvin in camera and stacked vs single raw file. Exported to jpeg in both RawTherapee and both darktable. I found darktable easier. In both RawTherapee and darktable I had to pick Spot WB.

Sample raw files + jpeg files from RawTherapee and darktable https://drive.google.com/open?id=1cbSH8wqckrF-WeaABqYMfE4w3aH_aRcs

In camera (6D) I can't change WB or add lens corrections when exporting to jpeg. That's a bummer.
 
This looks useful for combining ambient and flash images in real estate photography, however i see that the workflow converts to tif in order to combine the images in imagemagik. Doesn't this "bake in" the white balance? (My goal is to be able to skip white balance on my raw files and only white balance the combined image, do you know if this is possible?
 
This looks useful for combining ambient and flash images in real estate photography, however i see that the workflow converts to tif in order to combine the images in imagemagik. Doesn't this "bake in" the white balance? (My goal is to be able to skip white balance on my raw files and only white balance the combined image, do you know if this is possible?
Most full-fledged converters allow you to control WB independent of what is in the metadata, so I am not sure of what you are actually asking. The problem with two different light sources in separate shots is that you can't change the blend, or white-balance the images separately, once you have combined the raw images. It doesn't seem to me that this script is useful for your particular purpose unless you want to give up that control.
 
I did not read the whole thread carefully - if you use some kind of mechanical shutter, you can expect shake, and this would not work so well. If you use electric shutter, this increases the noise you want to fight...
 
This looks useful for combining ambient and flash images in real estate photography, however i see that the workflow converts to tif in order to combine the images in imagemagik. Doesn't this "bake in" the white balance? (My goal is to be able to skip white balance on my raw files and only white balance the combined image, do you know if this is possible?
A use case like combining ambient with flash is more suited to something like enfuse.

It looks like the script is behaving similarly to how I sometimes created DNGs:

Create a TIFF in camera-native colorspace (e.g. original R, G, and B photosite samples with no color matrix transform applied) with whatever averaging method you want (in my case I was using siril)

Tag that TIFF with DNG metadata, and copy relevant metadata from the original raw file(s) - you now have a DNG that preserves original white balance metadata.

I've moved away from this in favor of a pure-Python averaging script.
 

Keyboard shortcuts

Back
Top