Thursday 16 February 2012

Webcam Moon Mosaic with Xbox Live Vision

A couple of weeks ago I took a series of photographs of the moon using my telescope and the Xbox Live Vision webcam to turn into a mosaic. It took me a while to composite them together, but I managed to do this using some free open source software called Hugin.

Moon Mosaic, 4 Feburary 2011

Image capture

For this I used my Xbox Live Vision webcam (with the standard issue red glass IR filter still in place - getting enough light was not an issue) connected to my telescope in place of the 1.25" eyepiece using a manufactured nose piece.

I don't have a focal reducer, so the field of view (FOV) via the camera shows only a relatively small chunk of the moon, so quite a few images are needed for a complete picture - hence the need for a mosaic.

I considered using the sidereal drift method where you capture bands of the moon as movies (allowing the Earth's rotation to make the moon drift through your field of view), but decided instead to use my RA tracking motor and take a series of stationary snapshots.

I'm still using Apple's Photo Booth as my webcam capture software, not great as there is no fine control, it insists on flipping the photos horizontally, and it uses a low resolution of only 640 × 426 pixels. I'm sure there is a better tool, but I'm still looking. I used the "four in a row" mode, where with one click of the button four images are taken in quick succession.

I manually completed two traverses of the moon, from 9:20pm to 9:55pm. I'm not sure how much the terminator moved over this time period, but changes to the shadows are a minor problem overall. I tried to ensure each photo overlapped the previous one by about a third. I did two complete scans just in case I'd missed a gap.

I ended up with 113 sets of four images, giving 452 photos. I then manually went through the images and selected the best image of each four. It was surprising how much variability there was - perhaps partly telescope wobble, but it wasn't consistently the first or last image in each set that was crispest.

Example individual image, showing "amp glow"
Here is an example, showing the "amp glow" problem giving a purple glow on the (apparent) left edge of the image from the Xbox 360 camera (actually the right of frame, this was mirrored by Photo Booth). This has only been a noticeable problem on lunar photography - for planets and stars I've not noticed this at all.

Photo-stitching Software

On Windows for stitching together lunar mosaics I've seen several tools recommended online including iMerge (free), Microsoft Research Image Composite Editor (ICE) (free), AutoStitch. On the Mac, Calico Panorama looked possible but is on hiatus.

I settled on the first and only free open source tool I could find that supported Mac OS X, Hugin. This proved quite frustrating to get to grips with, and also quite demanding in terms of CPU run time. I initially tried using it on my laptop but gave up - it took hours to run alignments and risked overheating. Instead, I borrowed my work machine - an eight core Mac Pro. Bits of Hugin do take advantage of multiple CPU cores, but much of it doesn't.

Hugin for Lunar Mosaics

Hugin (version 2010.04.0) has some quirks which I dealt with as follows. It starts by asking your for the focal length of your lens. Entering a large number reflecting the telescope might be the right thing to do, but on the panorama preview screens this results in frustratingly small layouts with no apparent way to zoom the interface. Putting a normal rectilinear lens, focal length of 100mm, and focal multiplier of 1 seemed to work OK.

Given I used a proper equatorial mount tripod, my images shouldn't need any rotation (roll) for the alignment step - but Hugin tries this by default and often made things worse. If that happens on the Image tab you can select all the images, and reset the roll values to zero. Then on the Optimiser tab you can select custom mode and only use the yaw and pitch.

I found the fully automatic automatic alignment was a bit hit and miss, and so on the Control Points tab had to manually add references between overlapping photos. Essentially you just mark pairs of points to tell Hugin they are the same location. With the auto-options ticked, doing this for any given image pair was quite quick since after the first few pairs of points were added it could locate the matching point automatically.

After doing an alignment, you can get a popup window listing all the control points via the main menu or toolbar. This can be sorted by distance and gives you an easy way to delete bad pairs with distances above (say) two. Looking at some of the bad points, Hugin had often identified "features" in the noise of the black space next to the moon itself.

Because all my individual images were in automatic mode, their exposure and white balance are not directly comparable. There are a few presets on the Exposure tab, but I had to use a custom mode to optimize both the exposure and white balance. You can select a particular image as the exposure reference on the Image tab. I found using one of the brighter ones worked well to avoid over exposed regions in the final result.

Here are some screenshots from the preview mode, showing the alignment as a crude mosaic (without any exposure adjustment) and as a network from which I think I can see the two sets of traverses I made. Note there is a slight vertical drift as I panned left/right - I can't have had my polar alignment quite right.

Hugin showing good (green) alignment mesh

One thing I haven't tried yet is the Mask tab. I think this will let me use my full images for alignment, but then mask out the "amp glow" from one edge. However, this isn't evident in the final output - although it is quite clear in the individual images and the preview:

Hugin preview showing alignment

Initial Result

Once again, here is the finished picture after undoing the horizontal flip from the camera software, and removing the noise from the black space region by hand. The edge could do with a little more work - but I was pleased with this:

Moon Mosaic, 4 February 2011

On inspecting the individual frames, some are actual not as crisp and focused as others. Now that I have them all aligned, I can probably afford to deselect some within Hugin which may improve the final result. Clearly getting the best out of this software will require a significant time investment.

Maybe next time I'll try to use the full 1280 × 960 pixels the webcam is capable of?


  1. This was really helpful thanks. I've been doing my mosaics by hand up until now, with pretty dire results. Had thought about using Hugin, and have just tried it based on the instructions above and the results look great :)

  2. A lot of nice work there, impressive.
    I like the xbox's simple mod and cheap price, and anything that involves some creative ideas as to improving its picture quality goes a long way to getting the best from the comparatively noisy images it gives out.
    I have always found issues with colour when using the cam and its often difficult to process a 'natural' image from the data - unfortunately my software skills are minimal and Im at the mercy of tech-minded folks doing the work beforehand so I can then try to implement their ideas or use their software (like registax or PIPP), so I appreciate the info and attempts to record your method and results via the webpage.