Dirk Jan Buter's
Aspiring Innovators Magazine

Thursday, April 4, 2024

EDOF: Microscopic photography with sharp images

Wow, I often see microscope close-up images on my timeline with amazing sharpness. How is this possible? If I want to do that with my microscope, I only get a limited depth of field.

The trick is in the Extended Depth-Of-Focus or EDOF technology. You can achieve this with advanced lenses or software. In this article we will dive into this technology and try to write a software program for it ourselves.

Explanation of EDOF technology

Microscopes often have a small focus, so only part of the magnification is clearly visible, the rest is out of focus. With EDOF, advanced lenses or software with a special algorithm expand the focal area, giving you a full depth range.

Focus stacking

Focus stacking is a technique used to achieve EDOF. With this method we create a short video with different focus distances. The algorithm analyzes each frame, identifies the sharpest areas and combines them into a composite image with greater depth of field.

Contrast measurement technique

We compare the contrast per pixel with the 24 surrounding pixels. A high contrast difference can be a sharp transition or edge. This information is essential when selecting which areas to include in the final composite image.

Implementation

Looking in more detail at how EDOF can be achieved using C language code, we use the focus stacking method to merge video frames from a microscope slide taken at different focus distances to create an EDOF image. The code calculates the contrast of each pixel by analyzing the intensity variations between the central pixel and the twenty-four surrounding pixels. It then chooses the highest contrast image for each pixel and combines them to form the final composite image.

Sample application

Our own GitHub contains sample code, which we went through in the previous steps. This is a plugin, AV-Filter-EDOF (1), for the AV-Viewer (2). In addition to the viewer, the AV-Filter-Player (3) is also required to open videos.

Interpolation

Although this software technique can produce beautiful photos, it is not suitable for every situation. For example, a slight glare can ruin the image. The software could also be further developed by applying interpolation for the intermediate pixels. If you want this, you are free to customize the software to your liking.

Images with sharp focus and details

Extended depth of field technology expands microscope capabilities. Using focus stacking and contrast metering techniques we can create beautiful images with sharp focus and details with greater depth of field. So consider EDOF to take clear, detailed photos for your next research.

Candyfloss

Candyfloss

Comment

Join and comment on this article via our Discord (1) or via our Facebook (2) or LinkedIn (3) groups!

Next

Table of Contents

Expand your knowledge with our affordable subscriptions!

Join and get access to the full archive, bonus content, digital copies of every issue and/ or a hard copy by mail, a more extensive collection of articles and/ or videos on personal development technology. Choose one of the subscriptions that best suits your situation.

Contact person & Advertising sales: Dirk Jan Buter (+31628860414)
Editorial: See the captions for the articles.
Photography: See the captions with the photos.