basic Linux script for astrophoto stacking

Forums Forums Get Technical Tips & Tricks basic Linux script for astrophoto stacking

This topic contains 3 replies, has 3 voices, and was last updated by  fluffybunny 7 years, 2 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2793

    chupathingie
    Participant

    I figger I’ll drop this here for anyone who has an interest…

    I got tired of all the manual work involved in stacking under linux and finally put my head to work on a basic script. Now I simply dump my darks and lights into sub-folders in a directory named “darks” and “lights”, open a terminal window in that folder, enter “sh stackme”, and go get lunch.

    Result: (note that this is a jpg of an unadjusted 16bit/channel tiff…no levels corrections or additional processing of any kind applied)

    (other sizes here)

    Part of this script is doing darkframe subtraction, which is also useful for noise reduction in non-astro images where the shutter speed is slow enough to bring out hot pixels and thermal noise.

    Code:

    #!/bin/bash

    # This script depends on ufraw and hugin having been previously installed.
    # It should be run from a directory containing 2 folders, “lights” and “darks”
    # with the appropriate RAW files contained therein. It is written for some of
    # the Canon cameras using the .CR2 extension. If your files have a different
    # extension, edit the two occurrances of “CR2” below to reflect your filetype
    # using the proper upper/lower case characters.

    # convert raws in “darks” directory to tiff,
    # average all frame data into darkframe.tif
    cd darks
    ufraw-batch –out-type=tif –out-depth=16 *.CR2
    convert -average *.tif darkframe.tif
    cd ..

    # convert raws to tiff in “lights” directory,
    # subtract darkframe.tif from each resulting tif,
    # (eg. flnm.tif) write to files dsflnm.tif
    cd lights
    ufraw-batch –out-type=tif –out-depth=16 *.CR2

    # begin loop for all .tif in directory
    echo Applying darkframe to lights
    for flnm in *.tif
    do echo $flnm; composite -compose minus $flnm ../darks/darkframe.tif ds$flnm
    done
    echo Finished applying darkframe to lights

    # begin alignment of dark-adjusted lights
    echo Beginning alignment process, please wait.
    echo This can take a while with many images.
    align_image_stack -a ais ds*.tif

    # average aligned images into final.tif
    echo Averaging aligned files
    convert -average ais*.tif final.tif
    cp final.tif ..
    echo Stack complete.

    cd ..

    # file cleanup. Comment out lines if you
    # want to keep any of the converted files
    echo Deleting temporary files.
    cd darks
    rm *.tif
    cd ../lights
    rm *.tif
    cd ..
    echo Temporary files deleted.

    #48822

    CauseISaidSo
    Participant

    That script looks like it could be converted to a Windows batch file pretty easily, assuming there are Windows versions of the tools you’re using. But what I really came here to say was, that’s a really cool shot; even more so in larger size.

    #48823

    chupathingie
    Participant

    That’s the first reason I posted this… I was hoping it might be of use to someone with a passing familiarity with scripting.

    The second reason was to show off my first useful script. Shiny! 😆

    I posted linkage to the original full rez because I wanted to show what using darks does for you. Reducing hides a lot of noise, I wouldn’t dare show off a sub of this image except as a comparison. This is soooo much cleaner than the individual images. If you look toward the edges, and especially the corners, you can see a little bit of CA. But that’s not what’s causing my triangular stars out there in the weeds; that’s coma. The good news is that I’ve got pretty close to the same amount of coma all around the fringes…which means the lens and body mount are properly aligned. I’d love to see someone else’s results with the same lens and a full-frame sensor (that’s the kit lens for the 5DII… 24-105 F4L). I swear, nothing points out flaws in an optics train faster than astrophotography.

    BTW, coma is a common flaw in fast systems, but can be managed if the manufacturer does it well. The 70-200 F2.8L has *much* better coma, for instance, but at better than twice the price. A 200mm prime is on my list just for the stars; cheaper and better at it’s fixed FL. It’s a sorta geek thing…

    #48824

    fluffybunny
    Participant

    assuming there are Windows versions of the tools you’re using

    Not sure if applicable in this case but Cygwin is a long time friend of mine when I don’t have a Linux box nearby.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.