Astro Stacking with G'MIC?

I have never done that myself, but I guess that @David_Tschumperle and @patdavid have some experience in averaging or median stacking several images… I remember a thread about that in this forum, but I could not find it again…

Yes, search for “super resolution”… I think the most recent discussion was my post about image stacking to simulate long exposure though… Anyway, the truck is to do the blending with imagemagick, using and averaged or median blend mode. Don’t have time to look it up for you now, but will be back later and can post then (if someone else doesn’t do it before then!)

G’MIC can do median stacking which I’d recommend if you have just a few images (maybe up to 10), you can find it under layers/Blend [median] set input layers to all. If you have more images you want to use more advanced techniques for calculating the true value while rejecting outliers/noise. Look at Siril for doing that.

align_image_stack never worked for my astro shots either and I haven’t found a way to mask off the foreground so I just use hugin to mask and align. A bit of a pain but it works decently well. Reminds me that I should still write that astro tutorial. -.-

Edit: Just read that you are memory constrained, try Siril in that case, they do some more clever batching to work with the memory that’s available IIRC.

Thanks, @Jonas_Wagner, I did find G’MIC’s median/average blend filters. The “Average” filter chokes with a memory error if I try to do all 13 full-res files. I guess I can do a couple of pictures at a time till they’re all done though…

align_image_stack seems to work pretty well for me!

If it meets your stacking needs, I would suggest enfuse, also in the Hugin suite CLI, documentation on http://wiki.panotools.org/Enfuse. Have been using it for improving resolution and exposure and have not experienced it failing due to lack of memory.

To average/median a stack with several images without having memory issues with G’MIC, you should try commands -average_files and -median_files, as described in this post :

Thanks David, that’s what I needed! Just one small problem: It works just fine for .jpg files, but I could not get it to work with .tiff files. :frowning: Hugin’s align_image_stack outputs .tiff files, so it would be nice to be able to stack those files without having to convert back to .jpg.

@RT-Noob whenever reporting problems, always make sure that you have provided enough information for others to go by. Here you said “I could not get it to work”, but you didn’t say what the problem was - that’s not helpful. Show your command, and upload the TIFF in question using e.g. https://filebin.net/

I suspect your tiff files to be 16bits tiffs ?
I’ll probably have to handle this specific case in these commands.

Thanks for the reminder, @Morgan_Hardwood, I should have thought of that myself! :blush:

Now this is weird! I tried it again so that I could get a screenshot to show what was wrong, and now it works! :frowning:

I can get it to average the .tif files and output a perfectly good .jpg file. However, when I try to output a .tif file, it puts out a 250MB file that is blank. GIMP just shows it as transparency. (The input files are 25-26MB each.)

@David_Tschumperle, I don’t think the .tif files from Hugin are 16-bit, but I could be wrong. Does G’MIC have a way to identify whether it’s 8-bit or 16-bit?

Hugin will output whatever bit depth is input; 16 bits in will result in 16 bits out.

1 Like

ImageMagick/GraphicsMagick do:
identify foo.tif

1 Like

Thanks, that’s good to know! The Hugin output is 8-bit, but the G’MIC output is 32-bit! That’s why I can’t read it!

Can G’MIC average 16-bit files and output to another 16-bit file? It would be nice to keep all the data I can, since I’m working with 14-bit RAW files in the first place.

This is the case if you use imagemagick too. I believe it has something to do with the way tiff handles alpha channels. Tiff images can have color/channel information interleaved in three ways, by pixel, by line, or by band. These result in the data being stored very differently in the actual file. I don’t know if interleaving is the culprit here, but that was my first idea when I found this while averaging over an I.ge series innimagemagick. My main experience is from mulriband satellite imagery, and interleaving is often a source of these problems. But since I found it worked with jpeg or PNG, I never delved any deeper…

The command -average_files and -median_files were indeed buggy with 16bits files. This should be fixed now, after an update of the G’MIC commands :

$ gmic -update

(I assume you are using version 1.7.5_pre, otherwise, it won’t work).
After the update, computing the average and median of a sequence of 16bits tiff should work as expected.

Also, please note that by default, G’MIC saves .tiff files as 32bits float-valued files, and unfortunately, there are very few viewers that recognize this format (it is still a mystery for me, as this is a legacy tiff format).
You can force the output tiff files to be saved in 16bits in G’MIC, by specifying ushort after the filename, like this :

$ gmic -w -median_files test16bits\*.tiff -o result_16bits.tiff,ushort

Let me know if all work as I hope it will :slight_smile:

2 Likes

Wow, that did the trick! Thank you so much! Averaging 16-bit files worked splendidly, now I’m testing the “median” stack to see what the difference is.

I sort of figured that G’MIC was saving it in a higher bit-depth format, but I didn’t know how to tell it to save in a different format, so thanks for clearing that up for me as well! I just downloaded the “g’mic reference” .pdf file, so hopefully I’ll be able to answer some of my own questions (like how to batch convert .tif to .jpg, and so on) and not have to bother you too much.

Thank you again to everyone who helped me out! Here’s one of the projects I was working on:

I managed to keep in a 16-bit workflow until the final 8-bit JPG for web! And if I ever learn RAWTherapee well enough, the workflow will be totally free!

5 Likes

Here’s another view of the same sky, (taken on a different night).

Pentax K-5IIs + 50mm f/1.7 lens

  • ISO 4000
  • Aperture: f/1.7
  • Shutter Speed: 2.5 seconds
  • 25 frames aligned with Hugin, averaged with G’MIC

2 Likes

For comparison, here’s what one of the original frames looks like, processed (in Lightroom) with exactly the same parameters as the stacked image:

1 Like