This document proposes a hybrid technique for shape matching that combines chain code and depth-first search (DFS) tree methods. Chain code is used to detect boundaries and represent shapes, but can result in long codes that reduce accuracy. DFS is applied to break long chain codes into smaller subgraphs, producing more compact patterns that improve matching performance. The technique is tested on 500 images from different categories, achieving higher precision and recall than chain code alone, demonstrating the effectiveness of the hybrid approach.