Square Superpixel Generation and Representation Learning via Granular Ball Computing
Authors: Shuyin Xia, Meng Yang, Dawei Dai, Fan Chen, Shilin Zhao, Junwei Han, Xinbo Gao, Guoyin Wang, Wen Lu
Organizations: Shuyin Xia, Meng Yang, Dawei Dai, Fan Chen, Shilin Zhao and Junwei Han are with Chongqing University of Posts and Telecommunications, Chongqing, China. · Xinbo Gao and Wen Lu are with Xidian University, Xi’an, China. · Guoyin Wang is with Chongqing Normal University, Chongqing, China.
Superpixels provide a compact region-based representation that preserves object boundaries and local structures, and have therefore been widely used in a variety of vision tasks to reduce computational cost. However, most existing superpixel algorithms produce irregularly shaped regions, which are not well aligned with regular operators such as convolutions. Consequently, superpixels are often treated as an offline preprocessing step, limiting parallel implementation and hindering end-to-end optimization within deep learning pipelines. Motivated by the adaptive representation and coverage property of granular-ball computing, we develop a square superpixel generation approach. Specifically, we approximate superpixels using multi-scale square blocks to avoid the computational and implementation difficulties induced by irregular shapes, enabling efficient parallel processing and learnable feature extraction. For each block, a purity score is computed based on pixel-intensity similarity, and high-quality blocks are selected accordingly. The resulting square superpixels can be readily integrated as graph nodes in graph neural networks (GNNs) or as tokens in Vision Transformers (ViTs), facilitating multi-scale information aggregation and structured visual representation. Experimental results on downstream tasks demonstrate consistent performance improvements, validating the effectiveness of the proposed method.
Figures & tables
Fig. 1: In contrast with SLIC, the first line depicts the input image, the second showcases the superpixel blocks generated by our method, and the last line displays those generated by the SLIC method.
Fig. 2: Overview of our superpixel generation approach: (a) Module for multi-scale superpixels; (b) Integration of the module into ViG for image classification; (c) Integration of the module into ViT for image-text retrieval; (d) Integration of the module into ViT for object detection.
Method
Time Complexity
Ncuts [ 11 ]
Superlinear in N (global spectral/graph optimization)
ERS [ 12 ]
Typically superlinear or O(NlogN) (solver-dependent)
SLIC
O(NI)
SEEDS [ 13 ]
O(NI) (near-linear with iterative updates)
Watershed [ 14 ]
O(N)
TurboPixels [ 15 ]
O(NI)
TABLE I: Asymptotic time complexity comparison of representative superpixel methods. N=HW denotes the number of pixels, I is the number of iterations, and L is the number of coarse-to-fine stages.
Fig. 3: Our Method vs. SLIC on MNIST and CIFAR-10. Top: Our Method; Bottom: SLIC Method.
Model
Date
MNIST
CIFAR10
Test ACC
Test ACC
Vanilla GCN
ICLR 2017
90.70
55.71
GraphSage
NIPS 2017
97.31
65.76
MoNet
CVPR 2017
90.80
54.65
GatedGCN
Arxiv
97.34
67.31
GAT
ICLR 2018
95.53
64.22
TABLE II: Performance Comparison on MNIST and CIFAR10. The best results are boldfaced .
Dataset
Model
Image= > Text
Text= > Image
R@1
R@5
R@10
R@1
R@5
R@10
CelebA
FLIP
21.99
43.9
57.63
21.84
45.64
56.34
FLIP*
22.64
43.96
57.77
22.42
46.12
56.48
Ours
23.08
45.58
58.42
22.66
47.98
58.54
MM-CelebA
FLIP
7.63
19.15
26.06
8.85
21.5
28.86
FLIP*
8.41
21.75
29.18
9.2
23.3
31.58
TABLE III: Performance Comparison on CelebA and MM-CelebA Zero-Shot Tasks. The best results are boldfaced .
Dataset
Model
Image= > Text
Text= > Image
R@5
R@10
R@5
R@10
CelebA
ALIGN
6.99
11.09
5.08
8.65
BLIP
24.56
34.09
24.35
34.15
CLIP
21.42
30.3
26.52
37.22
FLIP
50.04
62.04
50.96
62.98
Ours
50.12
62.36
50.78
62.2
TABLE IV: Performance Comparison on CelebA and MM-CelebA. All pretrained model backbones are frozen, with only the linear layer being fine-tuned. The best results are boldfaced .
Fig. 4: Visualization of multi-granularity token selection on COCO image. Left: Original image with objects at various scales (cows and pedestrians). Right: Selected tokens represented by square blocks of varying sizes. Our method adaptively assigns larger blocks to homogeneous background regions and smaller blocks to object-dense areas, effectively reducing tokens while preserving critical information for detection.
Model
Backbone
#Epochs
#Params (M)
GFLOPs
APval
AP50val
AP75val
APSval
APMval
APLval
Real-time Object Detectors
YOLOv6-L
–
300
59
150
52.8
70.3
57.7
34.4
58.1
70.1
YOLOv7-L
–
300
36
104
51.2
69.7
55.5
35.2
55.9
66.7
YOLOv7-X
–
300
71
189
52.9
71.1
57.4
36.9
57.7
68.6
YOLOv8-L
–
–
43
165
52.9
69.8
57.5
35.3
58.3
69.8
YOLOv8-X
–
–
68
257
53.9
71.0
58.7
35.7
59.3
70.7
TABLE V: Performance comparison on COCO object detection. The best results are boldfaced .
Model
Tokens
Removed
AP
AP 50
AP 75
AP S
AP M
AP L
RT-DETR
400
0
53.1
71.3
57.7
34.8
58.0
70.0
Ours
350
50
52.5
70.6
56.5
34.2
56.6
69.8
Ours
300
100
52.3
70.4
56.6
35.4
56.7
69.9
Ours
200
200
52.3
70.3
56.6
33.4
56.3
69.8
TABLE VI: Performance Comparison on COCO Object Detection with Different Token Pruning Ratios. All models use RT-DETR-R50 backbone trained on COCO 2017. The best results are boldfaced .
Visual representation learning develops image and video features that capture useful structure for recognition, retrieval, spatial reasoning, and action.
Superpixels offer a compact image representation by grouping pixels into coherent regions. Recent methods have reached a plateau in terms of segmentation accuracy by generating noisy superpixel shapes. Moreover, most existing approaches produce a single fixed-scale partition that limits their use in vision pipelines that would benefit multi-scale representations. In this work, we introduce H-SPAM (Hierarchical Superpixel Anything Model), a unified framework for generating accurate, regular, and perfectly nested hierarchical superpixels. Starting from a fine partition, guided by deep features and external object priors, H-SPAM constructs the hierarchy through a two-phase region merging process that first preserves object consistency and then allows controlled inter-object grouping. The hierarchy can also be modulated using visual attention maps or user input to preserve important regions longer in the hierarchy. Experiments on standard benchmarks show that H-SPAM strongly outperforms existing hierarchical methods in both accuracy and regularity, while performing on par with most recent state-of-the-art non-hierarchical methods. Code and pretrained models are available: https://github.com/waldo-j/hspam.
Julien Walther, Rémi Giraud, Michaël Clément
Univ. Bordeaux, CNRS, Bordeaux INP, IMS, UMR 5218, France · Univ. Bordeaux, CNRS, Bordeaux INP, LaBRI, UMR 5800, France
Superpixel-based image classification has traditionally leveraged graph neural networks (GNNs) for processing irregular image representations. Recent advances in computer vision, driven by Vision Transformers (ViTs), have introduced new paradigms in self-attentional models, surpassing convolutional neural networks (CNNs) in various tasks. However, a synergistic connection between GNNs, superpixels, and transformers remains unexplored. In this work, we propose Superpixel Transformers (SPT), a novel framework that unifies superpixel-based image classification and ViTs. SPT generalizes the Superpixel Image Classification with Graph Attention Networks (SICGAT) model and ViT to support arbitrary superpixel-based chunking strategies, connectivity graphs, and positional encodings. We introduce refinements including a multidimensional sine-cosine positional encoding and an enriched patch data structure that fully incorporates superpixel shape and color information. By testing SPT across datasets such as CIFAR10, FashionMNIST, and Imagenette, with various superpixel generation and graph connectivity strategies, we demonstrate that SPT achieves superior performance compared to previous superpixel-based GNN methods and remains competitive with ViTs. Notably, our approach addresses the limitations of SICGAT, such as information loss during pixel aggregation, and shows how constrained graph connectivity can enhance ViT performance. SPT bridges the gap between superpixel-based and transformer models, opening avenues for cross-domain generalization and future innovations in hybrid attentional frameworks, and showing that an image can also be worth 16×16 superpixels.
Pedro Henrique da Costa Avelar, Anderson R. Tavares, Luís C. Lamb
Conventional cameras generate a lot of data that can be challenging to process in resource-constrained applications. Usually, cameras generate data streams on the order of the number of pixels in the image. However, most of this captured data is redundant for many downstream computer vision algorithms. We propose a novel camera design, which we call SuperCam, that adaptively processes captured data by performing superpixel segmentation on the fly. We show that SuperCam performs better than current state-of-the-art superpixel algorithms under memory-constrained situations. We also compare how well SuperCam performs when the compressed data is used for downstream computer vision tasks. Our results demonstrate that the proposed design provides superior output for image segmentation, object detection, and monocular depth estimation in situations where the available memory on the camera is limited. We posit that superpixel segmentation will play a crucial role as more computer vision inference models are deployed in edge devices. SuperCam would allow computer vision engineers to design more efficient systems for these applications.