Image matching method, device, electronic device and storage medium
By denoising and splitting the images, and using the image category recognition model to match the image set from the database, it solves the problem of insufficient computing resources and slow matching speed caused by the large amount of image database data, and achieves efficient image matching.
Patent Information
- Application Number
- CN202011525192.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-22
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2040-12-22
AI Technical Summary
When the amount of image data in the image database is too large, the image matching process will occupy too many computing resources, causing the matching speed to slow down.
By performing denoising, target image extraction and image splitting on the image to be matched, the trained image category recognition model is used to identify the category of the image block, and the corresponding image set is matched from the pre-built image database to avoid directly processing a large number of images. data.
It effectively reduces the occupation of computing resources, improves the image matching speed, and solves the matching speed problem caused by the large amount of data.
Smart Images

Figure CN112561893B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image detection, and in particular to a picture matching method, device, electronic equipment and computer-readable storage medium. Background Art
[0002] With the rapid development of science and technology, many research directions have emerged, among which effective image recognition and image matching are the current hot topics.
[0003] Currently, the main steps of image matching include: inputting the user's input image data into a pre-trained deep learning matching model, and using the deep learning model to match images similar to the image data from a pre-built image database. Although this method can achieve image matching, when the amount of image data in the image database is too large, the entire image matching process will take up too many computing resources, resulting in insufficient computing resources during image matching, which in turn affects the matching speed. Summary of the invention
[0004] The present invention provides a picture matching method, device, electronic device and computer-readable storage medium, the main purpose of which is to solve the problem of insufficient computing resources that affects the image matching speed.
[0005] To achieve the above object, the present invention provides a picture matching method, comprising:
[0006] Acquire an image to be matched input by a user, and perform denoising processing on the image to be matched to obtain a denoised image;
[0007] Extracting a target image from the denoised image;
[0008] Performing image segmentation on the target image to obtain one or more image blocks;
[0009] Receiving an original image category recognition model, training the original image category recognition model to obtain a standard image category recognition model, and using the standard image category recognition model to identify image categories corresponding to one or more image blocks to obtain an image category set;
[0010] By using the image category set, an image set corresponding to the image to be matched is matched from a pre-constructed image database.
[0011] Optionally, the training of the original image category recognition model to obtain a standard image category recognition model includes:
[0012] Get the image training set;
[0013] The image training set is used to perform K-fold cross validation training on the original image category recognition model to obtain the standard image category recognition model.
[0014] Optionally, performing K-fold cross validation training on the original image category recognition model using the image training set to obtain the standard image category recognition model includes:
[0015] Dividing the image training set into k training subsets, and using each of the k training subsets to train the original image category recognition model to obtain the image category recognition model to be verified;
[0016] Performing model evaluation on the image category recognition model to be verified to obtain an evaluation score, and when the evaluation score is less than a preset standard score, obtaining the standard image category recognition model.
[0017] Optionally, performing denoising processing on the image to be matched to obtain a denoised image includes:
[0018] Using a pre-constructed Gaussian filter, filtering the image to be matched to obtain a filtered image;
[0019] A convolution kernel is constructed, and a convolution operation is performed on the filtered image using the convolution kernel to obtain the denoised image.
[0020] Optionally, performing a convolution operation on the filtered image using the convolution kernel to obtain the denoised image includes:
[0021] Selecting the upper left pixel of the filtered image as the kernel center, and performing weighted averaging on the kernel center using the convolution kernel to obtain a weighted average value;
[0022] The weighted average value is used to replace the original pixel value of the core center until the core center moves from the upper left pixel of the filtered image to the lower right pixel of the filtered image, thereby obtaining the denoised image.
[0023] Optionally, performing weighted averaging on the core center using the convolution kernel to obtain a weighted average value includes:
[0024] Using the kernel center, construct a pixel matrix having the same size as the convolution kernel;
[0025] Perform weighted averaging on the convolution kernel and the pixel matrix to obtain the weighted average value.
[0026] Optionally, extracting a target image from the denoised image includes:
[0027] Performing target contour extraction on the denoised image to obtain a target contour map;
[0028] The target image is obtained by performing a correction operation on the target contour image through a preset affine transformation algorithm.
[0029] In order to solve the above problem, the present invention further provides a picture matching device, the device comprising:
[0030] A target image extraction module is used to obtain a to-be-matched image input by a user, perform denoising on the to-be-matched image to obtain a denoised image, and extract a target image from the denoised image;
[0031] A target splitting module, used to perform image splitting on the target image to obtain one or more image blocks;
[0032] An image category recognition module is used to receive an original image category recognition model, train the original image category recognition model to obtain a standard image category recognition model, and use the standard image category recognition model to identify the image category corresponding to one or more image blocks to obtain an image category set;
[0033] The image matching module is used to use the image category set to match an image set corresponding to the image to be matched from a pre-built image database.
[0034] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0035] a memory storing at least one instruction; and
[0036] The processor executes the instructions stored in the memory to implement any one of the above-mentioned image matching methods.
[0037] In order to solve the above problems, the present invention also provides a computer-readable storage medium, including a data storage area and a program storage area, the data storage area stores created data, and the program storage area stores a computer program; wherein, when the computer program is executed by a processor, any one of the above-mentioned image matching methods is implemented.
[0038] The embodiment of the present invention first extracts the target image from the image to be matched, and in order to improve the accuracy of matching the target image, performs an image splitting operation on the target image to obtain one or more image blocks, and then uses the trained image category recognition model to identify the image categories corresponding to one or more of the image blocks to obtain an image category set, and finally uses the image category set to match the image set corresponding to the image to be matched from a pre-built image database. Compared with the background technology that uses a deep learning matching model to directly perform image matching with the image in the image database, the present invention first identifies the image category of the image to be matched through an image category recognition model, and matches the corresponding image set from the image database through the image category. Therefore, it can be seen that the image category recognition model only processes the image to be matched and does not need to process the image in the image database. Therefore, when the image data amount of the image database is too large, the model will not occupy too many computing resources when performing image matching, resulting in affecting the matching speed. Therefore, the picture matching method, device and computer-readable storage medium proposed in the present invention can solve the problem of insufficient computing resources affecting the image matching speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 A schematic diagram of a flow chart of a picture matching method provided by an embodiment of the present invention;
[0040] Figure 2 A detailed flowchart of S1 of the image matching method provided by an embodiment of the present invention;
[0041] Figure 3 A detailed flowchart of S3 of the image matching method provided by one embodiment of the present invention;
[0042] Figure 4 A schematic diagram of modules of a picture matching device provided by an embodiment of the present invention;
[0043] Figure 5 A schematic diagram of the internal structure of an electronic device for implementing a picture matching method provided by an embodiment of the present invention;
[0044] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0045] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0046] The embodiment of the present application provides a method for image matching, and the execution subject of the method includes but is not limited to at least one of the electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiment of the present application. In other words, the method for image matching can be executed by software or hardware installed in a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc.
[0047] Reference Figure 1 FIG. 1 is a flow chart of a picture matching method provided by an embodiment of the present invention. In this embodiment, the picture matching method includes:
[0048] S1. Obtain an image to be matched input by a user, and perform denoising processing on the image to be matched to obtain a denoised image.
[0049] In the embodiment of the present invention, the images input by the user or the images crawled from the network by using a crawler program are collectively referred to as the to-be-matched images.
[0050] In detail, since the received image to be matched may include many noise points, which will affect the subsequent image matching, Figure 2 As shown, the S1 includes:
[0051] S11, using a pre-constructed Gaussian filter to filter the image to be matched to obtain a filtered image;
[0052] S12. Construct a convolution kernel, and use the convolution kernel to perform a convolution operation on the filtered image to obtain the denoised image.
[0053] Furthermore, the Gaussian filter described in the present invention is a linear smoothing filter constructed based on a Gaussian distribution function, and has a good denoising effect on noise points that are randomly distributed and obey a normal distribution.
[0054] In the embodiment of the present invention, the convolution kernel is composed of a convolution coefficient and a matrix block, wherein the size of the matrix block is 5*5, and the convolution kernel is specifically as follows:
[0055]
[0056] in It is called a convolution coefficient. In detail, the convolution kernel is constructed, and the convolution operation is performed on the filtered image using the convolution kernel to obtain the denoised image, including: selecting the upper left pixel of the filtered image as the kernel center, using the convolution kernel to perform weighted averaging on the kernel center to obtain a weighted average value, and replacing the original pixel value of the kernel center with the weighted average value until the kernel center moves from the upper left pixel of the filtered image to the lower right pixel of the filtered image, thereby obtaining the denoised image.
[0057] In detail, the method of using the convolution kernel to perform weighted averaging on the kernel center to obtain the weighted average value includes: using the kernel center to construct a pixel matrix of the same size as the convolution kernel, and performing weighted averaging on the convolution kernel and the pixel matrix to obtain the weighted average value.
[0058] If the kernel center is at the upper left pixel of the filtered image, operations such as padding with zeros or padding with 1s are used above and to the left of the kernel center, respectively, and a 5*5 pixel matrix is constructed in combination with the pixels to the right and below the kernel center. The pixel matrix and the convolution kernel have the same size, and the corresponding multiplication and addition are performed and then averaged to obtain the weighted average value, and then the weighted average value is used to replace the original pixels to obtain the denoised image.
[0059] S2. Extracting a target image from the denoised image.
[0060] Furthermore, in an embodiment of the present invention, extracting the target image from the denoised image includes: performing target contour extraction on the denoised image to obtain a target contour map; and performing a correction operation on the target contour map through a preset affine transformation algorithm to obtain the target image.
[0061] In detail, performing target contour extraction on the denoised image to obtain a target contour map includes: performing a grayscale operation on the denoised image to obtain a grayscale image; and using a pre-built contour extraction algorithm to extract the target contour from the grayscale image to obtain the target contour map.
[0062] In the embodiment of the present invention, the grayscale operation is performed using the following formula:
[0063] Gray=0.29R+0.58G+0.11B
[0064] Among them, Gray represents the grayscale image, R, G, and B represent the RGB values of the denoised image respectively, wherein R represents the red channel value, G represents the green channel value, and B represents the blue channel value.
[0065] In the embodiment of the present invention, the target contour is extracted from the grayscale image using an edge detection method to obtain the target contour map. Furthermore, since the target contour extracted by the above edge detection may be distorted, an affine transformation algorithm is required to perform correction on the target contour map. Specifically, the correction is performed using the following affine transformation formula:
[0066]
[0067] Among them, x, y are the pixel coordinates of the target contour map, x′, y′ are the corrected pixel coordinates, a, b, c, d represent the parameter values in the preset affine transformation matrix, and the above formula operation is executed to obtain the target image. For example, if the user inputs an image to be matched including a cat and a dog, after the above processing, a target image including a cat and a target image including a dog can be obtained respectively.
[0068] S3. Perform image segmentation on the target image to obtain one or more image blocks.
[0069] As described above, when the user inputs the images to be matched including a cat and a dog, a target image including a cat and a target image including a dog can be obtained respectively. However, in order to expand the image richness of the target image, the present invention further performs image segmentation on the target image. For details, refer to Figure 3 As shown, the S3 includes:
[0070] S31, extracting a target contour map of the target image;
[0071] S32, determining whether the target contour image is circular or elliptical;
[0072] S33, if the target contour image is circular or elliptical, perform image segmentation on the target image using a fan-shaped segmentation method to obtain one or more image blocks;
[0073] S34: If the target contour image is not a circle or an ellipse, perform image segmentation on the target image using a rectangular segmentation method to obtain one or more image blocks.
[0074] In the embodiment of the present invention, S2 includes the step of performing target contour extraction on the image to be matched to obtain a target contour map. Therefore, after S2 executes this step, the target contour map is stored in a database, and when the target contour map is needed in S3, it is extracted from the database.
[0075] Furthermore, the present invention constructs an OpenCV interface calling script, and utilizes the OpenCV interface calling script to call the HoughEllipse interface provided by OpenCV, so as to determine whether the target contour map is a circle or an ellipse.
[0076] If the target contour is a circle or an ellipse, the target image is segmented using a fan-shaped segmentation method, wherein the fan-shaped segmentation method is to set the target contour in the target image as a circle, and according to the principle that a circle can be split into several sectors, the target image is divided into two, three, four, etc., so as to obtain one or more image blocks similar to a sector shape.
[0077] If the target contour image is not a circle or an ellipse, the target image is segmented using a rectangular segmentation method, wherein the rectangular segmentation method is to set the target contour image in the target image as a rectangle, and according to the principle that a rectangle can be split into a number of square blocks, the target image is divided into two, three, four, etc., so as to obtain one or more image blocks similar to a square shape.
[0078] S4. Receive an original image category recognition model, train the original image category recognition model to obtain a standard image category recognition model, and use the standard image category recognition model to identify image categories corresponding to one or more image blocks to obtain an image category set.
[0079] In detail, the training of the original image category recognition model to obtain the standard image category recognition model includes: obtaining an image training set; and performing K-fold cross-validation training on the original image category recognition model using the image training set to obtain the standard image category recognition model.
[0080] Furthermore, the image training set uses crawler technology to crawl various images from the Internet, including various animals and plants, handicrafts, and manufactured products. The original image category recognition model is a classification model based on a convolutional neural network, which can determine whether each image includes a tiger, flowers, plants, cars, etc.
[0081] In detail, the method of using the image training set to perform K-fold cross-validation training on the original image category recognition model to obtain the standard image category recognition model includes: dividing the image training set into K training subsets, using each of the K training subsets to train the original image category recognition model to obtain the image category recognition model to be verified, performing model evaluation on the image category recognition model to be verified to obtain an evaluation score, and when the evaluation score is less than a preset standard score, obtaining the standard image category recognition model.
[0082] The embodiment of the present invention uses the following two training methods to train the original image category recognition model to obtain the image category recognition model to be verified:
[0083] s=((w / (kb)+(b+ab) / (tw)) / 2
[0084] s=((w / (kb-ab)+(b+ab) / (kw)) / 2
[0085] Among them, s is the target contour ratio value of a specific image in the training subset, b is the number of image contour points of a specific image in the training subset, w is the number of blank area points of a specific image in the training subset, ab is the number of target contour points of a specific image in the training subset calculated by the compensation algorithm after the target contour is deformed, and t is the total number of pixels of a specific image in the training subset. When the target contour ratio value of each image in the training subset is less than the specified threshold, the image category recognition model to be verified is obtained.
[0086] In the embodiment of the present invention, the model evaluation is performed on the image category recognition model to be verified as follows to obtain an evaluation score. When the evaluation score is less than a preset standard score, the standard image category recognition model is obtained.
[0087] The embodiment of the present invention adopts a dual index weighting method to perform model evaluation on the image category recognition model to be verified to obtain an evaluation score:
[0088] F=0.3*FN / (TP+FN)*100%
[0089] In the formula, F represents the evaluation score, TP represents the number of image training sets predicted as correct categories by the image category recognition model to be verified, and FN represents the number of image training sets predicted as incorrect categories by the image category recognition model to be verified.
[0090] The smaller the value of the evaluation score F is, the better the model is. In the embodiment of the present invention, the preset standard score is set to 0.15.
[0091] The embodiment of the present invention uses the image category recognition model to detect the graphic blocks, such as detecting the graphic category of a torso graphic block as a tiger or a leopard, detecting the graphic category of a head graphic block as a cat or a leopard, and so on.
[0092] S5. Using the image category set, match an image set corresponding to the image to be matched from a pre-built image database.
[0093] In the embodiment of the present invention, the images in the image database are stored according to image categories, and each image stored in the image database has a category label, such as a cat category image, a dog category image, and the like.
[0094] If the images to be matched include cat and dog categories, all images including cat and dog categories are matched from the image database using the cat and dog categories.
[0095] The embodiment of the present invention first extracts the target image from the image to be matched, and in order to improve the accuracy of matching the target image, performs an image splitting operation on the target image to obtain one or more image blocks, and then uses the trained image category recognition model to identify the image categories corresponding to one or more of the image blocks to obtain an image category set, and finally uses the image category set to match the image set corresponding to the image to be matched from a pre-built image database. Compared with the background technology that uses a deep learning matching model to directly perform image matching with the image in the image database, the present invention first identifies the image category of the image to be matched through an image category recognition model, and matches the corresponding image set from the image database through the image category. Therefore, it can be seen that the image category recognition model only processes the image to be matched and does not need to process the image in the image database. Therefore, when the image data amount of the image database is too large, the model will not occupy too many computing resources when performing image matching, resulting in affecting the matching speed. Therefore, the picture matching method, device and computer-readable storage medium proposed in the present invention can solve the problem of insufficient computing resources affecting the image matching speed.
[0096] like Figure 4 FIG. 1 is a schematic diagram of a module of the image matching device of the present invention.
[0097] The image matching device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the image matching device can include a target image extraction module 101, a target segmentation module 102, an image category recognition module 103 and an image matching module 104. The module described in the present invention can also be referred to as a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.
[0098] In this embodiment, the functions of each module / unit are as follows:
[0099] The target image extraction module 101 is used to obtain the image to be matched input by the user, perform denoising on the image to be matched to obtain a denoised image, and extract the target image from the denoised image;
[0100] The target splitting module 102 is used to perform image splitting on the target image to obtain one or more image blocks;
[0101] The image category recognition module 103 is used to receive an original image category recognition model, train the original image category recognition model to obtain a standard image category recognition model, and use the standard image category recognition model to identify the image category corresponding to one or more image blocks to obtain an image category set;
[0102] The image matching module 104 is used to match an image set corresponding to the image to be matched from a pre-built image database using the image category set.
[0103] The specific implementation steps of each module in the image matching device 100 provided in the embodiment of the present invention are as follows:
[0104] The target image extraction module 101 is used to obtain the image to be matched input by the user, perform denoising processing on the image to be matched to obtain a denoised image, and extract the target image from the denoised image.
[0105] In the embodiment of the present invention, the images input by the user or the images crawled from the network by using a crawler program are collectively referred to as the to-be-matched images.
[0106] In detail, since the received image to be matched may include more noise points, which will affect subsequent picture matching, the target image extraction module 101 is specifically used to include: using a pre-constructed Gaussian filter to filter the image to be matched to obtain a filtered image; constructing a convolution kernel, and using the convolution kernel to perform a convolution operation on the filtered image to obtain the denoised image.
[0107] Furthermore, the Gaussian filter described in the present invention is a linear smoothing filter constructed based on a Gaussian distribution function, and has a good denoising effect on noise points that are randomly distributed and obey a normal distribution.
[0108] In the embodiment of the present invention, the convolution kernel is composed of a convolution coefficient and a matrix block, wherein the size of the matrix block is 5*5, and the convolution kernel is specifically as follows:
[0109]
[0110] in It is called a convolution coefficient. In detail, the convolution kernel is constructed, and the convolution operation is performed on the filtered image using the convolution kernel to obtain the denoised image, including: selecting the upper left pixel of the filtered image as the kernel center, using the convolution kernel to perform weighted averaging on the kernel center to obtain a weighted average value, and replacing the original pixel value of the kernel center with the weighted average value until the kernel center moves from the upper left pixel of the filtered image to the lower right pixel of the filtered image, thereby obtaining the denoised image.
[0111] In detail, the method of using the convolution kernel to perform weighted averaging on the kernel center to obtain the weighted average value includes: using the kernel center to construct a pixel matrix of the same size as the convolution kernel, and performing weighted averaging on the convolution kernel and the pixel matrix to obtain the weighted average value.
[0112] If the kernel center is at the upper left pixel of the filtered image, operations such as padding with zeros or padding with 1s are used above and to the left of the kernel center, respectively, and a 5*5 pixel matrix is constructed in combination with the pixels to the right and below the kernel center. The pixel matrix and the convolution kernel have the same size, and the corresponding multiplication and addition are performed and then averaged to obtain the weighted average value, and then the weighted average value is used to replace the original pixels to obtain the denoised image.
[0113] Furthermore, in an embodiment of the present invention, extracting the target image from the denoised image includes: performing target contour extraction on the denoised image to obtain a target contour map; and performing a correction operation on the target contour map through a preset affine transformation algorithm to obtain the target image.
[0114] In detail, performing target contour extraction on the denoised image to obtain a target contour map includes: performing a grayscale operation on the denoised image to obtain a grayscale image; and using a pre-built contour extraction algorithm to extract the target contour from the grayscale image to obtain the target contour map.
[0115] In the embodiment of the present invention, the grayscale operation is performed using the following formula:
[0116] Gray=0.29R+0.58G+0.11B
[0117] Among them, Gray represents the grayscale image, R, G, and B represent the RGB values of the denoised image respectively, wherein R represents the red channel value, G represents the green channel value, and B represents the blue channel value.
[0118] In the embodiment of the present invention, the target contour is extracted from the grayscale image using an edge detection method to obtain the target contour map. Furthermore, since the target contour extracted by the above edge detection may be distorted, an affine transformation algorithm is required to perform correction on the target contour map. Specifically, the correction is performed using the following affine transformation formula:
[0119]
[0120] Among them, x, y are the pixel coordinates of the target contour map, x′, y′ are the corrected pixel coordinates, a, b, c, d represent the parameter values in the preset affine transformation matrix, and the above formula operation is executed to obtain the target image. For example, if the user inputs an image to be matched including a cat and a dog, after the above processing, a target image including a cat and a target image including a dog can be obtained respectively.
[0121] The target segmentation module 102 is used to perform image segmentation on the target image to obtain one or more image blocks.
[0122] As described above, when the user inputs the images to be matched including a cat and a dog, a target image including a cat and a target image including a dog can be obtained respectively. However, in order to expand the image richness of the target image, the present invention further performs image segmentation on the target image. For details, refer to Figure 3 As shown, the S3 includes:
[0123] Step A, extracting a target contour map of the target image;
[0124] Step B, determining whether the target contour is circular or elliptical;
[0125] Step C: if the target contour image is circular or elliptical, perform image segmentation on the target image using a fan-shaped segmentation method to obtain one or more image blocks;
[0126] Step D: If the target contour image is not a circle or an ellipse, use a rectangular splitting method to perform image splitting on the target image to obtain one or more image blocks.
[0127] In the embodiment of the present invention, the above-mentioned step has included performing target contour extraction on the image to be matched to obtain a target contour map, so the target contour map is stored in a database, and when the target segmentation module 102 needs the target contour map, it is extracted from the database.
[0128] Furthermore, the present invention constructs an OpenCV interface calling script, and utilizes the OpenCV interface calling script to call the HoughEllipse interface provided by OpenCV, so as to determine whether the target contour map is a circle or an ellipse.
[0129] If the target contour is a circle or an ellipse, the target image is segmented using a fan-shaped segmentation method, wherein the fan-shaped segmentation method is to set the target contour in the target image as a circle, and according to the principle that a circle can be split into several sectors, the target image is divided into two, three, four, etc., so as to obtain one or more image blocks similar to a sector shape.
[0130] If the target contour image is not a circle or an ellipse, the target image is segmented using a rectangular segmentation method, wherein the rectangular segmentation method is to set the target contour image in the target image as a rectangle, and according to the principle that a rectangle can be split into a number of square blocks, the target image is divided into two, three, four, etc., so as to obtain one or more image blocks similar to a square shape.
[0131] The image category recognition module 103 is used to receive an original image category recognition model, train the original image category recognition model to obtain a standard image category recognition model, and use the standard image category recognition model to identify image categories corresponding to one or more image blocks to obtain an image category set.
[0132] In detail, the training of the original image category recognition model to obtain the standard image category recognition model includes: obtaining an image training set; and performing K-fold cross-validation training on the original image category recognition model using the image training set to obtain the standard image category recognition model.
[0133] Furthermore, the image training set uses crawler technology to crawl various images from the Internet, including various animals and plants, handicrafts, and manufactured products. The original image category recognition model is a classification model based on a convolutional neural network, which can determine whether each image includes a tiger, flowers, plants, cars, etc.
[0134] In detail, the method of using the image training set to perform K-fold cross-validation training on the original image category recognition model to obtain the standard image category recognition model includes: dividing the image training set into K training subsets, using each of the K training subsets to train the original image category recognition model to obtain the image category recognition model to be verified, performing model evaluation on the image category recognition model to be verified to obtain an evaluation score, and when the evaluation score is less than a preset standard score, obtaining the standard image category recognition model.
[0135] The embodiment of the present invention uses the following two training methods to train the original image category recognition model to obtain the image category recognition model to be verified:
[0136] s=((w / (kb)+(b+ab) / (tw)) / 2
[0137] s=((w / (kb-ab)+(b+ab) / (kw)) / 2
[0138] Among them, s is the target contour ratio value of a specific image in the training subset, b is the number of image contour points of a specific image in the training subset, w is the number of blank area points of a specific image in the training subset, ab is the number of target contour points of a specific image in the training subset calculated by the compensation algorithm after the target contour is deformed, and t is the total number of pixels of a specific image in the training subset. When the target contour ratio value of each image in the training subset is less than the specified threshold, the image category recognition model to be verified is obtained.
[0139] In the embodiment of the present invention, the model evaluation is performed on the image category recognition model to be verified as follows to obtain an evaluation score. When the evaluation score is less than a preset standard score, the standard image category recognition model is obtained.
[0140] The embodiment of the present invention adopts a dual index weighting method to perform model evaluation on the image category recognition model to be verified to obtain an evaluation score:
[0141] F=0.3*FN / (TP+FN)*100%
[0142] In the formula, F represents the evaluation score, TP represents the number of image training sets predicted as correct categories by the image category recognition model to be verified, and FN represents the number of image training sets predicted as incorrect categories by the image category recognition model to be verified.
[0143] The smaller the value of the evaluation score F is, the better the model is. In the embodiment of the present invention, the preset standard score is set to 0.15.
[0144] The embodiment of the present invention uses the image category recognition model to detect the graphic blocks, such as detecting the graphic category of a torso graphic block as a tiger or a leopard, detecting the graphic category of a head graphic block as a cat or a leopard, and so on.
[0145] The image matching module 104 is used to match an image set corresponding to the image to be matched from a pre-built image database using the image category set.
[0146] In the embodiment of the present invention, the images in the image database are stored according to image categories, and each image stored in the image database has a category label, such as a cat category image, a dog category image, and the like.
[0147] If the images to be matched include cat and dog categories, all images including cat and dog categories are matched from the image database using the cat and dog categories.
[0148] like Figure 5 FIG. 1 is a schematic diagram of the structure of an electronic device for implementing the image matching method of the present invention.
[0149] The electronic device 1 may include a processor 10 , a memory 11 , and a bus, and may also include a computer program stored in the memory 11 and executable on the processor 10 , such as a picture matching program 12 .
[0150] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. The memory 11 may be an internal storage unit of the electronic device 1 in some embodiments, such as a mobile hard disk of the electronic device 1. The memory 11 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device 1. Further, the memory 11 may also include both an internal storage unit of the electronic device 1 and an external storage device. The memory 11 may not only be used to store application software and various types of data installed in the electronic device 1, such as the code of the picture matching program 12, etc., but also be used to temporarily store data that has been output or is to be output.
[0151] The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips, etc. The processor 10 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules stored in the memory 11 (for example, executing a picture matching program, etc.), and calls data stored in the memory 11, so as to execute various functions of the electronic device 1 and process data.
[0152] The bus may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.
[0153] Figure 5 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 5The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0154] For example, although not shown, the electronic device 1 may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, etc. The electronic device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0155] Furthermore, the electronic device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device 1 and other electronic devices.
[0156] Optionally, the electronic device 1 may further include a user interface, which may be a display, an input unit (such as a keyboard), or a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device 1 and to display a visual user interface.
[0157] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0158] The image matching program 12 stored in the memory 11 in the electronic device 1 is a combination of multiple instructions. When running in the processor 10, it can achieve:
[0159] Acquire an image to be matched input by a user, and perform denoising processing on the image to be matched to obtain a denoised image;
[0160] Extracting a target image from the denoised image;
[0161] Performing image segmentation on the target image to obtain one or more image blocks;
[0162] Receiving an original image category recognition model, training the original image category recognition model to obtain a standard image category recognition model, and using the standard image category recognition model to identify image categories corresponding to one or more image blocks to obtain an image category set;
[0163] By using the image category set, an image set corresponding to the image to be matched is matched from a pre-constructed image database.
[0164] Furthermore, if the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).
[0165] Furthermore, the computer-usable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0166] The present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program can implement:
[0167] Acquire an image to be matched input by a user, and perform denoising processing on the image to be matched to obtain a denoised image;
[0168] Extracting a target image from the denoised image;
[0169] Performing image segmentation on the target image to obtain one or more image blocks;
[0170] Receiving an original image category recognition model, training the original image category recognition model to obtain a standard image category recognition model, and using the standard image category recognition model to identify image categories corresponding to one or more image blocks to obtain an image category set;
[0171] By using the image category set, an image set corresponding to the image to be matched is matched from a pre-constructed image database.
[0172] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0173] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0174] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0175] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0176] Therefore, no matter from which point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any associated diagram mark in the claims should not be regarded as limiting the claims involved.
[0177] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0178] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The second and other words are used to indicate names, but not to indicate any particular order.
[0179] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A picture matching method, characterized in that: The method comprises: Acquire an image to be matched input by a user, and perform denoising processing on the image to be matched to obtain a denoised image; Extracting a target image from the denoised image; Extracting a target contour map of the target image, determining the shape of the target contour map, and if the target contour map is circular or elliptical, performing image segmentation on the target image using a fan-shaped segmentation method; if the target contour map is not circular or elliptical, performing image segmentation on the target image using a matrix segmentation method to obtain one or more image blocks; An original image category recognition model is received, an image training set is obtained, and K-fold cross validation training is performed on the original image category recognition model using the image training set to obtain an image category recognition model to be verified, wherein the formula for training the original image category recognition model to obtain the image category recognition model to be verified includes: s=(w / (kb)+(b+ab) / (tw)) / 2 Wherein, s is the target contour ratio value of a specific image in the training subset, b is the number of image contour points of a specific image in the training subset, w is the number of blank area points of a specific image in the training subset, ab is the number of target contour points of a specific image in the training subset calculated by the compensation algorithm after the target contour is deformed, and t is the total number of pixels of a specific image in the training subset. When the target contour ratio value of each image in the training subset is less than the specified threshold, the image category recognition model to be verified is obtained; A dual-index weighted method is used to perform model evaluation on the image category recognition model to be verified to obtain an evaluation score. When the evaluation score is less than a preset standard score, a standard image category recognition model is obtained. The standard image category recognition model is used to identify the image category corresponding to one or more image blocks to obtain an image category set. By using the image category set, an image set corresponding to the image to be matched is matched from a pre-constructed image database.
2. The image matching method according to claim 1, characterized in that: The performing denoising processing on the image to be matched to obtain a denoised image includes: Using a pre-constructed Gaussian filter, filtering the image to be matched to obtain a filtered image; A convolution kernel is constructed, and a convolution operation is performed on the filtered image using the convolution kernel to obtain the denoised image.
3. The image matching method according to claim 2, characterized in that: The step of performing a convolution operation on the filtered image using the convolution kernel to obtain the denoised image includes: Selecting the upper left pixel of the filtered image as the kernel center, and performing weighted averaging on the kernel center using the convolution kernel to obtain a weighted average value; The weighted average value is used to replace the original pixel value of the core center until the core center moves from the upper left pixel of the filtered image to the lower right pixel of the filtered image, thereby obtaining the denoised image.
4. The image matching method according to claim 3, characterized in that: The step of performing weighted averaging on the core center using the convolution kernel to obtain a weighted average value includes: Using the kernel center, construct a pixel matrix having the same size as the convolution kernel; Perform weighted averaging on the convolution kernel and the pixel matrix to obtain the weighted average value.
5. The image matching method according to any one of claims 1 to 4, characterized in that: The step of extracting a target image from the denoised image comprises: Performing target contour extraction on the denoised image to obtain a target contour map; The target image is obtained by performing a correction operation on the target contour image through a preset affine transformation algorithm.
6. A picture matching device, characterized in that: The device comprises: A target image extraction module is used to obtain a to-be-matched image input by a user, perform denoising on the to-be-matched image to obtain a denoised image, and extract a target image from the denoised image; A target segmentation module is used to extract a target contour map of the target image, determine the shape of the target contour map, and if the target contour map is circular or elliptical, perform image segmentation on the target image using a fan-shaped segmentation method; if the target contour map is not circular or elliptical, perform image segmentation on the target image using a matrix segmentation method to obtain one or more image blocks; The image category recognition module is used to receive the original image category recognition model, obtain the image training set, and use the image training set to perform K-fold cross-validation training on the original image category recognition model to obtain the image category recognition model to be verified, wherein the formula for training the original image category recognition model to obtain the image category recognition model to be verified includes: s=(w / (kb)+(b+ab) / (tw)) / 2 Wherein, s is the target contour ratio value of a specific image in the training subset, b is the number of image contour points of a specific image in the training subset, w is the number of blank area points of a specific image in the training subset, ab is the number of target contour points of a specific image in the training subset calculated by a compensation algorithm after the target contour is deformed, and t is the total number of pixels of a specific image in the training subset. When the target contour ratio value of each image in the training subset is less than a specified threshold, the image category recognition model to be verified is obtained; a dual index weighted method is used to perform model evaluation on the image category recognition model to be verified to obtain an evaluation score. When the evaluation score is less than a preset standard score, a standard image category recognition model is obtained. The standard image category recognition model is used to identify the image category corresponding to one or more image blocks to obtain an image category set; The image matching module is used to use the image category set to match an image set corresponding to the image to be matched from a pre-built image database.
7. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the image matching method according to any one of claims 1 to 5.
8. A computer-readable storage medium, comprising a data storage area and a program storage area, characterized in that: The data storage area stores created data, and the program storage area stores a computer program; wherein the computer program, when executed by a processor, implements the image matching method according to any one of claims 1 to 5.
