Written by Dirk Jan Buter

EDOF: Microscopic photography with sharp images

EDOF: Microscopic photography with sharp images

Written by Dirk Jan Buter on March 26, 2024. Photo by Lotte (AI).

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

CandyflossDirk Jan Buter

Candyfloss

CandyflossDirk Jan Buter

Soil

SoilDirk Jan Buter

Soil

SoilDirk Jan Buter

Is the World Waking Up? A New Consciousness Is Growing

The world has been a rollercoaster lately. You see problems and arguments everywhere, which makes you wonder if we will ever be okay. But in the midst of all that chaos, you also see something beautiful happening. *More and more people, from all kinds of different backgrounds, are starting to realize that we are all connected in some way. What you feel, what you experience, the struggles you have, it is not separate from what others experience.* This realization causes a change in the way we think. We start to understand that we are all part of something bigger, a kind of invisible web that we are all attached to. ## Connection: the basis of everything This new way of looking is based on the idea that your mind, your heart and what you do are not just separate things. They belong to a la...

Hacked: Why I’m kicking out WordPress

It started with an email like this on my screen: Your password has been changed. Well, definitely not. I hadn’t changed anything at all. Some hacker or other had found an old vulnerability in WordPress and was right inside the backend of the Ronald Thump Parody website. Within a few minutes, my password had been changed, strange accounts appeared in the database, a signature page was hanging on the site, and the AI ​​had been modified. That is, the hacker had dived straight into the system prompt. ## AI hijacked… but the hacker was right Usually, with a hack like this, you only get junk or vague advertisements. This was different. The hacker had rewritten the instructions for the interactive Ronald Thump avatar. Suddenly, it said that the clone had to shout that clim...

When Algorithms Rule, what Remains of Humanity?

Since 2023, generative AI tools like ChatGPT and Gemini have become accessible. It has made enormous strides in creating texts and images. Yet, it seems that this new AI power is primarily being used to exacerbate existing divides, amassing more power and becoming even richer. This runs counter to the hope that AI would help improve the world and feed everyone. It even seems to strengthen the current capitalist system, while I thought we would no longer need that system with the advent of AI. What this world truly lacks is a kind of global government. An entity that ensures that international laws are followed, that dictators don't rise to power, that everyone has food, and that wars are a thing of the past, so that no one can harm anyone anymore. However, we can't simply impose such glob...

Why Software Must Be Free

For decades, the software industry has operated on a foundational premise: code is a scarce intellectual property that can be locked behind paywalls, licensed, and monetized. Companies built moats out of proprietary codebases, and copyright laws served as the walls protecting them. Today, that entire paradigm is collapsing. We have entered an era where clinging to traditional software economics is not only obsolete, it is actively harmful to our technological progress and our planet. When software carries a hefty price tag or restrictive licensing terms, a strange economic friction occurs. Instead of adopting an existing, perfectly functional solution, organizations and individuals increasingly choose to build their own custom alternatives using AI. At first glance, this looks like empo...

Death Wish People are Rejecting a Ticket to the Future

For people into cryonics, the choice is a total no-brainer. When you’re looking down the barrel of a terminal illness or just getting old, the alternative to getting frozen in liquid nitrogen at -196°C is, well, game over forever. They see even a tiny shot that future tech could fix cellular damage and bring you back as the ultimate life insurance policy. Yet, decades after Robert Ettinger first pitched the idea back in 1962, cryonics is still way out on the fringes. Globally, only a few thousand people have signed up for post-mortem cryopreservation, and only a couple hundred bodies are actually sitting in tanks right now. Billions of people face the absolute certainty of death every single day. So why do the vast majority not just pass on cryonics, they actively brush it off? Wh...

I Was So Full of Praise and Enthusiasm

Have you ever met someone who was so full of praise and enthusiasm for you that you felt like you were priceless? I have to admit that this doesn’t happen to me very often. Well, the opposite is true. You meet someone who you find interesting and who you keep following. You become a fan. I am so happy when I meet them in real life! Wow! As fun as this is, it is often a disappointment. This person you are such a fan of shows no interest in you at all, gasp! There goes your appreciation for that person, at least you start to see him or her in a different light. Are you still a fan of him or her? Let’s turn the story around. Let’s say you meet someone who is a fan of yours. He or she talks about you with such high praise. What are you going to do? A) You don’t find that perso...