top of page
  • Daniel Knop

Focus stacking – what’s that?

Aktualisiert: 25. Apr.


In the wake of high-resolution digital photography, a shooting technique was developed that can create any depth of field with computer assistance: focus stacking. The popularity of this method has increased enormously during the recent years. The basic principle is explained here.



Chrysiridia rhipheus Flügelschuppen 20 x
Wing scales of the butterfly Chrysiridia rhipheus, photographed with a microscope objective (HLB Planapo 20x) – on the left a single photo, on the right a focus stack of 200 photos


Every macro photographer knows the problem: the closer the camera is to the object being photographed, the shallower the depth of field. In addition, there are other factors: as the focal length of the lens increases, the depth of field decreases, and the lens diameter also has a drastic effect, because the larger the lens, the smaller the depth of field. A medium format camera with a larger film format or digital sensor also has a correspondingly larger lens and, compared to the 35 mm format, the depth of field of its images is frighteningly shallow. This is completely different with the tiny lenses of smartphone cameras: their depth of field is so enormous that portrait photographers have to use internal algorithms to blur the background of the image. Such mini lenses are therefore ideal for close-ups, as they allow us to achieve depths of field that we can only dream of in 35 mm format.


This depth of field problem in close-up photography is as old as camera technology itself. In microscope photography, this problem is even more acute, as the depth of field here is only a tiny fraction of a millimeter. The solution to this problem is relatively simple and can be implemented with reasonable effort. It is called focus stacking and requires little more than a conventional digital camera, a linear stage with a finely adjustable feed, an inexpensive computer program and – of course – a computer. You can even do without the linear stage on the microscope, as it is virtually built in there as a coarse and fine drive.



Fliege Focus Stacking Einzelaufnahme
Photo of a prepared gold fly – only the edge of the wings is within the depth of field of the lens. Such a photo is simply unusable, but the depth of field cannot be increased sufficiently by conventional means, e.g. by using a smaller aperture.



Narrow zone of focus

Let's start with the theory: in macro and magnifying photography, only a small part of the object is in focus – only what is within the depth of field. In a landscape shot with a wide-angle lens and a large shooting distance, almost everything fits in. In a full-frame macro shot of a raspberry, on the other hand, the majority of the object is blurred, as the depth of field is then narrower than the berry.


Strictly speaking, instead of depth of field we should even talk about the plane of focus, the focal plane, because only the center of the depth of field is really optimally sharp, and this plane is paper-thin. In front of and behind this thin focal plane, the sharpness decreases continuously in both directions. However, we do not recognize this blurring in a certain close-up zone as such, because it still appears sharp to our eye, and this is exactly what we call depth of field.


If, for example, we take a full-frame photograph of a fly's head with a magnifying lens, for example at a reproduction scale of 4:1, at worst only a narrow strip will be in focus. Using the focusing ring of the lens, we can now move this strip-shaped zone of sharpness on the fly's head back and forth, but it will not become wider by focusing – try it.




Fruchtfliege Focus Stacking Einzelaufnahme
Head of a fruit fly Drosophila melanogaster, photographed with a microscope objective – the depth of field is so shallow that only one stripe can be in focus


We achieve the same thing if we move the entire camera back and forth instead of focusing on the lens, because this changes the distance to the object. (In fact, I often work like this for macro shots and don't focus using the focusing ring, but by varying the shooting distance).


Focus stacking

The solution to the depth of field problem is called focus stacking. The trick with stacked shots is that a series of individual shots is taken in which the narrow focus zone is moved over the object bit by bit. An easy-to-use computer program is then used to extract the high-contrast, i.e. sharp-looking parts from each of the individual images and combine them in a second step to create a new, consistently sharp complete image. This sounds complicated, but with the software versions available today, it runs automatically.


Porträt einer Fruchtfliege Drosophila melanogaster, ca. 2 mm Körperlänge – die drei Einzelbilder
Portrait of a fruit fly Drosophila melanogaster, approx. 2 mm body length – the three individual images (left and center) show the extremely shallow depth of field, which can only show a very small area in focus in each case. In the combination of 200 individual images (right), the entire animal is in focus.


This procedure can be combined with many photography techniques. You can use a camera with a conventional macro lens (image scale up to 1:1), a magnifying lens (1:1 to 5:1) or a microscope lens (up to well above 5:1). Some special lenses are also suitable for this, e.g. those of very high-resolution slide scanners – I will go into this in a separate article. The more you zoom in, the shallower the depth of field and the more important the new focus stacking technique becomes. And of course this technique can also be used with a conventional reflected or transmitted light microscope. The whole process can also be automated, as will be explained in detail in a separate article.



Schleimhautzellen im menschlichen Dünndarm unter dem Lichtmikroskop (Azan-Färbung, Heidenhain-Präparat, Ausschnitt)
Focus stacking in microscopy: mucosal cells in the human small intestine under the light microscope (Azan staining, Heidenhain preparation, crop), left half: a single image that illustrates the shallow depth of field under the microscope, right half: focus stacking image with continuous sharpness


The light scanning process

Focus stacking is actually not a completely new invention, as there was a predecessor in analog photography that solved the depth of field problem in a very similar way, but without a computer. In the 1990s, Swiss photographer Peter Fehrlin, a specialist in technical and scientific macro photography, combined a stereo microscope with a special lighting method in which not the entire object was illuminated with light, but only a tiny part of it, precisely the part that was within the depth of field (light-scanning illumination from Irvine Optical, USA). The rest of the object remained completely dark and was therefore not imaged on the film. The focus and the sharply defined light beam were then shifted synchronously in numerous individual shots, and all shots exposed the same individual image of the film. The result was a photo in which all the individual shots of the illuminated focus zones were merged into one overall image.


Functionally, this is very similar to what we do today in digital photography as focus stacking, apart from the fact that we do not isolate the individual sharp focus zones using light beams and darkness, but have this done later by a computer program.


Bridging the gap between macrophotography and the electron microscope

If we use a microscope lens instead of the camera lens, this has another advantage in addition to the larger image scale: a much greater image sharpness. Although we pay for this sharpness by a correspondingly shallower depth of field, we solve this problem with the focus stacking technique.


Focus-stacking images with a high-resolution and high-magnification microscope objective not only offer us an arbitrarily large depth of field, but also a level of detail reproduction that comes close to that of an electron microscope image. Of course, an electron microscope can achieve much larger image scales, up to several thousand times, but in the range of 10 x to about 50 x, which we can cover well with a microscope objective, we produce a photo of comparable detail reproduction, and also with natural colors. An electron microscope, on the other hand, works without light, as it scans the object with an electron beam. That is why it cannot reproduce any colors. A good system camera with a microscope lens, on the other hand, produces a photo with completely natural object coloration. This imaging technique can therefore bridge the gap between conventional macro photography and the images produced by an electron microscope.



Porträt einer 8 mm langen Ameise, Mikroskopaufnahme
Portrait of an 8 mm long ant from the garden, taken with a microscope objective (Mitutoyo M Plan Apo 10x, 200 individual images), and the original files of such photos are sufficient to enlarge them to around 150 cm edge length. Until a few years ago, photos with this level of detail were only possible with an electron microscope!


The series of images

The first step in the focus stacking process is our series in which we create the images with a slightly shifted depth of field. The number of individual images depends on the image scale and the size or depth of the object. At high magnification, virtually every object has a three-dimensionality, even a paper-thin histological microscope specimen. In principle, there are two ways of determining the number of images required.


The first is very abstract and, in my opinion, very cumbersome: you calculate the depth of field of your lens and determine the necessary number of individual shots by calculation, provided that the focus zones of the individual shots overlap each other by about a third so that the software can bring them into optimal alignment. In this way, you obtain a measurement for the required feed step size, which you then adjust using the adjustment screw on the manual linear stage or enter on the control unit. However, this orthodox approach is too theoretical for me; I am a minimalist and have therefore adopted a different, simplified procedure, which I will present in a separate article.


The position of the first photo is at the beginning of the object, or even better before, to be on the safe side. By gradually moving the camera or object, we shift the focal plane forward because we reduce the shooting distance. This is done either on the microscope's fine drive, on the fine adjustment screw of the linear stage on a stable focus stacking device or, if the procedure is automated, with the help of the control unit.


A computer monitor that displays the live view image is ideal for this, so that you can work under visual control. In this way, we work our way step by step through the object, e.g. an insect, according to the slice principle of computer tomography.



Mikroskoppräparat menschlicher Dünndarm
Image by image, the focal plane is moved through the object under examination, according to the slice principle of computer tomography


The image stacking process

In the second step, the individual images are analyzed by special computer software in order to capture all high-contrast contours. Each registered detail is compared on all images in terms of its contrast strength, and the software then merges the details with the highest contrast into a new overall image in a subsequent collection process.


However, the mutual overlapping of the sharpness zones of all individual images must be optimal and, as mentioned, at least one third, because the editing software has to overcome two major difficulties during the assembly process. Firstly, horizontal or vertical displacements can occur when creating the individual images, e.g. due to mechanical play or instability of the recording device or in other ways. As a result, the entire image on the sensor shifts so that the individual images no longer overlap perfectly. The software must correct this by bringing the images back into alignment.


On the other hand, focusing also changes the magnification, because as our objective lenses approach the object, the magnification increases and the image becomes larger. Here the software then has to reduce or enlarge the individual images to the required extent in order to actually bring everything into perfect overlay. However, the focus stacking software solutions carry out this optimization of the image overlay automatically.


The focus stacking software

Numerous software solutions are on the market, in addition to commercial ones (e.g. “Zerene Stacker”, “Helicon Focus”, “Focus Projects”, “Aphelion”) and free programs, for both Windows and Mac operating systems. Some image editing programs also support focus stacking, while others allow the integration of a corresponding plug-in. However, there are definitely differences between the individual programs, especially in terms of ease of use and the precision of the calculations. Also, avoiding imaging errors, so-called artifacts, does not work equally well with all software solutions.



Focus-Stacking-Software im Einsatz
Focus stacking software in use: one of the individual images on the left and the finished result image on the right (detail of the abdomen of an 8 millimeter long cuckoo wasp Chrysididae)


Some focus stacking solutions also have helpful detailed copy functions to eliminate image defects caused by the stacking process. Those allow you to copy certain original areas from a specific individual photo and paste it into the final image.


It's best if you can test certain software solutions for free for a while in order to compare how they work and the image results. I personally work with Helicon Focus, but have also had good experiences with Zerene Stacker. What doesn't work at all in focus stacking, however, are stacking programs from astrophotography. They are intended to combine numerous individual images of a planet in such a way that image disturbances caused by the atmosphere, which occur in different places in numerous individual images, are eliminated. In this way, e. g. in the case of moon craters, there is more image sharpness, which, however, requires a completely different software approach than with our focus stacking.

54 Ansichten0 Kommentare

Aktuelle Beiträge

Alle ansehen

Commentaires


bottom of page