Astrophotography - Stacking images with GMIC command line

Hi,

I’m trying to stack a bunch of astro pictures using gmic’s -blend_median or -median_files option:

gmic -median_files file{0..N}.tif output.tif,ushort

However, whatever option I use, the command below produces a list of files, like so:

output_000000.tif
output_000001.tif
output_000002.tif
etc.

To my understanding there should be only one output file. What am I doing wrong?

Thank you!

1 Like

Try

gmic median_files *.tif normalize 0,65535 round output output.tif

– Newer versions of G’MIC don’t require - in front of commands.
– Unlike ImageMagick, you need to use the command output to output files.
– I typically normalize or cut and then round to prevent the need for ushort.

1 Like

I would write:

$ gmic median_files \*.tif o output.tif,ushort

(at least on linux). Give a try in case the single *.tiff does not work.
That is due to the fact your shell may expand *.tiff before actually running the gmic command.

1 Like

Hi,

$ gmic median_files \*.tif o output.tif,ushort
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input file 'median_files' at position 0
[gmic]-0./ *** Error *** Unknown filename 'median_files'.

my gmic doesn’t like doesless :cry:

gmic -version
[gmic]-0./ Start G'MIC interpreter.

  gmic: GREYC's Magic for Image Computing.

        Version 1.7.9, Copyright (c) 2008-2016, David Tschumperle.
        (http://gmic.eu)

Apparently I’m using a pretty old version (installed from Ubuntu repositories - 18.10 I think)

Apart from that, what’s the benefit of using normalize and round instead of ushort?

Thank you David!

I didn’t realize that gmic does it’s own glob expansion. I fully relied on my shell’s glob expansion. :slight_smile:

Mainly because I wrote a script to recursively blend huge stacks of pictures (like 100 or so) to prevent memory exhaustion. However, I just tried gmic’s expansion on 16 pictures and it worked well. Now I’m running it with 64.

But I need to do a better job in aligning the pictures :sweat_smile:

Just a note about that:
We propose up-to-date packages for Ubuntu, on the G’MIC page: https://gmic.eu/download.shtml
You have first to uninstall all gmic related packages to make sure you won’t get conflicts with the separated packages provided in the Ubuntu repositories, then download the one from the G’MIC page (probably https://gmic.eu/files/linux/gmic_ubuntu_cosmic_amd64.deb if you are using Ubuntu 18.10). And install it with $ sudo dpkg -i gmic_ubuntu_cosmic_amd64.deb.
It will install both the CLI tool and the plug-ins for GIMP and Krita.

I don’t think normalize is needed in your case, it’s an extra processing step you may want to do but not necessarily. The use of round is pertinent because it avoids a simple cast from float to ushort and makes a rounding instead (but I guess this should be the default actually, but right now, it isn’t).

Thank you very much! I was just looking for up to date packages, now I will use yours right away! :blush:

Thank you for the explanation! Then I stick with ushort to keep it simple.

Btw. just stacked 64 images without problems. So much for my shell script. :smile: However, great program! Thank you for your work! :+1:

1 Like

Just a note :

In next version, rounding from floating values to integers will be done automatically when saving an image to an integer-encoded format.

https://github.com/dtschump/gmic/commit/a45005e3b78f03547e36e4feb57a37b917fae201

1 Like

Wait a sec: if I saved *.gmz, which I normally do for intermediary steps, I would get rounded values? I always thought that those were float file formats, while JPG, etc., were integer…

No, rounding occurs only if you specify one of the char,uchar,short,ushort,int,uint datatype when saving this type of files.
Typically:

$ gmic 100,100,1,3 fill 128.75 o foo.tiff,uchar

will result in a .tiff file with all values being 129 (rather than 128 as it is with latest stable version of G’MIC).
If you don’t specify the output datatype, then float is used as default (thus, the values are not rounded).

2 Likes