Tuesday, September 11, 2012

Make Your Own Miniplanet

After I'd been playing around with using the Hugin software to make panoramas [1], I discovered another way it can be used: to make miniplanets. Despite the name, this has nothing to do with real astronomy and everything to do with computer trickery. A miniplanet takes photographs from a complete 360° panorama and stitches them together so that they look like a tiny planet.[2] I've scoured the internet and found three different methods for making miniplanets. The first two require Hugin to make a regular panorama and then GIMP to make them miniplanets. The third method is all done in Hugin. For each method you'll need to shoot photographs all the way around you. To have enough ground that the whole planet isn't outrageously distorted, you'll need to aim your camera down a little and go all the way around again at least once (but the more the better).

Method One: Polar Coordinates Filter
  1. Shoot photos all around you in a complete circle, making sure to include lots of sky at the top and ground at the bottom (the more cluttered the area in your immediate vicinity, the more problems you'll have with paralax)
  2. Construct a 360° cylindrical panorama using Hugin
  3. Open in GIMP 2.8 [3]
  4. Choose Filters, then Distorts, then Polar Coordinates… [4]
  5. Uncheck Map from top and make sure To polar is checked then hit OK. This will give you a miniplanet the size of the height of your starting image, but it will retain the width as white space.
  6. Choose Layer, then Transparency, then Add Alpha Channel
  7. Use the Fuzzy Select Tool to select the white space to the left then hit Delete (repeat for the white spice on the right side)
  8. Choose Image and then Autocrop Image
  9. Heal the transparent corners [5]
Method Two: MathMap Script [6]
  1. Shoot photos all around you in a complete circle, making sure to include lots of sky at the top and ground at the bottom (the more cluttered the area in your immediate vicinity, the more problems you'll have with paralax)
  2. Construct a 360° cylindrical panorama using Hugin 
  3. Open in GIMP 2.8
  4. Choose Filters, then Generic, then Distorts, then Miniplanet [7]
  5. Click on User Values and use the turn slider to set the rotation to what you want then hit OK
  6. Choose Layer, then Transparency, then Add Alpha Channel
  7. Use the Fuzzy Select Tool to select the white space to the left then hit Delete (repeat for the white spice on the right side)
  8. Choose Image and then Autocrop Image
  9. Choose Image and then Transform and then Flip Horizontally [8]
  10. Heal the transparent corners
Method Three: Hugin Stereographic Projection [9]
  1. Shoot photos all around you in a complete circle (you should be able to do this in 6 shots) as well as a shot of the sky (zenith) and a shot of the ground (nadir)[10]
  2. Load your photographs into Hugin
  3. Set your Lens type to Full frame fisheye
  4. Be sure to set the correct HFOV (horizontal field of view) [11]
  5. Go to the Images tab, select your nadir photo, and hit Anchor this image for exposure
  6. Select the photo you want at the top of your miniplanet, and hit Anchor this image for position
  7. Go to the Assistant tab and hit 2. Align… [12]
  8. The control point generator doesn't like to create control points in the distorted parts of the photograph, so you may need to put some in yourself [13]
  9. When the fast preview comes up, change the projection to stereographic
  10. Close the fast preview and open regular preview
  11. Choose Num. Transf. and change the pitch to 90°
  12. Close the regular preview and go back to the fast preview
  13. In the Crop tab, zoom in until you have the miniplanet that you want in the frame
  14. Hit the green arrow button
  15. Close the fast preview
  16. Hit 3. Create panorama…
And now to see the results.


Here is a panorama I constructed after shooting some photographs of a rainbow in the park near our house.[14] I thought having a rainbow in the shot would make for an interesting miniplanet.


 


Here are the miniplanets I made. The first image was made using the Polar Coordinates method, the second using the MathMap method, and the third using the Hugin method. As you can see, Hugin gives the least distortion and MathMap gives the most. But Hugin left a huge hole in the middle that I had to fill in.


Here's another panorama. This time I photographed part of BYU campus, including the Widtsoe Building. I took the photographs from the field where the Knight Mangum Building (which at one point was the LTM [15]) used to be. Since I was on the side of a hill, things look a little funny (e.g. the crane constructing the new Life Sciences Building [16] and the BYU smokestack both look crooked). I used the camera I normally use in the lab for photographing root nodules [17], bacteria [18], etc. and it had a much narrower field of view. So this one took over 150 photographs to construct.




And here are the miniplanets. As before, the top image was generated using the Polar Coordinates method, the middle image using the MathMap method, and the bottom image using the Hugin method. The problems associated with each method are a little more apparent here. The first two methods, since they just circularize the pre-existing panorama, make the sidewalk pinch together in the center, and MathMap gives a smaller, more distorted miniplanet. Hugin preserves the appearance of the sidewalk, but by the time I'd taken ~150 photographs, I was getting impatient with the process, so I didn't take all the pictures I needed to finish the sidewalk where I was standing (which is why there's a hole in the middle of the bottom image).




This last batch I made while I was visiting my in-laws in Texas.[19] My father-in-law let me borrow his fisheye camera, so I was able to photograph the entire sphere around me in 8–12 shots. I particularly like the last one because 1. I was able to include trees (which with a regular camera would've been too close and would've introduced far too much paralax) and 2. I was standing in a ring of tree slices which I was able to make the center of the miniplanet, which I thought was a nice effect. These are far superior to the other miniplanets I've constructed. But if you (like me) can't afford a fisheye camera, the first two methods can usually get you close enough, provided you shoot enough photographs.



One more thing. When using the Hugin method, if in Step 11 you set the pitch to –90° instead of to 90°, then you get a tunnel instead of a miniplanet.


Notes:

[1] See my post Make Your Own Panorama.

[2] You can see lots of incredible examples here.

[3] You can download GIMP 2.8 here.

[4] If you have white pixels at the top of your image at this stage, invert the colors before proceeding. After step 8, invert the colors again to restore the image. Otherwise you will lose part of your image in step 7.

[5] See my post How to Fill in Transparency in a Hugin Panorama.

[6] To install the MathMap plugin for Gimp 2.8 onto a machine running Windows 7, download and run the installer (here). It will ask to install into a C:/Users/[YourUserNameHere]/.gimp-2.6 folder (which it will create). Go ahead and let it do that. When it's done, move the contents of C:/Users/[YourUserNameHere]/.gimp-2.6/plug-ins into C:/Users/[YourUserNameHere]/.gimp-2.8/plug-ins. Also, move the folder C:/Users/[YourUserNameHere]/.gimp-2.6/mathmap into C:/Users/[YourUserNameHere]/.gimp-2.8. Done.

[7] If you have white pixels at the top of your image at this stage, invert the colors before proceeding. After step 8, invert the colors again to restore the image. Otherwise you will lose part of your image in step 7.

[8] I don't know why, but the MathMap script for making a miniplanet turns all of your images around, so you have to turn it back in this step.

[9] To do it this way properly, you really need a camera with a fisheye lens. You can do it with a regular camera, but then you'll spend all day taking all the pictures you need to cover the entire sphere around you. While I was in Texas, recently, I borrowed my father-in-law's GoPro Hero Fisheye 960.

[10] You want to take two shots of the nadir if you're not using a tripod because you're going to appear in the photograph. Take the first, then move and take another photograph to capture the image data where you used to be standing. Then, before aligning your photographs, construct masks on the two nadir photographs to exclude yourself.

[11] Ignoring this step caused me hours of grief. On my father-in-law's camera it was 127°. If you need to change it after you've already loaded all of your photographs, go to the Camera and Lens tab, select all of your photographs, and enter the correct value into the degrees of view (v) field.

[12] For this to work properly, make sure you've enabled rotation search: Choose File, then Preferences, then the Control Points Editor tab, and check the box that says Enable rotation search (slower, but more accurate).

[13] The first thing to try is to go to the Images tab, select two pictures you know overlap, and hit the Create control points button. If that doesn't work (it often doesn't), then you'll have to put them in manually. Go to the Control Points tab. You will be able to look at two images simultaneously. Choose two that you know overlap. Click on either one at a point that you know is shared between the two images. Now click on the same point in the other image. Hugin will try to align the points. If it succeeds, hit the Add button. If Hugin doesn't find the right points for both images, move the crosshairs until they do and then hit the Add button. Try to spread out your control points as much as possible so that Hugin knows how much to distort the images. I shoot for 15–20 control points per image, but I've gotten it to work with as few as 5. Repeat these steps until all of your images are connected.

[14] This isn't the first time I've photographed a rainbow at that park. See my post Week One (scroll down).

[15] See http://www.deseretnews.com/top/127/6/The-Knight-Mangum-Hall-The-development-of-the-Language-Training-Mission-LTM.html.

[16] See my post Summer Walks.

[17] If you've never heard of root nodules, see my post What Is It That Matt Does, Anyway?

[18] See some of my photographs of bacteria at my post The End of Procrastination III.

[19] See my post Trip to Texas.

2 comments:

  1. Super cool. I have a slight preference for the tunnels.

    (Alas, when I tried to stitch photos on Hugin on my computer two years ago, the program always locked up.)

    ReplyDelete
  2. I started having that problem, too, but got around it by changing it to open the regular preview first instead of the quick preview. If you ever revisit Hugin, you might try that.

    ReplyDelete