Abstract
This paper presents a robust framework for solving square-piece jigsaw puzzles where both the location and the rotation of every piece are unknown (Type 2 puzzles). By introducing a novel gradient-based compatibility metric and a geometrically constrained greedy assembly algorithm, the proposed method achieves perfect reconstructions of puzzles containing up to 9,600 pieces—the largest automatically solved puzzles at the time of publication.
Introduction
Computational jigsaw puzzle assembly is a complex field in computer vision with applications ranging from archaeological artifact reassembly to image forensics. While previous research primarily focused on puzzles with known piece orientations, this work tackles the more difficult "Type 2" puzzle. In this scenario, the solver must determine both the spatial coordinates and the 90-degree rotation for each square piece.
The primary challenges are defining a reliable compatibility metric to determine if two pieces belong together and navigating an NP-hard search space that grows exponentially with the number of pieces and unknown rotations.
Methodology
Mahalanobis Gradient Compatibility (MGC)
Traditional compatibility metrics often rely on the Sum of Squared Differences (SSD) of pixel colors at boundaries. However, these metrics frequently fail in natural images with strong gradients or complex textures.
The author proposes the Mahalanobis Gradient Compatibility (MGC) metric, which shifts the focus from color matching to gradient continuity. MGC models the distribution of gradients near the edge of a piece and uses the Mahalanobis distance to penalize deviations in the adjacent piece. This approach accounts for correlations between color channels (R, G, and B), making it significantly more sensitive to true matches than standard Euclidean distances.
Constrained Tree-Based Reassembly
The assembly process utilizes a greedy approach inspired by Kruskal’s algorithm for finding a Minimum Spanning Tree (MST). The algorithm treats each piece as a separate component and iteratively merges them based on the highest compatibility scores.
To ensure a valid global arrangement, the algorithm incorporates geometric constraints. Before any merge is finalized, a collision check is performed to prevent pieces from overlapping in the virtual assembly space. After the initial tree is constructed, the result is trimmed to fit the target rectangular frame, and any remaining gaps are filled using the leftover pieces.
Experimental Results
The algorithm was evaluated against standard benchmarks and novel high-complexity tests:
- Accuracy: On 432-piece puzzles with known orientation, the MGC metric achieved 95.3% direct accuracy, a significant improvement over the ~10% seen in prior work.
- Type 2 Performance: The algorithm perfectly reconstructed 9 out of 20 puzzles from the Cho et al. dataset (432 pieces each) despite unknown orientations.
- Scalability: The system successfully solved a massive 9,600-piece "Mega-Puzzle," demonstrating its robustness at scale.
- Mixed-Bag Puzzles: The tree-based approach proved capable of separating and reassembling pieces from multiple mixed images simultaneously, as it naturally forms separate trees for unrelated components.
Conclusion
Andrew C. Gallagher’s 2012 paper established a new state-of-the-art for computational jigsaw puzzles. The transition to gradient-based matching and the use of relative rotations during assembly provided the necessary tools to solve large-scale, orientation-agnostic puzzles. While the greedy nature of the algorithm can lead to unrecoverable errors in uniform regions (like clear skies), the framework remains a foundational contribution to the field of automated reconstruction.
Summary updated