Friday, December 24, 2010

A quick look at HDR

Your eyes can easily adjust to accommodate the lighting conditions of your environment.  If you are in a room with brightly lit areas and deep shadows, the pupils of your eyes will increase or decrease in size to adjust the amount of light so that you can see both extremes in fair detail.  When you photograph a scene such as this you set the aperture (and shutter speed) of the camera to insure the proper exposure for the amount of light present.  If the "dynamic range" is too wide, there may be some areas that are either too dark or too light to see any detail.   The following photographs were taken in my garage (you can click on any of the images to go to full size). Photo 3) was taken with automatic exposure settings, and you can see that there are areas in the photo that are completely overexposed (the garage windows and the light on the clay pot), and areas where the shadows are so dark that detail is lost.  The other images were taken by varying the exposure to allow more or less light to be used.


 1)  Overexposed by 3.3 stops
 2) Overexposed by 1.7 stops
 3) "Proper" exposure
 4) Underexposed by 1.7 stops
5) Underexposed by 3.4 stops







Notice that in the 1) you can see details in the back corner where there is little light, but nearly everything else is "washed out".  In 5) very little detail inside the garage is visible, but you can actually see some details outside the garage through the windows.

HDR techniques allow us to combine two or more of these images so that the overall dynamic range is compressed.  The following two images were created from the above images using HDR software:

 PhotoShop CS5.  (easy, simple, $$$$$)
Hugin.  (confusing, free)







PhotoShop allows you to do some initial adjustments during the HDR creation.  The image using only the defaults was a bit dull and a underexposed using the defaults, so I applied a few adjustments to get it to match the Hugin HDR.  If you enlarge the two HDR images you can see a few differences--for example there is a bit of ghosting in the upper left corner of the Hugin image, but in general they both have a significantly larger dynamic range than the "proper exposure" in 3).

References:
1)  Wiki article on HDR (in depth, but quite good).  http://en.wikipedia.org/wiki/High_dynamic_range_imaging
2)  Creating HDR images with PhotoShop CS5
3)  Creating HDR images with Hugin

Thursday, December 23, 2010

Creating HDR images with Hugin

While PhotoShop CS5 is the easy way to generate HDR images, Hugin is an amazingly powerful and versatile program that can be used to create HDR images as well as stunning panoramas.  The great thing about Hugin is that it is absolutely free (open source software)--the bad thing is that it is not as easy to master as PhotoShop (although some would disagree with that statement).  Go to the link How to install Hugin on your computer if you do not have Hugin installed on your system.

The following screen captures should help guide you through the somewhat complex procedure you need to follow to generate your HDR.  Remember that you can click on the image to enlarge it if you have trouble reading it.  I have tried to highlight the important tabs and controls discussed in red.

After starting Hugin, select the files that you want to merge into an HDR image (either use the Load images button or drag the files into the Hugin window.


After loading the images, click on the "Images" tag and you should see a view similar to the following:


You can examine each of the individual images by selecting them from the list.  A thumbnail and some of the efix data for the photo.  You should not check to make sure that the Settings box has "Autopano-SIFT-C" selected (and make sure you have loaded it--see "How to install Hugin on your computer".  Then click on the "Create control points" box.


You should see a pop up box that will show what the program is doing (don't worry about what it says--it is mainly useful when debugging problems).  After a few second (or longer, depending on your computer, number of images, etc.), a new pop up box will appear telling you how many control points were located:


After clicking on the "OK", switch to the Assistant tab as shown below.  Make sure the lens type is "Normal (rectilinear)" and then select "Align..."  After a few minutes a new window (Fast Panorama preview) will appear.  If it does not, click on the symbol in the Hugin toolbar with the "GL" on the image.


By using the various tools available (start with drag), your can adjust the image so that it appears as shown below:


Once the image in the preview window appears correct, go to the "Stitcher" tab in the main Hugin window.


Click on the "Calculate Field of View" tab, followed by the "Calculate Optimal Size" tab.  Next, click on the "Camera and Lens" tab.


Click on "Reset" and set Exposure "to zero (no exposure correction)".  Click on OK and return to the Stitcher window.


In the Stitcher window, make sure Recitlinear is still selected, check the "Fused and blended panorama" box in "Output", and click the "Stitch Now" button.  You will get a pop up box asking for the location and name you wish for the final HDR image.

At this point I will confess that much of what I have described above had been determined by trial and error.  It may be possible that some of this is unnecessary, and there may be other pitfalls that I have not described.  One (annoying?) feature I have noticed in Hugin is that it tends to occasionally remember what you did the last time you ran the program, so some times you may find a box selected in a way you did not expect.  Feel free to let me know if you find errors and I will try to correct them.

How to install Hugin on your computer

Hugin--"an easy to use cross-platform panoramic imaging toolchain based on Panorama Tools."
If you don't have Hugin, get it!  If you have it, make sure your version is current!  Hugin is one of a number of "open source" projects that groups of volunteers are developing.  SourceForge allows groups to share and distribute software and is a fantastic resource for users looking for free software.  The best place to keep current with Hugin is the Hugin SourceForge page at: http://hugin.sourceforge.net/.

On the Hugin SourceForge page there will be a link to download locations for stable binary releases for various platforms.  When you go to that link you will want to download the latest precompiled version for the platform you are using (windows, Mac, possibly others).  The version in use for these demos is the windows 2009.4.0.  When you click on the (in my case) windows link you should get the download panel:

 
After downloading (click on Save File button) the "Hugin_2009_0_4_win32_setup.exe" file, execute it and the executable files will be installed. One additional program, Autopano-SIFT, (used to find similarcontrol points in the images) must also be downloaded, but it is not included with the preinstalled software due to licensing issues.  Go the the Autopano-SIFT link, select "Download", then select "autopano-sift-2.3-win-1.exe" to download the file and put it in the Hugin folder that was created during the latter installation (probably in the C:\Program Files directory).

Once you have Hugin installed, I strongly suggest you spend some time going through the Tutorials that can be reached from the Hugin Home page.

Creating HDR images with PhotoShop CS5

As is the case with most things in PhotoShop, once you know how to do something it is easy--unless you don't do it every day and forget!  This is just a quick how-to for creating images with CS5 (the same instructions will work with CS4 as well although the interfaces are a bit different).

(Remember, you can click on the images below to enlarge)

The easiest (and preferable method) is to use Bridge.  I know a few people who have never learned to use Bridge--don't be one of them!  With bridge you simply select the images you want to merge into and HDR and then select Tools; PhotoShop; Merge to HDR Pro:


This technique will merge the selected images and bring up a dialog box that allows you to "fine-tune" the image:

One particularly useful tool is the "Remove ghosts" checkbox shown above.  Checking this box will eliminate "ghosts" due to leaves blowing, people moving, etc.

There may be times when you would prefer to have a finer control over the image.  In such cases you can load the individual images into PhotoShop layers and then :
    1)  Select all levels
    2)  From the menu select: "Edit; Auto-Align Layers"
    3)  Upon completion select: "Edit; Auto-Blend Layers"
    4)  Check the "Stack images" button
At this point you can see what parts of each image are used in the composite and can presumably adjust the layer masks.  Note that this is the same procedure used to stack images to increase the depth of field such as in photomicroscopy.

Tuesday, May 11, 2010

Microphotography

I don't think I have ever thrown away anything that had a lens in it! As a result I have been able to come up with an amazing collection of "junk" that occasionally proves it's value. Some of the systems below were purchased (mostly at auctions) because I knew what I was getting, while others were just "in the junk pile".  Here is a description of my current active collection:

Nikon FS-2 bioscope

I probably take more photos with my "Slit Lamp" system than any other. It is a Nikon FS-2 bioscope that was part of a skid of obsolete optometry equipment. I stripped most of the slit lamp part of the hardware and made a sample table. My Nikon D80 attaches to the back and allows me to take photos at several magnifications.  The beauty of this system is that it can be used to take stereo pairs since the bioscope was designed to rotate about the focal point of the "sample".  the joystick system allows one to rapidly move in and out or to a different part of the sample.  It can take photos in the range 2x to 30x.

Nikon Alphaphot 2

This system is for high magnification work. When I acquired it I was taking a chance since it had been in a fire and was covered with black soot.  Originally it had a secondary viewing port so that it could be used in a "teacher-student" mode.  Since the secondary port was in bad shape I removed it and made an adapter so that my D80 will attach to the port using a T-adapter.  It can be used to take images up to 400x.


Nikon Model M Inverted Microscope

This is my "best" system in that it is a true research microscope designed for microphotography.  I managed to get it at an auction at a ridiculously low price (with all accessories and spare parts!).  While it was made in 1969 the optics and mechanical parts are in pristine condition.  It has a complete set of objectives and specialized accessories that I may (or may not) figure out how to use some day.

The Nikon D80 is attached to the "cine" port in the above picture using a t-adapter and standard eyepiece fitting.  The camera can also be placed on the trinocular head although I usually use a small CCD video camera on that port that can record to my computer.

These three systems are the "primary systems I use.  In a future blog I will describe some of my other less used systems and some general comments about microphotography.

Wednesday, March 3, 2010

Stereo photography (BPC Panorama Focus group)

Getting started in 3D Stereo photography is no longer difficult and can be done with with little or no investment (in both money and time!).  There is a dedicated group of enthusiasts who are developing the techniques and software, and with a little effort anyone with a digital camera and computer can generate fantastic images.

The software used by most of the 3D groups is "StereoPhoto Maker", written and maintained by Masuji Suto (I use hyperlinks here, so just click on the highlighted text above to go to a referenced url--use "shift" + click to open in a new window).  From the SPM site you will want to download and install the latest version of SPM (I suggest getting the version with the help file).  The latest version (as of this writing) is Ver4.21, released February 24, 2010.  You might want to bookmark this site since the software is being continuously updated.  The download is a zip file consisting of the help file (HTML) and the actual program, stphmkre.exe.  Place the latter on your desktop and simply double click its icon to start the program.

I suggest you also download the "SPM Beginner's Guide" which is a .pdf file that gives good "step-by-step" instructions. In order to get you started, I have uploaded images to Flickr for two 3D photos.  The first is the cemetery picture I shared during the January BPC photoshare.


You should be able to see this with the glasses handed out at the last focus group meeting. The left eye image, right eye image, and a side-by-side and color anaglyph are available to download from my Flickr site.*

Place the left and right eye images in a folder and start SPM.  Under "File" select "Open Left/Right Images".  Locate and select the left and right eye images and click "open".  If you then select "Adjust" and "Easy Adjustment" you will be able to fine-tune the two images so that they overlap nicely (actually little adjustment is needed for the cemetery photo since I used my "stereo camera".

Once you are satisfied that you can use the program try downloading the left eye and right eye images for the barn in my back yard.  This one is tricky!  I took it with my Nikon D80 (hand-held) and just moved over about 6 inches between the two shots.  I purposely tilted the camera for the second shot.  An additional problem is that there was a slight breeze, so the bird feeder has rotated between the two shots.  Thus, the resultant 3D image is terrible!  But--it does actually come out more or less OK.  Keep in mind that you have to rotate as well as translate in the "Quick Adjustment" window.  You will notice that I cropped the image.  It is difficult to focus because the two images are a bit too far apart (hyperstereo--not good for most shots!).  In any case the following is my version of the left-right stereo.  You can also download the anaglyph to see if you can see it.


There are all kinds of options and tricks to learn about taking and "processing" stereo photographs, but don't give up if you don't get the results you want immediately.  I really didn't know what I was doing (and some will say I still don't!) when I started, but I find the results very satisfying.  I admit I have an advantage since I spent much of my professional life looking at stereo images, so my eyes can adjust rapidly and I can "accommodate" many flaws.

Good luck and have fun!  If you have questions or need help just email me.
________________________________________
* To download images from Flickr, click on the "ALL SIZES" button at the top left of the image and then click on "Download the Large size".