Clear Sky Science · en

Optimized K-means algorithm for image segmentation based on improved dung beetle algorithm

· Back to index

Sharper Pictures from Smarter Algorithms

Every day, phones, medical scanners, and self-driving cars rely on computers to separate the important parts of an image from the background. This process, called image segmentation, affects everything from spotting tumors in scans to detecting pedestrians in traffic. The study summarized here introduces a new way to make this separation more accurate and reliable by combining two ideas: a classic clustering method and a beetle-inspired search strategy.

Figure 1
Figure 1.

Why Splitting an Image Is Hard

At first glance, cutting an image into regions that share similar brightness, color, or texture sounds straightforward. A popular tool, known as K-means, does this by grouping pixels into clusters. But K-means has a fragile side: its results depend heavily on where it starts. Give it a poor initial guess, and it may settle on a mediocre solution, missing fine details or blurring edges. This is especially troublesome for images with noise, complex lighting, or subtle textures, such as medical images or outdoor scenes with reflections and shadows.

Learning from the Life of a Beetle

To improve this situation, the authors build on a relatively new "swarm intelligence" method inspired by dung beetles. In nature, these insects roll, hide, steal, and forage for dung balls, adjusting their paths as conditions change. The original dung beetle optimization algorithm mimics these behaviors to search for good solutions in a mathematical landscape. However, like many search methods, it can get stuck too early or converge slowly on difficult problems. The researchers propose an Improved Dung Beetle Optimization algorithm, or IDBO, that refines how these virtual beetles explore and hone in on promising areas.

Three Upgrades for a Better Search

The new method introduces three key upgrades. First, it uses a sampling technique called Latin hypercube sampling to spread the initial beetle positions evenly across the search space, avoiding clumps and overlooked regions. Second, a hybrid movement strategy lets the beetles switch smoothly between broad exploration and focused refinement as the search progresses, using a changing decision rule and a simple "competition" where some beetles adjust their paths based on others. Third, special local adjustment steps, based on mathematical functions with both short and occasional long jumps, help the beetles fine-tune the best locations while still escaping small local traps. Together, these steps aim to find better solutions faster and more consistently than the original design.

Figure 2
Figure 2.

Testing on Benchmarks and Real Images

To see whether IDBO truly helps, the authors first test it on a collection of standard mathematical problems used to compare optimization methods. Across many functions and dimensions, IDBO typically reaches better answers more quickly and with less variation from one run to another than competing algorithms, including earlier dung beetle versions and other popular swarm methods. Next, they plug IDBO into the K-means pipeline, using it to choose better starting cluster centers for image segmentation. On classic test images—such as a swan on water, a cameraman, grains of rice, and a flower—the IDBO-enhanced K-means produces cleaner boundaries, fewer over-bright or washed-out regions, and more faithful textures. Numerical measures of distortion and signal quality confirm these visual gains.

What This Means for Everyday Images

In simple terms, the study shows that guiding K-means with a more thoughtful, beetle-inspired search makes it far less likely to settle for a poor way of splitting an image. Instead, it tends to find segmentations that preserve edges and structure, even when lighting and textures are complicated. While the method still demands computing power and may need further tuning for very large or real-time tasks, it points toward a future where intelligent search strategies quietly improve how machines see the world behind the scenes.

Citation: Li, N., Luo, Y., Feng, Z. et al. Optimized K-means algorithm for image segmentation based on improved dung beetle algorithm. Sci Rep 16, 11187 (2026). https://doi.org/10.1038/s41598-026-38438-2

Keywords: image segmentation, clustering, swarm intelligence, optimization algorithms, computer vision