Raspberry Pi Microscopy

by Howard Webb (Bloomington, IN, USA)

Background

I have been absent from Micscape for some time due to frustrations with photography. New technology was making my old 6 meg pixel camera outdated, yet the newer consumer grade cameras lacked a lens mount (unless I wanted to pay for a 35 mm digital). Other circumstances got me involved with Raspberry Pi computers, and investigating all their potential. Recently I was looking at the camera attachment, and realized that there was now an 8 meg camera available for only $24 (US), and that got me thinking again about photomicroscopy. To my surprise, there were a number of people who not only have had this idea, but have built working implementations.

The following were some quick experiments with an old slide and a convenient sample to check the ease and potential of Raspberry Pi photomicroscopy.
I think the results are quite respectable for the effort, and this is likely to get me back involved with more projects.

Bosmina

Bosmina

 

Copeopod

Copepod

 

Algae

Algae - wet mount

Design

The Raspberry Pi camera is a Sony IMX-219 8-megapixel sensor delivered as a 'board' camera with a ribbon cable that plugs into the Pi - it is basically just the sensor chip with a small lens. There are several options, as the lens easily unscrews, giving you easy access to the bare sensor (ie. think of a 35 mm camera attached to the microscope with a traditional "C" mount, where the only optics become the microscope objective).

The simplicity of the camera has advantages.

1) I am not fighting the cameras automatic controls (focus, light balance, ...). The Pi camera is dumb - unless you want to add your own programming smarts (and there are a lot of options).

2) Looking down through the camera's view screen was always a pain in the neck (literally), and the camera view screen was so small it was hard to be sure of the focus. With the Pi, I have gone pure digital; everything is done from the monitor.

I initially tried using the camera without the lens. Holding the sensor over the microscope tube (without the eyepiece), this gave a clear image, but the angle of view was so small that I ended up with magnification without resolution. This would be a great option for a "C" mount with an intermediary lens, but for now I was looking for an easier path.

I ended up mounting the camera to a PVC adapter, which holds the camera over the eyepiece. The stock lens has an angle of view that is larger than the eyepiece, so I have a round image in a black field; rather than the image filling the whole sensor. This could be remedied by getting a different lens for the camera (with a slightly smaller angle of view), but this is again more work than I wanted to do for a quick evaluation.

My Raspberry Pi is a version 3-B. You could get by with an older version, but I got this for a different project, and the computer is only $35 (US). It is running the latest stock Raspian operating system, and hooked up to a keyboard, mouse and 22 inch HDMI monitor. This gives me a full function computer (even if low powered), complete with a Python coding environment (which will come into use later).

The camera comes with a 6 inch ribbon cable, but I replaced it with a 2 foot ribbon (this was an easy swap).

My mount is a 1.5 inch piece of PVC pipe, with a scrap of PVC flattened and glued to one end for mounting the camera. I used 1/4 inch nylon bolts to clamp it to the tube. This tube is a bit big for this scope, but it allows me to use the same mount for other scopes (inclulding telescopes). Other mounting systems are available, from electrical tape to 3D printed mounts and machined aluminum. Pick what you want based upon your skills and budget. Google "Raspberry Pi microscope" and you realize that what I am doing is far from original.

Algae

Microscope with attached camera

Software

The one weakness to this system is software - there just isn't much available, it is basically a 'do it yourself' kit. There are good image libraries available in Python (picamera), but these are toolkits, not a product; however, it doesn't take much coding to get started by cutting and pasting code from the sample recipies. The IDLE IDE (Integrated Development Environment) comes pre-installed with the Raspberry Pi operating system (Noobs install of Raspbian Jesse).

Attached are two simple python scripts. One is a simple full-screen monitor for just looking at things, the other takes some keyboard input for capturing images. Again these are basic, there is no control of the camera settings in this code, but it will get you started.

The other piece of software I recommend is CombineZP, image stacking software that takes multiple images saved at different focus settings, and combines them into one image that has sharp focus for the whole depth of the image. The software is free and simple to use. Rather than an image with limited depth of focus, the combined images (I use 20 to 30 images) create a single image that is sharp through the full depth. The only problem with this technique is that it doesn't work with live specimens which are moving about.

Microscope: my old standby: Bausch & Lomb monocular, 10x ocular, 4x, 10x and 40x objectives.

Camera: Raspberry Pi (8 Megapixel)

Software: Python, CombineZP

Comments to the author are welcomed.

Microscopy UK Front Page
Micscape Magazine

Article Library


Microscopy UK or their contributors.

Published in the February 2017 edition of Micscape Magazine.

Please report any Web problems or offer general comments to the Micscape Editor,
via the contact on current Micscape Index.

Micscape is the on-line monthly magazine of the Microscopy UK web
site at
http://www.microscopy-uk.org.uk/