Lace sample retrieval system and method based on image matching

By designing a lace sample retrieval system based on image matching, using YOLOv5 and deep convolutional neural network for feature extraction and similarity calculation, the problems of low accuracy and slow speed of complex lace patterns in the prior art are solved, and a fast and accurate retrieval effect is achieved.

CN119988658APending Publication Date: 2025-05-13FUJIAN SANYI YUNTONG INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510057755.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-14
Publication Date
2025-05-13
Patent Text Reader

Abstract

The invention relates to the field of lace sample image retrieval, in particular to a lace sample retrieval system and method based on image matching, and the system comprises a data acquisition layer, a preprocessing layer, a core algorithm layer, a data storage layer and a user interaction layer, the preprocessing layer carries out standardization processing on an input image and prepares for subsequent feature extraction and matching, the core algorithm layer is responsible for target detection, feature extraction and similarity calculation, and the data storage layer is used for managing various data of the system, including original images, extracted feature vectors and metadata information. The user interaction layer provides a friendly interface, user operation and result display are facilitated, complex lace pattern retrieval can be processed, the accuracy is high, and the retrieval speed is high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of lace sample image retrieval, and in particular relates to a lace sample retrieval system and method based on image matching. Background Art

[0002] In the textile industry, especially in the lace manufacturing industry, lace sample management and fast retrieval has always been a challenge. Traditional methods rely on manual classification and retrieval, which is inefficient and prone to errors. With the development of computer vision technology, image-based automatic retrieval has become possible.

[0003] However, existing image retrieval technology still has problems such as low accuracy and slow speed when processing complex lace patterns. Summary of the invention

[0004] In order to solve the problem that the existing lace sample retrieval still has low accuracy and slow speed when processing complex lace patterns, the present invention provides a lace sample retrieval system and method based on image matching, which can process complex lace pattern retrieval with high accuracy and fast retrieval speed.

[0005] The technical solution of the present invention is as follows:

[0006] A lace sample retrieval system based on image matching, comprising a data acquisition layer, a preprocessing layer, a core algorithm layer, a data storage layer, and a user interaction layer, wherein the data acquisition layer comprises an image acquisition module, an image quality detection module, and an image compression module; the image acquisition module is used to acquire lace sample images to form a data set; the image quality detection module is used to evaluate the quality of the acquired lace sample images in real time; and the image compression module is used to compress the lace sample images;

[0007] The preprocessing layer includes an image resizing module, a color space conversion module, an image enhancement module and a noise removal module; the image resizing module is used to adjust the lace sample image to a preset size; the color space conversion module is used to convert the RGB color image into a grayscale image; the image enhancement module is used to improve the image contrast; the noise removal module is used to adaptively select a suitable filtering method according to the image characteristics to denoise the lace sample image;

[0008] The core algorithm layer includes a target detection module, a feature extraction module, a similarity calculation module and a retrieval result sorting module. The target detection module is used to locate and segment the preprocessed lace sample image; the feature extraction module is used to extract features from the lace sample image; the similarity calculation module is used to retrieve by calculating the similarity of the lace sample image; and the retrieval result sorting module is used to sort according to the retrieval results.

[0009] The data storage layer is responsible for managing the system data, and the data storage layer includes an image database, a vector database and a metadata management database. The image database is used to store the original lace sample images, the vector database is used to store and index feature vectors, and the metadata management database is used to store metadata information of lace samples;

[0010] The user interaction layer has an interactive interface for user operations and display results;

[0011] As a preferred technical solution, the quality detection module specifically evaluates the quality of the captured image in real time, including clarity, brightness and contrast, and prompts the user to retake the image if the image quality does not meet the standards.

[0012] As a preferred technical solution, the image size adjustment module specifically adjusts the image to a preset size through a bilinear interpolation algorithm.

[0013] As a preferred technical solution, the image enhancement module specifically improves image contrast by applying an adaptive histogram equalization algorithm.

[0014] As a preferred technical solution, the noise removal module adaptively selects Gaussian filtering or median filtering to perform denoising on the lace sample image according to image characteristics.

[0015] As a preferred technical solution, the target detection module specifically uses a YOLOv5 model to locate and segment the lace pattern.

[0016] As a preferred technical solution, the feature extraction module uses a deep convolutional neural network to extract high-level features of lace patterns, uses a pre-trained ResNet50 as the backbone network of the feature extractor, and uses a transfer learning method to perform fine-tuning on the data set;

[0017] In the feature extraction stage, feature maps of multiple convolutional layers are extracted simultaneously; an adaptive weight mechanism is designed to dynamically adjust the weights according to the importance of features at different scales, and weighted fusion of multiple scale features is performed to generate more expressive hybrid features; the LSH algorithm is applied to the fused feature vectors to map high-dimensional features to low-dimensional space, construct multiple hash tables, and design a dynamic update mechanism to support incremental updates of the sample library.

[0018] As a preferred technical solution, the similarity calculation module integrates multiple similarity measurement methods, including cosine similarity algorithm, Euclidean distance algorithm and Manhattan distance algorithm;

[0019] The similarity calculation module uses the LSH fast algorithm to screen the candidate set, uses cosine similarity to calculate the similarity between the query image and the database sample (candidate set), combines Euclidean distance and Manhattan distance to construct a hybrid distance metric (combines pattern structure information to fine-tune the similarity), and performs weighted fusion of different similarity indicators to improve matching accuracy (a configurable similarity fusion strategy is designed to support weighted combination of different measurement methods).

[0020] As a preferred technical solution, the retrieval result sorting module uses the KD tree data structure to optimize the nearest neighbor search, sets a minimum similarity threshold, and filters out irrelevant samples; returns the K results with the highest similarity; reorders the K results according to additional pattern structure information, displays the retrieval results in thumbnail form, and provides a similarity score for each result.

[0021] A lace sample retrieval method based on image matching, the method is as follows:

[0022] Step 1: Obtain the lace sample image to be retrieved;

[0023] Step 2: preprocessing the lace sample image, wherein the preprocessing includes image size standardization, color space conversion, contrast enhancement and noise removal;

[0024] Step 3: Locate and segment the area of ​​the lace sample image through the YOLOv5 model;

[0025] Step 4: Use a deep convolutional neural network to extract the feature vector of the area described in step 3;

[0026] Step 5: Calculate the similarity between the extracted feature vector and the samples in the database;

[0027] Step 6: Sort the search results according to the similarity and display them.

[0028] Compared with the prior art, the present invention has the following beneficial effects:

[0029] (1) The present invention has wide applicability and can be applied to the production, sales and management of various lace products;

[0030] (2) In the embodiments of the present invention, the YOLO algorithm is used to detect and locate the target of the lace pattern, the deep convolutional neural network is used to extract the high-level features of the lace pattern, and an efficient similarity calculation and retrieval algorithm is designed to achieve fast matching, build a large-scale lace sample feature database, and support efficient retrieval; the speed and accuracy of lace sample retrieval are greatly improved, the labor cost is significantly reduced, and the work efficiency is improved.

[0031] (3) The present invention is accurate and reliable, and the retrieval accuracy rate reaches more than 95% in practical applications.

[0032] (4) The present invention adopts a modular and layered software architecture design. The overall architecture is divided into five main parts: data acquisition layer, preprocessing layer, core algorithm layer, data storage layer and user interaction layer. The layers communicate and exchange data through well-defined interfaces. The scalability is good, and the system architecture supports continuous optimization and functional expansion. DETAILED DESCRIPTION

[0033] The present invention is described in detail below with reference to specific embodiments.

[0034] A lace sample retrieval system based on image matching, comprising a data acquisition layer, a preprocessing layer, a core algorithm layer, a data storage layer, and a user interaction layer, wherein the data acquisition layer comprises an image acquisition module, an image quality detection module, and an image compression module; the image acquisition module is used to acquire lace sample images to form a data set; the image quality detection module is used to evaluate the quality of the acquired lace sample images in real time; and the image compression module is used to compress the lace sample images;

[0035] The preprocessing layer includes an image resizing module, a color space conversion module, an image enhancement module and a noise removal module; the image resizing module is used to adjust the lace sample image to a preset size; the color space conversion module is used to convert the RGB color image into a grayscale image to reduce the computational complexity; the image enhancement module is used to improve the image contrast; the noise removal module is used to adaptively select a suitable filtering method according to the image characteristics to denoise the lace sample image;

[0036] The core algorithm layer includes a target detection module, a feature extraction module, a similarity calculation module and a retrieval result sorting module. The target detection module is used to locate and segment the preprocessed lace sample image; the feature extraction module is used to extract features from the lace sample image; the similarity calculation module is used to retrieve by calculating the similarity of the lace sample image; and the retrieval result sorting module is used to sort according to the retrieval results.

[0037] The data storage layer is responsible for managing the system data, and the data storage layer includes an image database, a vector database and a metadata management database. The image database is used to store the original lace sample images, the vector database is used to store and index feature vectors, and the metadata management database is used to store metadata information of lace samples;

[0038] The user interaction layer has an interactive interface for user operations and display results;

[0039] Specifically, the image acquisition module supports multiple input sources, including smartphone cameras, professional digital cameras, and scanners, etc. The module uses a standard image capture API to ensure compatibility with various hardware devices.

[0040] The image compression module appropriately compresses the collected lace sample images to reduce network transmission and storage overhead, while ensuring that the image quality is not significantly reduced.

[0041] In the user interaction layer, the interaction interface includes Web front-end pages, mobile applications and API gateways;

[0042] The web front-end page adopts a responsive design and supports access from PC and mobile devices;

[0043] Native applications have been developed for iOS and Android systems to provide a better mobile user experience, and can also be searched in offline state, supporting limited sample matching in an off-network environment.

[0044] Offline retrieval is implemented based on existing technologies. The implementation principle is as follows:

[0045] (1) Local data storage: Use the local storage system of the mobile device to store part of the sample data and its feature vectors. The sample data is synchronized and updated from the server regularly when the device has a network connection;

[0046] (2) Model compression and quantization: using ONNX Runtime;

[0047] (3) Efficient local search algorithm: Use the local search algorithm LSH to compare the extracted features with the sample features stored on the device;

[0048] (4) Mobile image processing library: OpenCV mobile;

[0049] The API gateway uses RESTful API to facilitate third-party system integration, and implements JWT-based identity authentication and fine-grained access control.

[0050] Fine-grained access control implementation based on JWT:

[0051] 1. Permission definition: The backend defines fine-grained permissions, including "display samples", "search samples", "create samples", "delete samples", etc.

[0052] 2. Role definition: Create different user roles, such as "Administrator", "Designer", "Production Staff", "Marketing Staff", "Customer", etc. Assign corresponding permission sets to each role.

[0053] 3. JWT contains permission information: When generating JWT, it contains the user's role and specific permission list.

[0054] 4.API Gateway Implementation:

[0055] The API gateway parses the JWT in the incoming request, extracts the permission information in the JWT, and checks whether the user has the corresponding permissions based on the requested resource and operation type.

[0056] In addition, the system also includes some common general components: log module, monitoring module, configuration management module and task scheduling module;

[0057] The log module uses the ELK stack to implement distributed log collection, storage and analysis;

[0058] The monitoring module integrates Prometheus and Grafana to monitor system performance and resource usage in real time;

[0059] The configuration management module adopts a distributed configuration center (such as Apollo) to support dynamic configuration updates;

[0060] The task scheduling module uses a distributed task scheduling framework (such as Quartz) to manage scheduled tasks and asynchronous processing.

[0061] The system of the present invention adopts a microservice architecture, and its main services include: image processing service, feature extraction service, retrieval service, data management service and user authentication service;

[0062] The above services are deployed through Docker containers and compiled through Kubernetes clusters, which enables elastic scaling and fault self-healing of services. At the same time, service meshes (such as Istio) are used to manage inter-service communication, providing traffic management, security, and observability.

[0063] The load balancing layer uses Nginx as a reverse proxy and load balancer, combined with CDN to accelerate the distribution of static resources. The database adopts a master-slave replication architecture to ensure high data availability.

[0064] In a preferred embodiment of the present invention, the image database uses a distributed file system to store the original lace sample images, supports high-concurrency access, implements a content-based image deduplication mechanism, and avoids duplicate samples from occupying storage space.

[0065] In a preferred embodiment of the present invention, the vector database uses a high-performance vector database (such as Milvus) to store and index feature vectors, and implements an incremental update and dynamic index reconstruction mechanism for feature vectors.

[0066] In a preferred embodiment of the present invention, the metadata management database uses a relational database (such as PostgreSQL) to store metadata information of samples and supports attribute extension of different types of lace samples.

[0067] In one embodiment of the present invention, the quality detection module specifically evaluates the quality of the captured image in real time, including parameters such as clarity, brightness and contrast, and prompts the user to retake the image if the image quality does not meet the standards.

[0068] In another embodiment of the present invention, the image size adjustment module specifically adjusts the image to a preset size by a bilinear interpolation algorithm.

[0069] In an embodiment of the present invention, the image enhancement module specifically improves image contrast by applying an adaptive histogram equalization algorithm.

[0070] In addition, in the embodiment of the present invention, the noise removal module adaptively selects Gaussian filtering or median filtering to perform denoising on the lace sample image according to the image characteristics.

[0071] Image characteristics: noise type, noise intensity, image contrast, image texture complexity, edge information richness, etc.

[0072] Here are some solutions for image feature adaptation:

[0073] Noise intensity:

[0074] Less than 5%: Generally no filtering is required;

[0075] 5%-15%: Mild filtering;

[0076] More than 15%: intensity filtering;

[0077] Contrast (assuming a range of 0-1):

[0078] 0-0.3: low contrast, additional image enhancement may be required;

[0079] 0.3-0.7: normal contrast;

[0080] 0.7-1: High contrast, attention should be paid to retaining details when filtering;

[0081] Edge information (assuming edge pixel ratio is used):

[0082] 0-10%: There are fewer edges and a larger filter window can be used;

[0083] 10%-30%: medium edge information, use a medium-sized filter window;

[0084] More than 30%: Rich edge information, use a small filter window;

[0085] For example: when a lot of salt and pepper noise is detected in the image, the median filter is selected because it is particularly effective for this type of noise;

[0086] When there is a lot of Gaussian noise in the image, choose Gaussian filtering;

[0087] When the image has rich texture and edge information, choose to adjust the filter parameters to preserve these details;

[0088] The following is an example of the implementation of the present invention:

[0089] For a lace sample image: the system first analyzes its image characteristics and detects that there is 10% salt and pepper noise in the image, the image contrast is high, and the edge information is rich;

[0090] Based on the above characteristics, the system decides to use median filtering because it can effectively remove salt and pepper noise while retaining edge information.

[0091] The system also adjusts the window size of the median filter, such as selecting a 3x3 window, to strike a balance between denoising and retaining details.

[0092] In one embodiment of the present invention, the target detection module specifically uses the YOLOv5 model to locate and segment the lace pattern; its working principle is: a large number of labeled lace sample images are used for model training, and the model output includes target frame coordinates, confidence and category probability, and finally, overlapping redundant detection frames are removed to retain the best detection result;

[0093] In one embodiment of the present invention, the feature extraction module uses a deep convolutional neural network to extract high-level features of the lace pattern, uses a pre-trained ResNet50 as the backbone network of the feature extractor, and uses a transfer learning method to perform fine-tuning on the dataset;

[0094] In the feature extraction stage, feature maps of multiple convolutional layers are extracted simultaneously; an adaptive weight mechanism is designed to dynamically adjust the weights according to the importance of features at different scales, and weighted fusion of multiple scale features is performed to generate more expressive hybrid features; the LSH algorithm is applied to the fused feature vectors to map high-dimensional features to low-dimensional space, build multiple hash tables, and design a dynamic update mechanism to support incremental updates of the sample library; a batch processing mechanism for feature extraction is implemented to improve the efficiency of processing a large number of images, and the model is stored in the ONNX format to ensure cross-platform compatibility.

[0095] The adaptive weight mechanism is a method to dynamically adjust the importance of different features to optimize the fusion of multi-scale features. This mechanism can automatically adjust the weights of each scale feature according to the characteristics of the input image and task requirements, thereby generating more effective hybrid features.

[0096] The following is a detailed explanation of the adaptive weight mechanism

[0097] How the adaptive weight mechanism works:

[0098] (1) Feature extraction: Extract feature maps from multiple convolutional layers.

[0099] (2) Weight calculation: Calculate the importance of each scale feature based on certain indicators.

[0100] (3) Weight normalization: Normalize the calculated weights to ensure that their sum is 1.

[0101] (4) Weighted fusion: Use normalized weights to perform weighted summation of features of different scales.

[0102] The following is an example of an adaptive weight mechanism in the implementation of the present invention:

[0103] For example, using ResNet50 as the backbone network, features are extracted from three different convolutional layers:

[0104] (1) Low-level features (such as the output of the second convolutional block)

[0105] (2) Intermediate features (such as the output of the third convolutional block)

[0106] (3) High-level features (such as the output of the 4th convolutional block)

[0107] The implementation steps of the adaptive weight mechanism are:

[0108] (1) Feature extraction:

[0109] Low-level features: F_low (size: 56x56x256)

[0110] Intermediate feature: F_mid (size: 28x28x512)

[0111] High-level features: F_high (size: 14x14x1024)

[0112] (2) Weight calculation: Use a channel attention mechanism such as the Squeeze-and-Excitation module (existing technology) to calculate the importance of each feature map. For each feature map F_i:

[0113] a. Global average pooling: Z_i = GAP(F_i)

[0114] b. Use fully connected layer: W_i = FC(Z_i)

[0115] For example: W_low=0.3W_mid=0.5W_high=0.2

[0116] (3) Weight normalization: sum_W=W_low+W_mid+W_high=1.0W_low_norm=W_low / sum_W=0.3W_mid_norm=W_mid / sum_W=0.5W_high_norm=W_high / sum_W=0.2

[0117] (4) Weighted fusion: First, resize all feature maps to the same spatial dimension (e.g., 14x14). Then, perform weighted summation: F_mixed = W_low_norm*F_low_resized+W_mid_norm*F_mid_resized+W_high_norm*F_high_resized

[0118] This process is dynamic, and the weights may be different for different input images. For example:

[0119] For a lace image containing fine textures, the weights of low-level features may be higher.

[0120] For a lace image with a more obvious overall pattern, the weights of mid-level and high-level features may be higher.

[0121] Through this adaptive weight mechanism, the system can dynamically adjust the importance of features at different scales according to the specific characteristics of each lace image, thereby generating more effective hybrid features and improving the accuracy of subsequent retrieval.

[0122] The advantage of this mechanism is that it can automatically adapt to different types of lace patterns without the need for manual parameter adjustment, which improves the flexibility and robustness of the system.

[0123] Weighted fusion of multiple scale features means combining feature maps from different convolutional layers into a new, more expressive feature representation by weighted summation. This process usually includes several steps: feature alignment, weight assignment, and weighted summation. The following is the process and related algorithms:

[0124] Weighted fusion process of multiple scale features:

[0125] (1) Feature alignment

[0126] First, since the feature maps output by different convolutional layers may have different sizes, they need to be adjusted to the same spatial dimension. This is achieved by upsampling the smaller feature maps.

[0127] Common methods:

[0128] Bilinear Interpolation

[0129] Transposed Convolution

[0130] Nearest Neighbor Interpolation

[0131] (2) Weight allocation

[0132] Assign a weight to each scale feature, which can be fixed or dynamically calculated (such as the adaptive weight mechanism mentioned above).

[0133] (3) Weighted summation

[0134] The aligned feature maps are weighted summed according to the assigned weights.

[0135] Weighted fusion algorithm for multiple scale features:

[0136] (1) Algorithm description:

[0137] Suppose we have N feature maps of different scales, denoted as F1, F2, ..., F N , the corresponding weights are w1,w2,...,w N .

[0138] The weighted fusion algorithm can be expressed as:

[0139] F_fused=Σ(w i *F i )(i=1 to N)

[0140] Among them, F_fused is the fused feature map.

[0141] (2) Advantages of the algorithm:

[0142] Multi-scale information fusion: By combining features from different layers, various visual information from low-level to high-level can be captured.

[0143] Flexibility: The weights can be adjusted according to the specific task to balance the importance of features at different scales.

[0144] Computational efficiency: The weighted sum operation has low computational complexity and is easy to implement and optimize.

[0145] Differentiability: The entire process is differentiable and can be used in an end-to-end deep learning model and optimize the weights via back-propagation.

[0146] In the lace sample retrieval system, this weighted fusion method can help generate a more comprehensive feature representation that includes both the detailed texture information of the lace (from low-level features) and the overall pattern structure (from high-level features), thereby improving the accuracy and robustness of the retrieval.

[0147] The dynamic update mechanism is a method implemented in the Lace Sample Retrieval System to support incremental updates of the sample library. This mechanism allows the system to efficiently add new samples or update existing samples without completely rebuilding the index. The following is the specific implementation of the dynamic update mechanism:

[0148] (1) Incremental feature extraction

[0149] When new lace samples are added to the system:

[0150] Use the existing feature extraction model to extract features from new samples;

[0151] Convert the extracted feature vector into LSH (Locality Sensitive Hashing) representation.

[0152] (2) Dynamic Update of LSH Table

[0153] LSH (Locality-Sensitive Hashing) is a technology that maps high-dimensional data to low-dimensional space for fast approximate nearest neighbor search. The dynamic update mechanism is mainly reflected in the update of the LSH table:

[0154] a)Multiple hash table structures:

[0155] The system maintains multiple LSH hash tables, each using a different hash function;

[0156] This structure improves the accuracy of retrieval and also facilitates incremental updates.

[0157] b) Dynamic expansion of hash bucket:

[0158] Each hash table contains multiple hash buckets;

[0159] When a new sample is added, the system calculates its hash value and puts it into the corresponding hash bucket;

[0160] If the number of samples in a bucket exceeds the preset threshold, the system will dynamically split the bucket to maintain query efficiency.

[0161] c) Lazy deletion strategy:

[0162] When a sample needs to be deleted, it is not immediately removed from the hash table;

[0163] Instead, they are marked as "deleted" and then actually deleted in subsequent batch maintenance;

[0164] This strategy reduces the impact of frequent deletion operations on system performance.

[0165] (3) Gradual Adjustment of Index Structure

[0166] The system will record the number of updates or the amount of updated data since the last full rebuild;

[0167] When the update volume reaches a certain threshold, a gradual adjustment of the index structure is triggered;

[0168] This process may include rebalancing hash buckets, optimizing hash functions, etc.

[0169] (4) Concurrency Control Mechanism

[0170] To support highly concurrent update and query operations:

[0171] Using a read-write lock mechanism allows multiple query operations to be performed simultaneously, but update operations require a write lock;

[0172] Implement version control to ensure that queries always see a consistent view of the data.

[0173] (5) Batch update optimization

[0174] The system supports adding new samples in batches;

[0175] When updating in batches, the system will optimize the update order and hash calculation process to improve efficiency;

[0176] (6) Update log and rollback mechanism.

[0177] Record all update operations;

[0178] If an error occurs during the update, the system can be rolled back to a previous stable state.

[0179] 6.3.2 Specific examples of dynamic update mechanism:

[0180] Suppose our lace sample retrieval system currently contains 10,000 samples, and now we need to add 100 new samples:

[0181] (1) The system first performs feature extraction and LSH encoding on these 100 new samples.

[0182] (2) For each new sample:

[0183] Calculate its hash value in each LSH table;

[0184] Add the sample ID and feature vector to the corresponding hash bucket;

[0185] (3) If the number of samples in a hash bucket exceeds a preset threshold (for example, the threshold is set to 100), the system will create two new sub-buckets and use another hash function to redistribute the samples in the bucket to the two sub-buckets;

[0186] (4) The system records this update, including the number of samples added and the changes in the hash bucket;

[0187] (5) If the total update volume exceeds a preset threshold (e.g. 10% of the total sample volume), the system will trigger a gradual adjustment during the off-peak period, including:

[0188] Rebalance all hash buckets, optimize hash functions, and clean up samples marked as "deleted".

[0189] Through this dynamic update mechanism, the system can flexibly respond to changes in the sample library without frequently rebuilding the entire index structure, thus ensuring the efficiency and scalability of the system.

[0190] This is extremely important for lace sample libraries that need to be updated frequently, as it allows the system to quickly adapt to new samples and changing trends while maintaining efficient retrieval performance.

[0191] In one embodiment of the present invention, the similarity calculation module integrates multiple similarity measurement methods, including cosine similarity algorithm, Euclidean distance algorithm and Manhattan distance algorithm;

[0192] The similarity calculation module uses the LSH fast algorithm to screen the candidate set, uses cosine similarity to calculate the similarity between the query image and the database sample, combines the Euclidean distance and Manhattan distance to construct a hybrid distance metric, and performs weighted fusion of different similarity indicators to improve matching accuracy.

[0193] The candidate set is screened from the sample feature database using the LSH fast algorithm.

[0194] The main purpose of constructing a hybrid distance metric is to fine-tune the similarity to improve the matching accuracy.

[0195] Similarity weighted fusion is achieved by combining multiple distance metrics and assigning a weight to each method. This method aims to take advantage of the advantages of different metrics while taking into account the structural information of the lace pattern to obtain a more accurate similarity assessment. The following is an algorithm description and Python code example to implement this weighted fusion:

[0196] Algorithm description:

[0197] (1) Calculate various distance / similarity indicators;

[0198] (2) normalize the indicators so that they are on the same scale;

[0199] (3) Application weights;

[0200] (4) Combining pattern structure information;

[0201] (5) Calculate the weighted sum.

[0202] Code example:

[0203] import numpy as np

[0204] from scipy.spatial.distance import cosine,euclidean,cityblock

[0205] def normalize(value,min_val,max_val):

[0206] return(value-min_val) / (max_val-min_val)

[0207] def compute_structure_diff(feature1,feature2):

[0208] #This function needs to be implemented according to the specific pattern structure characteristics

[0209] #This is just a sample implementation

[0210] return np.abs(np.mean(feature1)-np.mean(feature2))

[0211] def weighted_similarity(feature1,feature2,weights,normalize_range):

[0212] #Calculate various distances / similarity

[0213] cosine_sim=1-cosine(feature1,feature2)#Convert to similarity

[0214] euclidean_dist=euclidean(feature1,feature2)

[0215] manhattan_dist=cityblock(feature1,feature2)

[0216] structure_diff=compute_structure_diff(featurel,feature2)

[0217] norm_cosine=cosine_sim#cosine similarity is already in the range [e,1]

[0218] norn_euclidean=normalize(euclidean_dist,normalize_range['euclidean'][@],normalize_range['euelidean'][1])

[0219] norn_manhattan=normalize(manhattan_dist,normalize_range['manhattan'][@],normalize_range['manhattan'][1])

[0220] norn_structure=normalize(structure_diff,normalize_range['structure'][0],normalize_range['structure'][1])

[0221] Apply weights and calculate weighted sum

[0222] weighted_sum=(weights['cosine']*norm_cosine+weights['euclidean']*(1-norm_euclidean)

[0223] Convert to similarity

[0224] weights['manhattan']

[0225] (1-norm_manhattan)

[0226] Convert to similarity

[0227] weights['structure']*(1-norm_structure)

[0228] #Convert to similarity

[0229] return weighted_sum

[0230] Usage Examples

[0231] feature1=np.random.rand(108)

[0232] feature2=np.random.rand(100)

[0233] weights = {

[0234] cosine':e.3,

[0235] 'euclidean':e.3,

[0236] 'manhattan':8.2,

[0237] 'structure':@.2

[0238] normalize_range={

[0239] 'euelidean': (@, 10), # assumed range

[0240] 'manhattan':(8,20), #assumed range

[0241] "structure':(@,1)

[0242] Scope of assumptions

[0243] similarity=weighted_similarity(feature1,feature2,weights,normalize_range)

[0244] print(f"Weighted similarity:{similarity}")

[0245] In one embodiment of the present invention, the retrieval result sorting module uses a KD tree data structure to optimize the nearest neighbor search, sets a minimum similarity threshold, and filters out irrelevant samples; returns the K results with the highest similarity; reorders the K results based on additional pattern structure information, displays the retrieval results in thumbnail form, and provides a similarity score for each result.

[0246] The KD tree data structure optimizes the nearest neighbor search, which is an optimization of the nearest neighbor search process. KD tree (K-Dimensional Tree) is a data structure used to organize points in k-dimensional space, which is very suitable for nearest neighbor search in multidimensional space. In this system, it is used to speed up the search process for similar lace samples. KD tree is a classic data structure and is a prior art. However, applying KD tree to the nearest neighbor search optimization in the lace sample retrieval system may be an innovation of this system. In particular, it is combined with other techniques (such as minimum similarity threshold filtering, additional pattern structure information reordering, etc.) to form a comprehensive retrieval result ranking scheme.

[0247] Additional pattern structure information refers to some specific features of lace samples. Some features may not be fully captured by conventional feature extraction methods (such as deep learning models), but are very important for the recognition and matching of lace patterns. Including: lace texture patterns (such as patterns, geometric figures, etc.), pattern symmetry, pattern complexity, pattern density distribution, etc. The source of information is mainly metadata information, that is, descriptive information attached to the sample, including: craftsmanship, pattern, color, material, batch, process, etc.

[0248] A lace sample retrieval method based on image matching, the method comprising:

[0249] Step 1: Obtain the lace sample image to be retrieved;

[0250] Step 2: preprocessing the lace sample image, wherein the preprocessing includes image size standardization, color space conversion, contrast enhancement and noise removal;

[0251] Step 3: Locate and segment the area of ​​the lace sample image through the YOLOv5 model;

[0252] Step 4: Use a deep convolutional neural network to extract the feature vector of the area described in step 3;

[0253] Step 5: Calculate the similarity between the extracted feature vector and the samples in the database;

[0254] Step 6: Sort the search results according to the similarity and display them.

[0255] The present invention is described below in conjunction with a specific embodiment:

[0256] 1. The user uses a smartphone to take a picture of a lace sample with a size of 3024x4032 pixels.

[0257] 2. The system scales the image to 224x224 pixels and converts it to grayscale.

[0258] 3. The YOLO detection module locates the lace pattern and outputs the bounding box coordinates (50, 30, 180, 200).

[0259] 4. Extract ROI (Region of Interest) based on the bounding box and input it into the feature extraction network.

[0260] 5. The ResNet50 network outputs a 2048-dimensional feature vector v = [0.1, 0.3, …, 0.2].

[0261] 6. The system calculates the cosine similarity between the feature vector v and all samples in the database.

[0262] 7. Select the 10 results with the highest similarity, and the similarities are [0.95, 0.93, …, 0.85].

[0263] 8. The system displays thumbnails and similarity scores of these 10 results.

[0264] 9. Users can click to view detailed information such as sample number, production date, etc.

[0265] The entire retrieval process of the present invention takes no more than 1 second on an ordinary PC, and achieves fast and accurate matching in a database of 10,000 samples.

[0266] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A lace sample retrieval system based on image matching, comprising a data acquisition layer, a preprocessing layer, a core algorithm layer, a data storage layer, and a user interaction layer, characterized in that: The data acquisition layer includes an image acquisition module, an image quality detection module and an image compression module; the image acquisition module is used to acquire lace sample images to form a data set; the image quality detection module is used to evaluate the quality of the acquired lace sample images in real time; the image compression module is used to compress the lace sample images; The preprocessing layer includes an image resizing module, a color space conversion module, an image enhancement module and a noise removal module; the image resizing module is used to adjust the lace sample image to a preset size; the color space conversion module is used to convert the RGB color image into a grayscale image; the image enhancement module is used to improve the image contrast; the noise removal module is used to adaptively select a suitable filtering method according to the image characteristics to denoise the lace sample image; The core algorithm layer includes a target detection module, a feature extraction module, a similarity calculation module and a retrieval result sorting module. The target detection module is used to locate and segment the preprocessed lace sample image; the feature extraction module is used to extract features from the lace sample image; the similarity calculation module is used to retrieve by calculating the similarity of the lace sample image; the retrieval result sorting module is used to sort according to the retrieval results; The data storage layer is responsible for managing the data of the system, and the data storage layer includes an image database, a vector database and a metadata management database. The image database is used to store the original lace sample images, the vector database is used to store and index feature vectors, and the metadata management database is used to store metadata information of lace samples; The user interaction layer has an interactive interface for user operations and display results.

2. A lace sample retrieval system based on image matching according to claim 1, characterized in that: The quality detection module specifically evaluates the quality of the captured image in real time, including clarity, brightness and contrast, and prompts the user to retake the image if the image quality does not meet the standards.

3. A lace sample retrieval system based on image matching according to claim 1, characterized in that: The image size adjustment module specifically adjusts the image to a preset size through a bilinear interpolation algorithm.

4. The lace sample retrieval system based on image matching according to claim 1, characterized in that: The image enhancement module specifically improves image contrast by applying an adaptive histogram equalization algorithm.

5. The lace sample retrieval system based on image matching according to claim 1, characterized in that: The noise removal module adaptively selects Gaussian filtering or median filtering to perform denoising on the lace sample image according to the image characteristics.

6. The lace sample retrieval system based on image matching according to claim 1, characterized in that: The target detection module specifically uses the YOLOv5 model to locate and segment the lace pattern.

7. The lace sample retrieval system based on image matching according to claim 1, characterized in that: The feature extraction module uses a deep convolutional neural network to extract high-level features of lace patterns, uses a pre-trained ResNet50 as the backbone network of the feature extractor, and uses a transfer learning method to fine-tune on the dataset; In the feature extraction stage, feature maps of multiple convolutional layers are extracted simultaneously; an adaptive weight mechanism is designed to dynamically adjust weights according to the importance of features at different scales, and weighted fusion of features at multiple scales is performed to generate more expressive hybrid features; The LSH algorithm is applied to the fused feature vector to map the high-dimensional features into the low-dimensional space, build multiple hash tables, and design a dynamic update mechanism to support the incremental update of the sample library.

8. The lace sample retrieval system based on image matching according to claim 1, characterized in that: The similarity calculation module integrates multiple similarity measurement methods, including cosine similarity algorithm, Euclidean distance algorithm and Manhattan distance algorithm; The similarity calculation module uses the LSH fast algorithm to screen the candidate set, uses cosine similarity to calculate the similarity between the query image and the database sample, combines the Euclidean distance and Manhattan distance to construct a hybrid distance metric, and performs weighted fusion of different similarity indicators.

9. The lace sample retrieval system based on image matching according to claim 1, characterized in that: The retrieval result sorting module uses the KD tree data structure to optimize the nearest neighbor search, sets a minimum similarity threshold, and filters out irrelevant samples; returns the K results with the highest similarity; reorders the K results according to additional pattern structure information, displays the retrieval results in thumbnail form, and provides a similarity score for each result.

10. A lace sample retrieval method based on image matching, characterized in that: Step 1: Obtain the lace sample image to be retrieved; Step 2: preprocessing the lace sample image, wherein the preprocessing includes image size standardization, color space conversion, contrast enhancement and noise removal; Step 3: Locate and segment the area of ​​the lace sample image through the YOLOv5 model; Step 4: Use a deep convolutional neural network to extract the feature vector of the area described in step 3; Step 5: Calculate the similarity between the extracted feature vector and the samples in the database; Step 6: Sort the search results according to the similarity and display them.