Thursday, November 16, 2023

Cramming for an Astrophotography Opportunity

Shira and I have a trip coming up where I should have the chance to shoot some amazing night sky pics. While I've done some research on the topic before, I've never put this into practice. With time quickly running out, I wanted to take whatever steps I could to improve my chances of getting some keeper shots.

To YouTube!

First up, I headed over to YouTube to arm myself with the latest information. In my mind, there are broadly two types of night sky photos to capture: fixed images and star trails. It turns out that both sets of images can be created the same way: capturing hundreds of relatively short exposures and then stacking them together to either form either a static image or star trails.

This tutorial in particular walks you through every step of the process, from preparation, to image capture to post processing. At nearly two hours in length it's a lot to take in, but so worth it. If I have any success at capturing photos in the field, it will because NebulaPhotos got me there.

To Amazon!

Fortunately, the only new hardware I'd need is an introvelometer. This device plugs into your camera and allows you to capture N photos with M delay between each one. It's perfect for capturing thousands of photos of the night sky. It's also handy for time lapses and other photo projects. And, at $20, it was surprisingly affordable.

I thougt I might need a star tracker to have the camera rotate at the same rate as the Earth to avoid un-wanted star trails. But, all of this can be accomplished in post processing.

To Emacs!

To increase the odds that I won't forget something in the field, I've updated my astrophotography cheatsheet I created a few years ago. I've folded in the information learned on YouTube and dropped the distinction between shooting with a DSLR or phone. My Samsung's S22 pro mode should work more or less the same as my DSLR if I want to give that a try.

You can find the source for my astrophotography chatsheet on github. Feel free to grab it and make improvements.

To The Field!

I felt it was really important to get out and do at least some primitive testing with both the camera settings and my new introvelometer. The best scene I could find given my free time for was to set up a poorly lit, sort of busy intersection. My hope was that dark scene would imitate the night sky, the headlights of cars would stand in for stars. This would be my first attempt at working with raw images. I figured any experience I got in the dark and cold would serve me well.

I spent about 10 very chilly minutes shooting outdoors, capturing two 50 photo sequences.

To The Command Line!

Now that I had some photos, I wanted to practice post processing them. This Reddit post had a suggestion for using ImageMagick's convert function to average a set of photos into one. While this is far more primitive than the astrophotography software I'd ultimately be using should I manage to capture some night sky pics, some of the concepts are the same.

My first attempt to producing an averaging shot was a bust:

$ convert -monitor cr2/*.CR2 -evaluate-sequence median output.jpg
convert-im6.q16: delegate failed `'ufraw-batch' --silent --create-id=also --out-type=png --out-depth=16 '--output=%u.png' '%i'' @ error/delegate.c/InvokeDelegate/1958.
convert-im6.q16: unable to open image `/tmp/magick-27807cFWXnZiY4WSQ.ppm': No such file or directory @ error/blob.c/OpenBlob/2874.
convert-im6.q16: delegate failed `'ufraw-batch' --silent --create-id=also --out-type=png --out-depth=16 '--output=%u.png' '%i'' @ error/delegate.c/InvokeDelegate/1958.
convert-im6.q16: unable to open image `/tmp/magick-27807i9EWII9jtzZR.ppm': No such file or directory @ error/blob.c/OpenBlob/2874.
convert-im6.q16: unable to open image `/tmp/magick-27807i9EWII9jtzZR.ppm': No such file or directory @ error/blob.c/OpenBlob/2874.

The problem was that convert doesn't know how to work with the raw cr2 files my Canon DSLR captured.

I installed dcraw, which is able to convert from cr2 to other formats. While it has a great many options, a simple -T *.CR2 was all I needed to convert a directory of cr2 files to tiffs.

$ dcraw -v -T cr2/*.CR2
Loading Canon EOS Rebel T6s image from cr2/IMG_0021.CR2 ...
Scaling with darkness 2048, saturation 13583, and
multipliers 2.499162 1.000000 1.475508 1.000000
AHD interpolation...
Converting to sRGB colorspace...
Writing data to cr2/IMG_0021.tiff ...
Loading Canon EOS Rebel T6s image from cr2/IMG_0022.CR2 ...

Once in the tiff format, convert worked with the images. I kicked off the following command to average one of the sequences:

$ convert -monitor tiff/*.tiff -evaluate-sequence median output.jpg
Load/Image/tiff[IMG_0021.tiff]: 4021 of 4022, 100% complete
Load/Image/tiff[IMG_0022.tiff]: 4021 of 4022, 100% complete

As it churned, I imagined just how visually stunning the final product would be. Oh man, it was going to be legendary. When the image finished I found myself beyond disappointed:

That's what I froze my butt off for? Sure, that's the scene that was in front of me, but where are the lights of the cars and blur of the people?

I quickly realized that I got exactly what I should have expected. ImageMagick averaged all the photos, so what remained were just the parts of the image sequence that showed up most often. A car zipping through a frame or two was easily averaged out.

Thinking a bit more about this, I realized that this is actually a pretty clever technique. Say I want to capture a picture of the Lincoln Memorial, but I don't want all the tourists in frame. I can simply capture a whole bunch of images and then average them out.

Still, I was curious if I could combine the images in a way that would emphasize the presence of the cars and people. For that, I found this recipe: Create Star Trails With ImageMagick. Again, I used convert to join images, but this time I composed each image on top of each other.

$ cp tiff/$(ls tiff/* | head -1) master.tiff 
$ for f in tiff/*.tiff ; \
  do echo $f ; \
  convert full.jpg $f -gravity center -compose lighten -composite -format jpg full.jpg ; \

The image while far from being a masterpiece is certainly more fun:

I still feel unprepared for this upcoming photo opportunity. But I now feel armed enough to give this my best shot!

No comments:

Post a Comment