In some embodiments, a method of encoding image features of a biological specimen image obtained by a slide scanner is disclosed. The method may include: obtaining the biological specimen image; grouping pixels of the biological specimen image into a plurality of superpixels; for each superpixel, extracting a feature vector comprising a plurality of image features characterizing the superpixel; based on the feature vectors extracted for the plurality of superpixels, generating (e.g., using k-means clustering) a predefined number of clusters, each cluster being characterized by a centroid vector, and associating each superpixel with a cluster whose centroid vector is the closest to the feature vector of the superpixel; for each superpixel, storing an identifier of a cluster whose centroid vector is closest to the feature vector of the superpixel; and storing the centroid vector of each cluster in the plurality of clusters and/or distances between each two clusters in the predefined number of clusters.
In some aspects, the method may further include precalculating the distances between each two clusters within the predefined number of clusters. Furthermore, in some aspects, the method may also include retrieving the centroid vector of each cluster and/or the distances between each two clusters, and using the centroid vector of each cluster and/or the distances between each clusters to construct a graph; and performing a graph-based image processing task based on the graph.