Fast Shape Retrieval Based on Differential Chain Code Descriptor and Fuzzy Contour Matching

In one sentenceEncodes how a contour turns as a short code sequence and matches it in segments so noise cannot spread, giving lower mean distance than Halcon and the Smart baseline on all eight test images.
The problem
Matching a known shape in an image is a basic step in industrial inspection and measurement. Feature-based methods such as SIFT, SURF and ORB describe key points, but they perform poorly under heavy noise, blur or strong viewpoint change, and the many feature points make them computationally intensive. Template-based methods compare image patches directly, which is costly over large search spaces and sensitive to scale, rotation and illumination. This paper therefore matches contours, using the structural and topological information they carry.
A chain code turns a contour into a sequence of direction changes, so two similar shapes produce similar sequences and matching becomes sequence comparison. The catch is that the sequence is ordered: one noise point shifts the correspondence of the points after it, and the longer the code, the more points are misaligned and the larger the error.

How it works
The method first turns each contour into an ordered, evenly spaced point set and encodes it as differential chain codes. It then matches the local contour against the model in short segments, so that a noise point only disturbs the segment it falls in, and finally checks each candidate position geometrically.

- Extract, smooth and resample the contour. Run-length encoding of the binary image, a connectivity analysis and a depth-first search give the outer and inner contours, with points about 1 pixel apart. The points are smoothed with the mean of their neighbours and then sampled at a fixed distance, which reduces their number while keeping the shape.
- Encode the turning angles. Instead of computing an ordinary chain code first, each point and its two neighbours form two vectors, and the rotation angle between them is quantised into a differential code. The contour becomes a code sequence that does not change when the shape is translated.
- Match short segments. The code of the local contour is divided into short segments. Each segment slides along the longer model code, and at every position the cost is the sum of absolute code differences. Each segment produces one cost array as long as the model code.
- Combine the costs and pick candidates. A sliding window writes the minimum cost inside the window into its centre, which absorbs small shifts of the best position. The segment cost arrays are then combined into one total cost. The total forms valleys; positions with small cost are kept, and the centre of each valley becomes a candidate starting position.
- Verify with SVD. Fuzzy matching can also return look-alike or wrong positions. For each candidate, the local points are paired with the model points, a transformation is estimated by singular value decomposition (SVD), and the mean distance between the transformed pairs scores the match. The positions with the smallest mean distance are kept. An optional ICP step refines the final alignment.


Results
The test material is CAD drawings captured with the SmartFlash-2020 one-click measurement sensor, an instrument for large flat products with a measurement range of up to 300 × 200 mm. Each original image was rotated clockwise by 30°, 60°, 90°, 120° and 150° and matched against the original, and further experiments test matching under multi-target interference. For the quantitative comparison, Table 1 reports the mean distance and standard deviation between the matched contour and the ground truth on eight test images, for Halcon, a baseline referred to as Smart, the proposed method, and the proposed method followed by ICP.
The proposed method has the lowest mean distance of the three methods on every image; on test image 2, for example, it is 0.426, against 1.027 for Halcon and 0.715 for Smart. ICP refinement lowers the mean distance on seven images and leaves it unchanged on image 6 (0.376), with the largest reductions on images 8, 5 and 4 (0.601 → 0.372, 0.581 → 0.391 and 0.578 → 0.419). As future work, the authors plan more advanced smoothing, an improved fuzzy matching algorithm and the use of deep learning.


Cite
@article{wei2025fast,
title={Fast Shape Retrieval Based on Differential Chain Code Descriptor and Fuzzy Contour Matching},
author={Wei, Pan and Ning, Li and Wenming, Tang and Lei, Lu},
journal={Computer-Aided Design and Application},
volume={23},
number={2},
pages={222--233},
url={https://www.cad-journal.net/files/vol\_23/CAD\_23(2)\_2026\_222-233.pdf},
year={2025},
doi={10.14733/cadaps.2026.222-233}
}