Introduction: Microscope Photography With Webcam or Point-and-shoot Camera

I'll describe two easy ways to take pictures through a microscope, one with a point and shoot camera and one with a cheap webcam.  I'll also explain how to calibrate the sizes of objects in the pictures.

The "afocal" point-and-shoot camera method is easier, the images are brighter and more colorful, but the magnification is significantly lower.  The "prime focus" webcam method will give you a very high magnification, quite a bit higher than your microscope normally provides when you look through it.  The color will be more subdued and resolution will be lower.

Both methods are really quite easy, but I'll go into a lot of detail.

What you need

For both methods:

  • Optical microscope (I use a surplus Spencer)
  • Samples: a number of my photos will be prepared slides that one can buy; some will be micrometeorite candidates which one can collect; some will be bits of plant matter from the yard; and I also have a meteorite sample that I bought
  • Optional: Phone or PDA or other device with backlit LCD screen and known resolution for determining magnification
For point and shoot method:
  • Camera (for many of the photos I used a Sony DSC-W55, and for some I used a Canon G7)
  • Optional (for comfort): PVC tubing or empty film canister, and easily removable tape (e.g., painter's tape)
  • Optional (for photographing opaque objects): Bright LED flashlight
For webcam method:
  • Microscope with removable eyepiece
  • Webcam which you can disassemble (I use a Logitech Chat)
  • Computer (Windows, OS X or Linux)
  • Easily removable tape
  • Optional (for photographing opaque objects): Bright LED flashlight
Note on transmitted and reflected light microscopy

There are two ways of imaging a sample.  One way is you shine a light through it, typically from a light bulb in the base of the microscope.  This produces bright images of translucent objects.  The other way is to shine a light at the top surface of a sample, and then image the reflected light.  Our microscope is built for transmitted light use and so this is more difficult--I would either illuminate with a bright flashlight or a reflection of the sun.  The result isn't ideal, but reflected light is the only way to image opaque samples, such as rocks or micrometeorites.

Step 1: Point and Shoot Camera, Transmitted Light

The simplest way to photograph through a microscope is to focus the microscope on the sample, hold the camera right above the eyepiece set to auto focus, and click.  This produces surprisingly good results.  Sometimes setting macro mode helps, but not always.

If your camera's front lens and the microscope eyepiece have the glass recessed you may be able to touch the camera lens to the eyepiece top without the glass on either side touching anything, which provides some support for the camera.  Obviously, you don't want the glass to touch anything to prevent scratching.  If there is a danger of glass touching, putting a plastic washer on top of the eyepiece or making a cardboard ring to put on top of the eyepiece may help.  

For ease of use, you want to make something to hold the camera in place.  In the case of the Sony DSC-W55, it turned out that cutting off the bottom from a film canister produced a tube that snugly fits on the outside of the camera lens and goes around the eyepiece.  For greater stability, for some of the photos I taped the canister in place around the microscope tube that holds the eyepiece.  I used paper painter's tape so it would come off without leaving residue.

If a film canister isn't the right size for your microscope and/or camera, it shouldn't be very hard to come up with something out of PVC or cardboard tubing.

Warning: If the camera retracts its lens while held in place solely by the adapter, like in the photo below, it will fall off.  So keep a hand on its strap if there is any danger of that, and don't leave the camera like that for any extended period of time.  A bit more tape to hold the camera in place if the lens retracts might help.

You may want to play with zoom settings on the camera--I found that normal, unzoomed works better.  Generally, using the microscope with a lower magnification eyepiece produces sharper looking images.  And turn off the flash.

You need to focus with the microscope.  If all goes well, the camera will take care of its own focusing.

If your eyepiece has a pointer and/or measurement scale, you may want to remove it or keep it, as you wish.

Step 2: Point and Shoot Camera, Reflected Light

If your microscope has a light mounted near the objective, it's easy to view and photograph opaque samples.  

I wanted to view and photograph micrometeorite candidates extracted with a magnet from near a downspout (see this excellent Instructable), but our microscope only illuminates from below.  I ended up taping a bright LED flashlight to the microscope (painter's tape is great as it'll leave no residue), pointing at the sample.  This wasn't always the best solution--sometimes hand-holding the flashlight and putting it in a different location produced a better image.

Probably because of the steep angle of the flashlight, a lot of the images are fairly dim.  I also experimented with using a mirror (actually, a hard drive platter!) to reflect sunlight.  That was a bit brighter than the flashlight, but more finicky, and in the end probably not worthwhile.

When using reflected light, if your sample is on glass, it's a good idea to put a piece of paper or cardboard under the glass as a background.

You will probably find that higher magnifications don't work very well for you.

Some soft three-dimensional objects may need to be pressed down to be focused well.

Step 3: Attaching a Webcam to the Microscope

Before you start, make sure your computer has drivers for your webcam.  You want to try out the camera and your webcam software before disassembling it.  

1. Unscrew your webcam case and remove from the case the circuit board with the USB cable.  

2. There will be a round plastic lens assembly.  Unscrew it from the board.  

3. Under the lens assembly, you should find a recessed area with a very small sensor.  Keep the sensor clean and don't touch it.  I recommend keeping the lens assembly on whenever you're not actually using this.  I've just blown off dust when I needed to.

4. Remove the eyepiece from the microscope.  Place the circuit board with the sensor pointing down on top of the tube.  Try to center the sensor in the tube where the eyepiece was.  Gently tape the circuit board onto the tube, trying if possible not to attach the tape to any electronic components that might break when you remove the tape or that might overheat in conjunction with the tape.  The first time I did this, I used electrical tape.  The second time, I used paper tape.

Step 4: Prime-focus Webcam Pictures, the Simple Way

Now, hook the USB cable up to your computer. Start up your webcam software. You should see a rectangle full of noisy pixels.

The simple way to take pictures is just to put in a sample, illuminate it (either with the microscope's light, or with a flashlight like in step 2), focus the microscope, and then use the webcam software (or software built into Windows; on Windows XP, I could just double click on "My Computer", double click on the webcam, and then there was a button to take pictures; on Windows 7, my webcam needed the Logitech software) to take still pictures.

You will notice that it's harder to find the sample than with a point-and-shoot camera on top of the microscope, because the magnification is probably going to be very large, because the webcam's sensor is very small.  The colors are likely to be washed out, too.  (If you really want better color, you can try to do what amateur astronomers often do--photograph in grayscale through red, green and blue filters in sequence, and then put the images together.)

Focus carefully with the microscope.

For better quality, you can do this with a lensless DSLR, but I don't own one, so I won't try to give instructions.

There are two problems with this method.  One is sensor noise.  The other may not come up for you, but did come up for me: with well-illuminated transmitted light samples, I had wave artifacts on the screen, probably due to the interaction between the 60Hz AC running the microscope light and the 30 frame per second rate of the camera.  The next step shows how to fix both problems.

Step 5: Stacking Webcam Pictures, Introduction

The photos in step 4 showed a fair amount of sensor noise.  There is a trick to fixing this which one can borrow from amateur astronomers who use webcams to image the moon and planets (like this moon photo that I took using a webcam, Avi Stack and my 8" F/4.5 telescope--more photos here).  Instead of taking a single picture, one takes a short movie containing a number of frames.  The ones I did ranged from 30-90 frames (i.e., one to three seconds).  Then one uses stacking software to combine the frames into a better image.  Good stacking software also allows you to use wavelets to adjust sharpness in pretty sophisticated ways.

I used the free Avi Stack for stacking (you can also use the also free Registax), which works on Windows, Mac and Linux.  You can capture the video with your webcam's software, but I found that it's better to use wxAstroCapture, available for Windows and Linux, as my webcam software wanted to produce .mpg files, and then I had to convert them to .avi files with Windows Movie Maker.  

So, install Avi Stack (on Windows, you just unzip it into any directory where you want it) and and any video capture software you need.  You need to make sure your capture software produces videos in a format Avi Stack can understand.  See Section 2.3 of the Avi Stack manual for supported formats.  On Windows, I strongly recommend you follow the instructions in Section 2.3 to install support for additional Windows .avi codecs: go here, and download the file by unzipping its contents into the directory where Avi Stack got installed.

Once you have all this installed, capture a small .avi segment of your sample with your webcam.  Don't worry if there is noise jumping around.  Here's an example.

Step 6: Using Avi Stack to Stack the Frames

Assuming you've captured an .avi sequence, now launch the AviStack2 application.  You should get an IDL 7.0 screen.  Click on the "AviStack2" button and then again on "Continue".  You will finally get three windows: the main one entitled "AviStack 2.00" (or whatever version you have), "Display" (which will show your image), and "Parameters and Settings".  

Go to the menu in the main window, and choose "Settings", "Processing" and "All automatic (except post-processing)".

Then choose the "Add Movie" button, the first button in the button bar.  You'll get a large window.  Navigate to the directory where you saved you .avi file, choose your .avi file, and click on "Open".

Then, back on the main screen, make sure your .avi file is highlighted in the main window, and click "Process file".  A display window will come up where all sorts of things will happen for a couple of minutes (depending on how fast your computer is).  

Finally, you'll get a very busy screen.  If it's not as busy as in my photo, you may want to go to the Parameters and Settings window, and expand things until you get to Post-processing, and then check Wavelets, Histogram and Levels.

You can adjust levels like in any photo editing application.  You can also do wavelet sharpening--see the Avi Stack manual for more information.  

Once you're satisfied with your image, in the Post-processing window, click on "OK".  Then choose the file format you want to save as.

You may want to load the image into a photo editor to make fine adjustment.  You might, for instance, find that converting to grayscale improves things.  

Step 7: Optional: Getting the Scale of the Images

What if you want to know how big the fields of view in your photos are?  Well, take a picture of something you know the size of, using the same microscope objective, eyepiece (if any) and camera settings.  

You could take a photograph of a ruler, but that will only work for low magnifications.  With the webcam, the thickness of the line in the millimeter divisions on my steel ruler covered about half of the field of view, and I couldn't see the next line over.

But there is a very simple way to do this.  Take any phone or PDA whose screen resolution you know.  In my case, my Treo 700P.  Turn it on and place it under the microscope.  Take a focused picture.  You will see the pixels.  Each pixel is made up of three subpixels: red, green and blue.  By measuring the width of the screen, you can figure out how wide a subpixel is.  (When I talk about the width of the subpixel, I include the spacing on one side of it).  

For instance, my Treo has a 320x320 screen which is 43mm wide.  So each pixel is 0.1344 mm wide, and each subpixel is 1/3 of that, or 0.0448 mm wide.  

Then count how many subpixels wide the image in the photo is.  For instance, in the second photo below, I'd estimate it at around 9.6 subpixels.  Multiply by the size of a subpixel: 9.6 x 0.0448 = 0.44 mm.  And then do a sanity check--does the number make sense?  Yes, it does: when I put the ruler under the microscope, I couldn't get a whole millimeter.

At  low magnifications, the counting may be challenging.  You might do better counting vertical lines of pixels (but measure your screen vertically, too--you shouldn't assume squareness).  For instance, at lowest magnification using the Sony W55, I get 28 pixel lines in the image circle, or 3.7 mm.

Step 8: Optional: Telescope Eyepieces

You can increase the range of magnifications by using telescope eyepieces in the microscope.  This may also make it easier to connect a camera as there are plenty of adapters for connecting telescope eyepieces to a microscope.  Telescope eyepieces are denominated in focal length, not magnification.  A 10X microscope eyepiece is an eyepiece of 25mm focal length.  In general, an eyepiece of focal length L corresponds to a microscope eyepiece of nominal magnification 250mm/L.  For instance, a 13mm eyepiece corresponds to a nominal eyepiece magnification of 19.2X.  (The actual microscope magnification also needs to take into account the objective.)

Telescope eyepieces will often have a wider field of view than the eyepiece that came with your microscope, and hence more pleasant to use.  Even a relatively very inexpensive $20 Plossl (e.g., from Owl Astronomy) might work very well.  

Typical telescope eyepieces have a barrel with outer diameter 1.25".  This is more than the 23mm or 30mm barrel diameter on microscope eyepieces.  The trick I use is to make an adapter that sits around the microscope tube where the eyepiece goes, and provides a short barrel with inner diameter 1.25".  I did this by partly nesting two tubes.  An wider tube whose inner diameter is 1.25", and an inner tube whose outer diameter is 1.25" and whose inner diameter is equal to the outer diameter of the eyepiece holding tube on the microscope.  The two are offset as in the picture (actually, the offset on the top side is bigger--the drawing is not to scale), so that the telescope eyepiece sits within the larger tube and on top of the smaller tube.  

Note: Make sure that nothing protrudes in such a way as to hit the glass of the telescope eyepiece!

I had an aluminum tube with inner diameter 1.25", so I used that for the bigger tube.  I didn't have any tubing for the smaller tube, so I took some 1.25" poplar dowel and drilled it out with a Forstner bit and a drill press to make a wooden tube.  Then I glued the two in the offset position.  This works great for looking at things, and can be used for photography as well.

Some telescope eyepieces have a thread for attaching the camera, often but not always a T-thread.  Then all you need is a threaded filter adapter for your camera, and any step-down or step-up adapters that might be needed.  

Camera & Photo Skills Challenge

First Prize in the
Camera & Photo Skills Challenge

4th Epilog Challenge

Participated in the
4th Epilog Challenge