Image Segmentation using Ant Colony algorithms.
Switch branches/tags
Nothing to show
Clone or download


A Java Program to identify segments on an image using an Ant Colony optimization algorithm. It is a two-phase procedure:

The Ant-Colony Algorithm

The Ant Colony algorithm used to extract segments of the image is based on Max-Min Ant System, as was proposed by Salima Ouadfel in the paper "Unsupervised image segmentation using a colony of cooperating ants". To implement it, we used the Isula Framework:

    ConfigurationProvider configurationProvider = ProblemConfiguration
    EnvironmentForImageSegmentation environment = new EnvironmentForImageSegmentation(
        imageGraph, ProblemConfiguration.getInstance().getNumberOfClusters());

    ImageSegmentationAntColony antColony = new ImageSegmentationAntColony(

    problemSolver = new AcoProblemSolver<ClusteredPixel>();


        new StartPheromoneMatrixForMaxMin<ClusteredPixel>(),
        new ImageSegmentationUpdatePheromoneMatrix());
    antColony.addAntPolicies(new ImageSegmentationNodeSelection());

    ClusteredPixel[] bestPartition = problemSolver.getBestSolution();

The implemented process has the following characteristics:

  • The components of the solution are Clustered Pixels, that is, each pixel of the image will be assigned to one of three clusters.
  • The Ant class avaible in Isula was extended to support this image clustering class. The ants for this problems have memory of the current position in the image, as well as a Map for Cluster storage. Since the calculation of the Solution Quality is expensive, it was also added as an instance variable.
  • These Ants are built so they only consider Cerebrum pixels. That information was provided but the previous binary thresholding algorithm.
  • The Max-Min Ant System policies available in Isula were reused with minor customization. This includes pheromone update and node selection.

The results

We use an MR Brain image as an input. This was provided by the BrainWeb Database:

Original Image

The program extracts three segments from the image: Brain Matter, White Matter and CLF. Here's the segment corresponding to the Grey Matter:


How to use this code

The code uploaded to this GitHub Repository corresponds to a Java Project developed on the Eclipse IDE. You should be able to import it as an existing project to your current workspace.

This project depends on the Isula Framework. You need to download first the Isula Framework Project available on this Github Repository:

This project also depends on an ACO-based procedure for image thresholding. The aco-image-thresholding project that contains it is available on this Github Repository:

Keep in mind that several file and folder locations were configured on the file. You need to set values according to your environment in order to avoid a FileNotFoundException.

More about Isula

Visit the Isula Framework site:

Review the Isula JavaDoc:

Questions, issues or support?

Feel free to contact me at