Thursday, May 14, 2009

Lift Bridge Time-Lapse (Part 2: Fun with Photo Slicing)

The Portage Lake lift bridge, made up of 36 vertical stripes from 36 photos taken around sunset.
The Portage Lake lift bridge sunset, together in a single photo

Here's my next bit of fun with time-lapse photography: putting it all together in one photo! This photo is made up of 36 vertical slices. Reading from left to right, they span approximately 1.5 hours centered around sunset -- from 8:30 until 10:00 pm. These are the same images that went into my time lapse video of the lift bridge. The sharp edges are a bit annoying, but that could be solved by taking even more photos (something I hope to do shortly).

For those interested -- how did I do this? I can certainly tell you how I didn't do this: I definitely did not slice and assemble 36 photos by hand! Instead, starting with my 36 image files, I used magic -- actually, ImageMagick -- to do this for me. First, I ran the following shell script:
#!/bin/bash
off=$[0]
for ((i=2861;i<=2896;i++)) do
convert -crop 107x2385!+$off+0 DSC_$i.jpg Crop_$i.jpg;
off=$[$off + 107];
done
This script runs through the images, which were named DSC_2861.jpg through DSC_2896.jpg, in order. For each of them, it uses ImageMagick's convert command to crop the image into a single slice, 107 pixels wide and 2385 pixels tall. Each slice is 107 pixels to the right of the previous image's slice, so that the slices would all line up. I came up with these numbers pretty simply: 107 is the width of my images, divided by 36, while 2385 is the height of my images. After that, all I had to do was
convert Crop*.jpg +append bridge.jpg
which stitches the images together horizontally into a single image. (That's what +append does. Using -append stacks them vertically, in case you wanted to do a vertical time-lapse photo.)

6 comments:

Anonymous said...

that's friggin awesome!

Summer said...

Cool:) Maybe you could do a panoramic shot next time, or sunrise to sunset. Not that I advocate the evil rise before the sun thing. Can't wait to see the smooth version...

Once you smooth out the lines, I bet it will make a *sweet* print!

DC said...

@cmartin -- thanks! :)
@Summer -- Man, that would be pretty cool to do sunrise to sunset. My only worry would be leaving my equipment out all day... even in the Keweenaw, a fancy camera and laptop might be a bit of temptation! Actually, I'm also limited by battery life, which is a problem I don't know how to solve. Any ideas?

steve h said...

Shell-scripting is fun.

Something to do with that picture, right?

Jay Balliet said...

I was thinking, in PS you could do this with layers. Just put each one on top the the other and cut out the appropriate width. With minimal tweakikng it wouldn't have the sharp lines.

DC said...

@Jay -- yeah, that's actually the first approach I tried (with Gimp, not Photoshop). It was a royal pain -- having that many images takes a TON of memory, and slowed things WAY down. Then slicing had to be done manually, although I suppose there must be a way to automate that. The resulting file was gigantic. Using ImageMagick and automating it was my second choice, and I was much happier with it.