An image analysis system for analysing biological specimen images, the image analysis system comprising: a superpixel generator configured to obtain a biological specimen image and group pixels of the biological specimen image into a plurality of superpixels; a feature extractor configured to extract, from each superpixel in the plurality of superpixels, a feature vector comprising a plurality of image features; a clustering engine configured to assign the plurality of superpixels to a predefined number of clusters, each cluster being characterized by a centroid vector of feature vectors of superpixels assigned to the cluster; a storage interface configured to store, for each superpixel in the plurality of superpixels, clustering information identifying a cluster to which the superpixel is assigned; and, a graph engine configured to: obtain the clustering information stored by the storage interface; based at least on the clustering information, construct a graph comprising a plurality of nodes, wherein adjacent nodes correspond to adjacent superpixels in the biological specimen image and are connected by a weighted edge, wherein the weighted edge has a weight corresponding to a distance between clusters to which the adjacent superpixels belong; and use the graph to perform a graph-based image processing task, wherein: the clustering engine is further configured to precalculate distances between each two clusters in the predefined number of clusters; the storage interface is further configured to store the precalculated distances; and the graph engine is further configured to obtain the precalculated distances stored by the storage interface, and to construct the graph based on the precalculated distances. a superpixel generator configured to obtain a biological specimen image and group pixels of the biological specimen image into a plurality of superpixels; a feature extractor configured to extract, from each superpixel in the plurality of superpixels, a feature vector comprising a plurality of image features; a clustering engine configured to assign the plurality of superpixels to a predefined number of clusters, each cluster being characterized by a centroid vector of feature vectors of superpixels assigned to the cluster; a storage interface configured to store, for each superpixel in the plurality of superpixels, clustering information identifying a cluster to which the superpixel is assigned; and, a graph engine configured to: obtain the clustering information stored by the storage interface; based at least on the clustering information, construct a graph comprising a plurality of nodes, wherein adjacent nodes correspond to adjacent superpixels in the biological specimen image and are connected by a weighted edge, wherein the weighted edge has a weight corresponding to a distance between clusters to which the adjacent superpixels belong; and use the graph to perform a graph-based image processing task, obtain the clustering information stored by the storage interface; based at least on the clustering information, construct a graph comprising a plurality of nodes, wherein adjacent nodes correspond to adjacent superpixels in the biological specimen image and are connected by a weighted edge, wherein the weighted edge has a weight corresponding to a distance between clusters to which the adjacent superpixels belong; and use the graph to perform a graph-based image processing task, the clustering engine is further configured to precalculate distances between each two clusters in the predefined number of clusters; the storage interface is further configured to store the precalculated distances; and the graph engine is further configured to obtain the precalculated distances stored by the storage interface, and to construct the graph based on the precalculated distances. <EOS>