A Matching Algorithm for Content-Based Image Retrieval