2013-05-12T07:08:20Z

Take 3D Pictures With Your Canon DSLR and Magic Lantern

Posted by Miguel Grinberg under Photography.

In this article I'm going to show you how you can make high quality 3D pictures with a Canon DSLR, Magic Lantern and free software. If you have an old pair of cardboard red/blue 3D glasses at hand then put them on to view the image above and that will give you an idea of what you can do with the technique I'll show below. You can click on the image to view a larger version of it.

Brief theory

3D pictures are made from two regular pictures of the same scene taken from two different points of view. Later during post-processing, the two images are combined into one.

To view the image and see the 3D effect the viewer must use a viewing device such as red/cyan colored glasses, or a viewing technique such as crossing the eyes. These have the effect of separating the original two images again and feeding them independently to each eye. The slight differences between the two images help our brain generate the illusion of depth.

Planning

Before you grab your camera you have to design your 3D picture carefully. You need to decide which elements of the picture you want to pop out, and which you want to sink into the screen.

Here is how I do this. I position myself in the location from where I will take the picture and then observe the scene, looking for an element in the picture that I can use as a reference. In the final 3D picture this element will be aligned with the depth of the screen. Once I have identified my reference element I know that anything that is closer to me will pop out, and anything that is farther away than this element will sink in.

For example, if I wanted to take a picture where everything pops out of the screen, then I would pick a reference element that is way back.

Taking the pictures

Now comes the fun part. The basic rule to make a good 3D picture is that you need to take two pictures, from each eye position. In practice this means that you will move the camera two to three inches horizontally between the pictures.

It is important that nothing moves significantly between pictures, so this is not a good technique to use in places where people, animals, cars, etc. are moving.

It is also recommended that the camera is set to a manual mode, to prevent settings from changing between pictures. At the very least you should set focus to manual, but if you feel comfortable working with your camera in manual mode you should also set a fixed exposure.

The tricky part is to get the pictures aligned, and for this there is nothing better that Magic Lantern's Ghost Image feature.

The process is as follows:

I start by enabling live mode and taking the first picture. Live mode isn't necessary for the first picture, but since it has an important role later I usually enable it from the start. I'll call this first picture the left side picture.

Then I enable Ghost Image in Magic Lantern's Overlay menu (version 2.3):

Next I preview the left side picture I just took and press the Live View button to put it in the overlay. This brings the camera back into Live Mode, but now I can see a blend of the left side picture and the live view.

I now move the camera a couple of inches to the right and align my reference element, the one that I picked when I planned the picture. This step is very important, anything that is perfectly aligned between the two pictures will appear in the plane of the screen in the final 3D picture, and everything else will find its place relative to that.

When I have the desired alignment in the preview I take my right side picture and then take the two pictures to the computer for processing.

Post processing

There are several methods for post-processing the images. The one to use depends on how the image will be viewed.

To generate the 3D pictures I will use a small script that I wrote, simply called anaglyph.py. I wrote it in Python using the Python Imaging Library (PIL). The script is open source and available directly from github or as a zip file download.

I will assume that you already have or know how to get python and pip installed. My script requires the PIL libray, which can be installed with the following command:

pip install pil

Using this script you can generate a few different types of 3D images, which I describe below.

Red/Cyan Anaglyphs

This is one of the most known types of 3D image. To view the images you need red/cyan colored glasses, like these:

Cardboard glasses of this type can be obtained online (Amazon, Ebay, etc.) for very cheap.

To generate a red/cyan anaglyph that can be viewed with these glasses you must run the following command:

./anaglyph.py left-image.jpg right-image.jpg final-image.jpg

The script provides a few options that control how the anaglyph is generated:

  • --true to generate a true anaglyph
  • --mono to generate a grayscale anaglyph
  • --color to generate a color anaglyph
  • --halfcolor to generate a half color anaglyph
  • --optimized to generate an optimized color anaglyph (the default)

The difference between these options is in how the colors from the two images are mixed. The default method is typically the one that produces the best color images. For details on the algorithms for these options see this page.

The main disadvantage of the red/cyan anaglyphs is that they have a poor rendering of the red color.

You've already seen an example of this type of image above. Here is another one (click to enlarge):

Note how in both images the reds are almost non-existant. This is an unfortunate limitation of this format.

Stereo Pairs

Another way to represent 3D pictures is as stereo pairs. These have excellent color quality and can be viewed without glasses, but the viewing technique is difficult to learn for some people.

There are two types of stereo pairs, crossed and parallel. To generate a crossed stereo pair you must use the following command:

./anaglyph.py -x left-image.jpg right-image.jpg final-image.jpg

And to generate a parallel stereo pair you must use this command:

./anaglyph.py -p left-image.jpg right-image.jpg final-image.jpg

I find the crossed pairs much easier to view. The viewing technique involves crossing your eyes, as explained in detail in this page. To learn how to view parallel stereo pairs visit this other page.

Here are the above 3D pictures rendered as crossed stereo pairs (click to enlarge):

Wiggle 3D

The final method I'm going to show you is the least serious of all. It does not require you to wear glasses and you don't have to do any difficult tricks with your eyes either. The problem is that it isn't really 3D but a fast animation of the two original images.

To generate a Wiggle 3D image use the following command:

./anaglyph.py -w left-image.jpg right-image.jpg final-image.gif

Note that the final image must have a .gif extension, as this is the only widely supported format for animations.

Here are the images above rendered in this format:

As you see, this isn't really 3D, but for certain images the effect is quite interesting anyway.

How to fix bad alignment

Sometimes no matter how careful you are to align the pictures they don't come out good and the 3D picture looks bad. Maybe the camera was not kept leveled between the two pictures, or the distance between the two pictures was too much or too little. If the resulting 3D image seems to be badly aligned there is something you can try.

Less than great 3D pictures can sometimes be improved in a photo editor like GIMP or Photoshop. To do this you import the two images as layers, set the opacity of the top layer to 50% and then move or rotate the layers to align them better. The resulting layers can be cropped and exported back to disk as individual images that can be processed again with anaglyph.py.

Conclusion

I hope you find making 3D pictures fun. If you have any questions you are welcome to send them via the comments below.

Miguel

6 comments

  • #1 Eduardo Serrano said 2013-05-14T10:46:44Z

    wow -llloved it!!! really innovative for me. Will try this out soon. cheers & thank you! Ed.

  • #2 BL said 2013-05-26T00:41:21Z

    Could you go into more detail about the post processing? I have everything installed I just don't follow after that...

  • #3 Miguel Grinberg said 2013-05-26T02:24:30Z

    @BL: Did you get my anaglyph.py script? See above the commands you need to run to generate the different types of 3D images. Is there anything specific you don't understand from those examples?

  • #4 Michael Rath said 2014-02-18T15:41:00Z

    Have you tried StereoPhoto Maker ( http://stereo.jpn.org/eng/stphmkr/ ). It's really easy because it does automatical alignment and batch conversions and you can view in different modes (anaglyph, sbs, parallel...) and export as html with even better view modes (e.g. mirror using the StereoPhotoViewer Applet). A really handy and time saving utility. Works on Linux an MacOS X with wine too...

  • #5 Kun Li said 2017-01-11T17:18:36Z

    Dear Miguel Thanks for this interesting article. I'm Kun Li from University of Cambridge (Engineering dept.). I want to ask your permission to use your stereo image pair (bird) in this article. I am using it to demonstrate an auto-stereoscopic display based on lenticular lens array in my academic paper which I want to publish in a good journal. I will credit the source of the image and provide the link of the image in the paper. Is that OK with you? Can you please send me an email to kl330@cam.ac.uk to say if you have me the permission to so. Many thanks. Best regards Kun Li

  • #6 Miguel Grinberg said 2017-01-11T18:00:28Z

    @Kun: As long as you link back to this article, I have no problem. Thanks!

Leave a Comment