## 3 Materials and Methods
### Key-Based Document Image Retrieval  
In this section, within the Key-Based DIR system, our process begins by employing a Canny edge detector [32] to compute edges within the document image. Following edge computation, we proceed to extract contours. Subsequently, we eliminate contours whose area falls below a predefined minimum contour area threshold. This elimination step proves valuable in reducing noise, which can commonly arise during the binarization process or originate from imperfections in printed paper. We apply a minimum bounding box to each contour found in the gray-level image for feature extraction over these retained contours. Within this bounding box, we resize the image, resulting in an \"L \(\times\) L\" image patch, from which we derive an L\({}^{2}\)-dimensional feature vector. This process allows us to capture essential visual characteristics from the contours for subsequent analysis and comparison.  
The obtained feature vectors are subsequently assigned to C clusters. These clusters are computed using the same set of features over the entire document image dataset. Once the feature vectors are assigned to their respective cluster labels, we process each contour within the document image. We identify the closest contours for each contour and arrange them in order based on their spatial proximity to the target contour. We then concatenate these sorted labels to construct a key. A collection of such keys ultimately represents each document image. Both the document images and the query image are transformed into numerical vectors. These vectors are populated with term frequency-inverse document frequency (TF-IDF) values corresponding to the keys. In text mining and information retrieval, the TF-IDF numerical statistic is used to assess a term's significance in a document for a group of documents [33]. This method takes into account both the frequency of a phrase inside a single document and its rarity over the whole document collection to assist in conveying the relevance of a term within a corpus. We utilize cosine similarity to assess the similarity between the query vector and the document image vector. For efficient processing of large document datasets, we implement TF-IDF and an inverted index using the open-source text retrieval tool SOLR [34]. Apache SOLR, which is an open-source corporate search platform, is a popular text retrieval tool. It is a component of the broader Apache Lucene project, which is a Java-written, feature-rich, fast text search engine library. Building strong and scalable search apps is made possible by the search platform offered by SOLR [34]. This approach ensures scalability in handling extensive collections of document images.  
In the context of key-based DIR, the goal is to have each label correspond ideally to a character or a frequently occurring non-textual shape. Importantly, these labels' local arrangement and alignment within the key are preserved. It is worth noting that this approach is not limited solely to characters found in textual content; it can also effectively represent common shapes such as integral signs, triangles, or circles. This flexibility enables the system to capture a wide range of visual elements, enhancing its capacity to identify and retrieve various content types within document images.