January 12, 2020

3D TUTORIAL: Aligning and Cropping Stereopairs

This is a ‘pure’ geeky (and unfunny) post for my stereophotography friends. If you’re unfamiliar with it, briefly: stereophotography is the art of taking 3D pictures, usually via a stereopair: two pictures—each representing the view of one eye—which, when fused, recreate the 3D scene. See a ton of examples I have made here: http://instagram.com/WorldOfDepth

Taking a Stereopair

Though there are specialized dual-lens stereocameras, you can take a stereopair with any camera in a sequential fashion: take one photo, then while keeping the camera pointed straight ahead, move to the left or right, exactly perpendicular to the camera view, 2-3 inches or 4-5 cm, and take another. You want:

  • the magnification/zoom to be constant (don’t move closer/farther to/from the subject) 
  • the top and bottom edges of the scene to be constant (don’t move or point up/down)
When you move sideways, things at the opposite edge of your view will get cut off slightly, of course; this is OK. Do NOT pivot the camera to compensate (this creates trapezoidal so-called keystone distortion).




Here is an example stereopair taken in such a fashion, and placed side-by-side (otherwise unedited). The top version is meant for cross-eyed viewing: cross your eyes until the two images fuse into one at the center. In this version, the left eye view is on the right, and vice versa. The bottom version, which preserves the left and right views, is meant for parallel viewing, which requires you to diverge your eyes to fuse them. For almost all people, this is significantly more difficult than crossing your eyes; it is also harder to do with larger stereos. However, the sense of depth in parallel view feels superior to many people (myself included).

Vertical Alignment
 

The unedited stereopair above is viewable, but it has flaws. It is vertically misaligned, for one thing: look at the differences in the upper right corners. The stereo will look cleaner and nicer if we correct this.


(For some pictures hereon, I will use cross-view only, because that is the view I use when editing. I can view the stereos at larger size that way.)

Using a simple program like Mac’s Preview (built into every recent Mac desktop/laptop), you can draw two a box (or two horizonal lines) around certain features of the picture. Here I wanted to focus on the center plant, so I chose to draw the top line through the edge of a certain leaf, and the bottom line through a dewdrop on the bottom of another leaf. After doing this in both pictures, you can see that the top line is higher in the blue box here. If the bottom line were also higher, it would be a simple matter of moving the left-hand picture down a bit, and then cropping the overhanging tops/bottoms of both pictures.

However, the bottom line here is approximately aligned, so in other words, the blue box is LARGER than the red—the left-hand picture was therefore taken closer to the subject. (This is something we always try to avoid, but small differences happen.)

(Occasionally, you’ll find misalignments that are different on the left than on the right of the stereo scene. If they are misaligned in opposite directions, that indicates a rotation misalignment, and that may require a more advanced program than Preview to correct.)


In Mac Preview, when drawing a box, it shows you the dimensions. Here, it showed that the blue box was 3458 pixels tall, and the red 3416. Therefore, if we want to reduce the blue box to the be same size as the red, we have to downsize that picture to 98.8% of its original. If you do that in Preview, and then move the windows to align the boxes once again, you get:


Now the right-hand picture is larger. If you crop the top and bottom to the same height as the left-hand picture, you get:



The top and bottom edges here are much cleaner than before (try comparing it to the original!).

Left/Right Cropping
 

Now let’s look at the left edge. Overlap the pair and bring their left edges closer together. Draw a line (or box) along the left picture left edge. Draw the same line on the right, but then *while viewing in 3D*, move that line gradually to the right. At some point, you will see the line in 3D, within the scene:


Here the line appears to float just on or above the ground. However, if you look below, notice that those grass-like blades appear to reach OVER the line. If the white line were the edge of the stereo, those blades would look ‘cut off’ in mid-air by that edge, and this would be what’s called a window violation or edge violation—something most stereographers dislike. So, if you continue nudging the right-hand line to the right farther, you can raise the line in 3D up towards the viewer:


Now the line floats at the same level as the highest (closest to you) blade, and doesn’t cut it off. Now you can crop the right-hand picture at that line. (You can do this by drawing a box with the left side on this line, and all other sides out past the other edges.)

If you repeat this process for the right stereo edge (moving the left-hand picture line to the left), you might choose to place the line in 3D here:



It is aligned with the highest (closest to viewer) object on the right edge: that little leaf bit at upper right. If you then crop the left-hand picture at that line, here is full result:



Compare this to the original, paying special attention to the image edges. Much better!

Now, this method of cropping the left and right edges separately may yield a stereopair with different left & right widths. I personally prefer this, as it gives you the freedom to frame a stereo asymmetrically if you so choose. But if you require a same-width stereopair (like for making an anaglyph), simply move the left or right edge farther inward on the wider picture, until they match. Alternatively, add vertical bars to make the narrower picture wider. (That is what I do for making asymmetrical pairs into anaglyphs, but it requires more advanced tools than Mac Preview.)

So this is what you can do even with a simple program like Mac Preview. This stereo is now fairly clean and good, though not flawless (the details at upper right, for example). You can of course go beyond this: instead of drawing lines to manually align things, you can identify shared points at key locations, and use techniques like 4-point perspective distortion to make the pair match very precisely. For my stereo workflow, I do just that, using the programs Hugin and Imagemagick (I also use the latter for creating the side-by-sides and anaglyphs). Here is the result of those techniques on the same original stereopair:




This is cleaner still than the previous. Discussion of these more advanced techniques, however, will have to wait for another time.

Feel free to leave questions in comments below, and/or send them via my 3D Instagram account @WorldOfDepth. Cheers and happy stereo taking!

2 comments:

  1. I was not able to use Preview for these... thank you

    ReplyDelete
    Replies
    1. You mean you can't do this with your version of Preview? Some older or newer versions might be different, for on my Mac, you click the Markup button (or in the menu, View > Show Markup Toolbar), then go to Selection Tools > Rectangular Selection in order to select an area for cropping. If your version can't do this, you can use many different free tools to do the same thing, like Photopea.com.

      Delete