Abstract
Quantifying 2D object contours is a fundamental task in biological imaging and computer vision. However, standard representations are often sensitive to geometric transformations and arbitrary point indexing. We present ShapeEmbed, a self-supervised framework that transforms contours into compact "shape fingerprints." By utilizing Euclidean Distance Matrices (EDMs) and a specialized Variational Autoencoder (VAE) with circular padding, ShapeEmbed achieves inherent invariance to rotation, scaling, translation, and indexation. Our results demonstrate that ShapeEmbed outperforms state-of-the-art methods in shape classification and biological phenotype discovery.
Introduction: The Challenge of Shape Quantification
Recognizing the "shape" of an object independently of its position, orientation, or size is a core capability of human vision that remains challenging for computational models. Traditional methods often rely on binary segmentation masks, which are highly sensitive to geometric shifts. While handcrafted features like area or perimeter offer invariance, they lack the descriptive power to capture complex morphological details.
Modern deep learning typically addresses these challenges through extensive data augmentation or pre-alignment, both of which can be computationally expensive and brittle. A particularly subtle issue is the indexation problem: when a contour is represented as a sequence of points, the choice of the "starting point" is arbitrary. A computer might perceive the same closed loop as different signals depending on where the sequence begins.
Methodology
ShapeEmbed addresses these challenges by moving away from raw pixel data and point sequences, instead representing contours as Euclidean Distance Matrices (EDMs).
Invariant Representation via EDMs
An EDM stores the pairwise distances between all points on an object's outline. Because these distances are relative, the representation is naturally invariant to translation and rotation. By normalizing the matrix, scale invariance is also achieved.
Architecture and the Indexing Fix
The framework employs a modified VAE architecture designed to handle the periodic nature of contours:
- Circular Padding: To resolve the indexation problem, the authors integrated circular padding into a ResNet-18 encoder. This ensures that the network treats the end of a point sequence as being physically connected to the start, reflecting the topology of a closed loop.
- Invariant Reconstruction Loss: A custom "Indexation Invariant Reconstruction Loss" was introduced. During training, the decoder's output is compared against all possible cyclic shifts and mirrored versions of the input. The model is only penalized for the best match, forcing the latent space to ignore the arbitrary starting point and focus on the underlying geometry.
Reconstruction and Validation
Using Multi-Dimensional Scaling (MDS), the framework can reconstruct visual outlines from the abstract latent codes, allowing for direct validation of the learned representations.
Experimental Evaluation
The framework was benchmarked against standard computer vision datasets (MNIST, MPEG-7) and real-world biological datasets, including C. elegans (BBBC010) and Mouse Embryonic Fibroblasts (MEF).
Key Results
- Superior Accuracy: On the MPEG-7 shape benchmark, ShapeEmbed achieved an F1-score of 0.75, significantly outperforming the 0.13 achieved by O2VAE.
- Robustness to Transformations: In tests involving random rotations and translations (rMNIST), ShapeEmbed maintained an F1-score of 0.85, whereas standard VAEs dropped to 0.38.
- Biological Discovery: In the C. elegans dataset, ShapeEmbed successfully clustered worms by phenotype (live vs. dead) in an unsupervised manner. It even identified mislabelled data points where the physical shape contradicted the experimental label.
Discussion and Future Work
ShapeEmbed provides a mathematically grounded approach to shape quantification. By encoding invariance directly into the architecture, it reduces the need for data augmentation and provides more robust descriptors for biological research.
Current limitations include a constraint to simply-connected contours (no holes) and a focus on 2D data. Future work aims to extend this framework to 3D surfaces and explore its utility in more complex segmentation-dependent pipelines.
Summary updated