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

An Innovative Future with Sanator Sanders?

For forty years, you have been a champion of the cause, a man on the barricades. You have dedicated your entire political life to fighting for the worker and against the greed of big money. But today, at the most critical crossroads in human history, you are blind. You look at artificial intelligence (AI) and see an enemy. You see Big Tech, you see billionaires, and your reflex is to tax, slow down, and halt progress. But Senator, hear this hard truth: you are fighting a war from the last century. You are trapped in an industrial mindset from the 1970s, when the factory gate marked the edge of the world. Through that outdated lens, you view AI as a thief stealing jobs. Yet the reality is that AI holds the key to breaking the chains of the working class. Your fear makes you conservative,...

The Future of the Computer and Smartphone

The way we interact with computers is changing. For years, we’ve been accustomed to screens and keyboards, but these familiar interfaces are increasingly being challenged by new technologies. Think of voice recognition, which has become commonplace in our phones and smart speakers. Or touch feedback from touchscreens, allowing you to actually feel virtual buttons. But the future goes further than that: we’re already seeing prototypes of virtual and laser projection keyboards, and even the rise of brain-controlled interfaces that convert our thoughts into commands. ## Farewell to the physical? Perhaps the most striking change is the disappearance of the physical keyboard and screen as we know them. Why type when you can simply speak? Why stare at a screen when information can appear d...

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...

The Mirror of Immortality

If you could live forever, what’s the first thing you’d do? Imagine the awe-inspiring prospect of perpetual youth, the boundless energy of your twenties, and an existence that stretches into eternity. This dream, brimming with adventures and possibilities, is truly captivating. It promises a life without end, where you can delve into every facet of existence, forge new connections, and chase your aspirations. But what would such a world look like? What challenges and opportunities would we encounter on this extraordinary journey? ## The beauty of eternal life The idea of ​​immortality makes you think of a life full of endless adventures and quests for knowledge. Think of traveling the world, throwing parties, or diving into books for weeks. You could constantly help others an...

Can we fight crime without punishing?

Today's newspaper reported on a crypto fraudster, Sam Bankman-Fried, who will spend 25 years in prison. Once again someone who is convicted with today's standards and the imposition of high sentences. The result of a trial is punishment with money, years of life or the death penalty. It's as if time has stood still! Restorative justice is a better and more moderate approach. We must focus on rehabilitation and recognize the power of people to make positive contributions to society even after committing crimes. ## Healing and rehabilitation: an alternative to revenge The high penalties or even killing as punishment are not only inhumane, but also perpetuate the cycle of violence. It deprives us of the opportunity to learn and grow as a society. Instead of seeking revenge, we should...

Simple Home Hacks: What India and the Netherlands Can Learn From Each Other

If you spend a month living with an Indian family, like my in-laws, you notice a lot of things that could be better. But it goes both ways. We usually talk about big things like the economy or public transport when comparing countries. However, the real lessons happen in daily life: in the kitchen, the bedroom, and our everyday habits. Here are a few simple tips that Indian and Dutch households can steal to live healthier and more comfortably. 1 - Stop Eating Late at Night The problem in India: Dinner is often late, heavy, and eaten at different times by different family members, right before bedtime. Why it’s bad: Eating big meals late forces your digestive system to work hard when your body should be resting, which can lead to weight gain and diabetes. What to do: * Eat ear...