Thursday, June 14, 2012

How to Fill in Transparency in a Hugin Panorama

After I started using Hugin [1] to create panoramas, I quickly ran into a problem where I wanted to keep certain parts of the original photographs in the panorama, but because of the way everything lined up, they either had to be cropped or empty (transparent) areas had to be created in the image. The other graduate student in my lab, Ryan, showed me a video that showed a new feature in the latest version of Photoshop, called Content Aware Fill.[2] Basically it analyzes the surrounding pixels and creates similar content to fill in the target area. I didn't feel like forking out hundreds of dollars for Photoshop CS5, so I went looking for a way to do the same thing using the GIMP.[3] I found a plugin for the GIMP called Resynthesizer.[4] As it turns out, this feature has existed for GIMP longer than it has for Photoshop—and the Photoshop tool is derived from the GIMP tool! Now, let me show you the magic:

Last fall I took some pictures on the south end of Utah Lake, while birding with Leann and Lillian [5], that I wanted to make a panorama with. Above are the original component pictures.[6] All three had undesirable lens flares.

I used Hugin to stitch them together. But, as you can see, there were some problems. Along the bottom is a big stretch of transparency. There's also a spot in the grass that is transparent. This happened because I used masks in Hugin to get rid of the lens flares in the first two photos. And there's a flare in the top right (from the third photo) that I didn't remove with Hugin.

I first fixed the transparent spots by choosing from the drop-down menu: Filters, then Enhance, then Heal transparency... I set the Context sampling width to 100 pixels [7] and the Filling order to "Outwards from center". It's almost hard to believe that the view didn't originally look like that!

That still left the one lens flare, so I removed it. To do that I drew around the target area using one of the Select Tools then I chose from the drop-down menu: Filters, then Enhance, then Heal Selection... For this project I set the Context sampling width to 100 pixels and the Filling order to "Inwards towards center". Voilà! It's gone.

Since our camera has a tendency to make things look gray, I also adjusted the color levels. From the drop-down menu choose Colors, then Levels... Move the little triangles under the part of the window that says Input Levels until it looks the way you want it (be sure the Preview box is checked). And there you have it: a panorama with the transparency fixed, lens flares removed, and the color enhanced.[8]


[1] See my post Make Your Own Panorama.

[2] You can see that video here.

[3] See my post Raster Graphics and Vector Graphics.

[4] You can download an older version by following the steps listed here, or the newer version by following the steps listed here. Both of these sets of instructions are for Windows. If you want the newer version of Resynthesizer, you'll have to first uninstall GIMP before following the instructions at the website I linked to. Be sure to follow them all! You can install the latest version of GIMP (here), but be sure not to install later versions of Python.

[5] See my post Lillian's First Birding Trip.

[6] They're not exactly the originals. Because Blogger has a limited amount of image and video storage, I've reduced their size and converted them to .png files.

[7] The default, 50 pixels, is usually sufficient. But for some reason 100 pixels gave me a better result for this project, so that's what I used.

[8] I have no explanation for this, but on Macs the retouched image looks oversaturated and washed out, while on others it looks just fine.

No comments:

Post a Comment