Similar area search method, device, electronic device and medium
By scaling the image and extracting feature data, combined with traversal search and offset comparison, the problem of low accuracy and efficiency in searching similar areas in the image is solved, and fast and accurate recognition and restoration of similar areas are achieved.
Patent Information
- Application Number
- CN202011478854.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-15
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2040-12-15
AI Technical Summary
The existing technology's accuracy and efficiency in searching similar areas in images are not high, mainly because the peripheral contours identified by grayscale processing are unclear and the recognition speed is slow.
By scaling the original image, use the trained feature data extraction model to extract feature data, determine the target area, traverse the search and offset comparison of the scaled image according to the target area, and calculate the similarity. If the similarity is greater than or equal to the predetermined If a threshold is set, it will be determined as a similar area and restored according to the preset scaling ratio.
The accuracy and efficiency of similar area search are improved, and target similar areas can be quickly identified and restored.
Smart Images

Figure CN112541902B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a similar area search method, device, electronic device and computer-readable storage medium. Background Art
[0002] Computer vision is an important direction in the field of artificial intelligence. Image search, especially the search for similar areas in images, is becoming increasingly popular.
[0003] In the prior art, a common method for searching similar regions in an image is to grayscale the target region (i.e., the region to be searched), identify the outer contour of the target region, and search for similar regions based on the contour. However, since the outer contour identified by grayscale processing is usually not very clear and the recognition speed is slow, it is impossible to accurately and efficiently search for all similar regions based on the outer contour. Therefore, the accuracy and efficiency of searching for similar regions in an image in the prior art are not high. Summary of the invention
[0004] The present invention provides a similar region search method, device, electronic device and computer-readable storage medium, the main purpose of which is to solve the problem that the accuracy and efficiency of similar region search in an image are not high.
[0005] To achieve the above object, the present invention provides a similar area search method, comprising:
[0006] Acquire an original image, and perform scaling processing on the original image to obtain a scaled image;
[0007] Using a trained feature data extraction model to extract the zoomed image to obtain a plurality of feature data, and determining a target area according to the plurality of feature data;
[0008] Perform traversal search and offset comparison on the zoomed image according to the target area to obtain a search area, and calculate the similarity between the target area and the search area;
[0009] If the similarity is greater than or equal to a preset similarity threshold, determining that the search area is a similar area;
[0010] The similar region is restored according to a preset scaling ratio to obtain a target similar region. Optionally, scaling the original image to obtain a scaled image includes:
[0011] Get the preset zoom ratio;
[0012] Get the position of the i-th pixel in the original image, where the initial value of i is 1 and i is a positive integer;
[0013] Multiplying the scaling ratio by the position to obtain a virtual pixel position of the i-th pixel;
[0014] Perform inference recognition according to the virtual pixel position to obtain a scaled pixel point set of the i-th pixel point;
[0015] Performing interpolation processing on the set of scaled pixel points using a bilinear interpolation algorithm to obtain a true scaled pixel position of the i-th pixel point;
[0016] Let i=i+1, and repeatedly obtain the position of the i-th pixel in the original image until i is equal to the total number of pixels in the original image, and obtain the true scaled pixel position of all pixels in the original image;
[0017] The scaled image is determined according to the actual scaled pixel position.
[0018] Optionally, before extracting and processing the zoomed image using the trained feature region extraction model to obtain a plurality of feature data, the method further includes:
[0019] Get a training sample set;
[0020] The training sample set is input into a convolutional neural network, and the multiple training channels contained in the convolutional neural network are trained using the training sample set until the multiple training channels meet preset convergence conditions, thereby obtaining the trained feature region extraction model.
[0021] Optionally, the step of inputting the training sample set into a convolutional neural network, using the training sample set to train a plurality of training channels included in the convolutional neural network until the plurality of training channels meet a preset convergence condition, and obtaining the trained feature region extraction model comprises:
[0022] Determine the parameters of each training channel, and independently train each training channel through the training sample set to obtain prediction feature data corresponding to each training channel;
[0023] Generating a predicted bounding box for each training channel according to the predicted feature data of each training channel;
[0024] The loss function of each training channel is calculated according to the predicted bounding box of each training channel. For the training channels whose loss functions have not reached the convergence conditions, the internal parameters are adjusted and the training is performed again independently until the loss functions of each training channel reach the convergence conditions, thereby obtaining the trained feature data extraction model.
[0025] Optionally, the independently training each training channel through the training sample set to obtain prediction feature data corresponding to each training channel includes:
[0026] Performing vector conversion on the training sample set to obtain a multi-dimensional vector;
[0027] Performing convolution and pooling processing on the multidimensional vector through the convolution layer and pooling layer of each training channel to obtain a feature image;
[0028] The feature image is predicted through the fully connected layer and the output layer of each training channel to obtain the predicted feature data corresponding to each training channel.
[0029] Optionally, performing traversal search and offset comparison on the zoomed image according to the target area to obtain a search area, and calculating the similarity between the target area and the search area includes:
[0030] Determine the size of the target area as a standard frame selection size;
[0031] According to the standard frame selection size, the target area is offset framed from left to right and from top to bottom on the zoomed image to obtain multiple search areas;
[0032] Acquire a first outer pixel point set of a first outer connected area of the target area and a first inner pixel point set of a first inner connected area of the target area;
[0033] Acquire a second outer pixel point set of a second outer connected area of the plurality of search areas and a second inner pixel point set of a second inner connected area of any one of the plurality of search areas;
[0034] Obtaining the number of common outer pixel points between the first outer pixel point set and the second outer pixel point set, and the number of common inner pixel points between the first inner pixel point set and the second inner pixel point set;
[0035] The similarity calculation is performed according to a similarity calculation formula and the number of identical outer pixels and the number of identical inner pixels to obtain the similarity between the target area and the multiple search areas.
[0036] Obtain the number of common pixel points between a pixel point set of a first peripheral connected area of the target area and a pixel point set of a second peripheral connected area of any one of the search areas, and the number of common points between a first internal connected area of the target area and an internal connected area of the search area;
[0037] The similarity between the target area and the search area is obtained by combining a preset similarity calculation formula, the number of identical points in the peripheral connected point set of the search area, and the number of identical points in the internal connected area of the search area.
[0038] Optionally, the restoring the similar region according to a preset scaling ratio to obtain a target similar region includes:
[0039] Mapping the similar area to a two-dimensional coordinate system to obtain the abscissa and ordinate of the similar area;
[0040] Dividing the abscissa and the ordinate by the scaling ratio to obtain a target abscissa and a target ordinate;
[0041] A search is performed in the original image according to the target horizontal coordinate and the target vertical coordinate to obtain a target similar area.
[0042] In order to solve the above problem, the present invention further provides a similar area search device, the device comprising:
[0043] An image scaling module is used to obtain an original image, and perform scaling processing on the original image to obtain a scaled image;
[0044] A target area determination module is used to extract and process the zoomed image using a trained feature data extraction model to obtain a plurality of feature data, and determine the target area according to the plurality of feature data;
[0045] A similarity calculation module is used to perform traversal search and offset comparison on the zoomed image according to the target area to obtain a search area, and calculate the similarity between the target area and the search area;
[0046] A similar region determination module, configured to determine that the search region is a similar region if the similarity is greater than or equal to a preset similarity threshold;
[0047] The restoration processing module is used to restore the similar area according to a preset scaling ratio to obtain a target similar area.
[0048] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0049] at least one processor; and,
[0050] a memory communicatively connected to the at least one processor; wherein,
[0051] The memory stores computer program instructions that can be executed by the at least one processor. The computer program instructions are executed by the at least one processor to enable the at least one processor to perform the similar area search method described above.
[0052] In order to solve the above problem, the present invention further provides a computer-readable storage medium storing a computer program, wherein the computer program implements the above similar area search method when executed by a processor.
[0053] The embodiment of the present invention first obtains a scaled image by scaling the acquired original image, scaling the original image to an image of a preset scale size to facilitate subsequent feature extraction and traversal search processing, thereby improving search efficiency, extracting and processing the scaled image using a trained feature data extraction model to obtain multiple feature data, determining a target area based on the multiple feature data to improve the accuracy of identifying the target area, performing traversal search and offset comparison on the scaled image based on the target area to obtain a search area, calculating the similarity between the target area and the search area, and if the similarity is greater than or equal to a preset similarity threshold, determining that the search area is a similar area, restoring the similar area according to a preset scaling ratio to obtain a target similar area. Therefore, the similar area search method, device, and computer-readable storage medium proposed in the present invention can solve the problem that the accuracy and efficiency of similar area search in an image are not high. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 A schematic diagram of a similar area search method according to an embodiment of the present invention;
[0055] Figure 2 A schematic diagram of a module of a similar area search device provided by an embodiment of the present invention;
[0056] Figure 3 A schematic diagram of the internal structure of an electronic device for implementing a similar area search method provided by an embodiment of the present invention.
[0057] 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
[0058] 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.
[0059] The embodiment of the present invention provides a similar area search method, and the execution subject of the similar area search 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 similar area search method 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.
[0060] Reference Figure 1 FIG. 1 is a flow chart of a similar area search method provided by an embodiment of the present invention. In this embodiment, the similar area search method includes:
[0061] S1. Acquire an original image, and perform scaling processing on the original image to obtain a scaled image.
[0062] In the embodiment of the present invention, the original image may be one or more images, and the original image may contain multiple identical or similar regions.
[0063] For example, the original image may be a workplace floor plan. Specifically, the workplace floor plan may include a plurality of office seats.
[0064] The original image may be obtained by downloading it from other third-party systems, for example, directly downloading a workplace plan from a workstation system.
[0065] Specifically, scaling the original image to obtain a scaled image includes:
[0066] Get the preset zoom ratio;
[0067] Get the position of the i-th pixel in the original image, where the initial value of i is 1 and i is a positive integer;
[0068] Multiplying the scaling ratio by the position to obtain a virtual pixel position of the i-th pixel;
[0069] Perform inference recognition according to the virtual pixel position to obtain a scaled pixel point set of the i-th pixel point;
[0070] Performing interpolation processing on the set of scaled pixel points using a bilinear interpolation algorithm to obtain a true scaled pixel position of the i-th pixel point;
[0071] Let i=i+1, and repeatedly obtain the position of the i-th pixel in the original image until i is equal to the total number of pixels in the original image, and obtain the true scaled pixel position of all pixels in the original image;
[0072] The scaled image is determined according to the actual scaled pixel position.
[0073] The preset scaling ratio is: , .
[0074] Due to the preset zoom ratio and is a floating point number, so the virtual pixel position is also a floating point number, so it is necessary to infer and identify the virtual pixel position to find a preset number of pixel positions near the virtual pixel position, that is, a scaled pixel point set.
[0075] Furthermore, reasoning and identifying based on the virtual pixel position includes: determining the virtual pixel position on a preset two-dimensional coordinate system, finding a preset number of scaled pixel points closest to the virtual pixel position, wherein the position of the scaled pixel point is an integer, thereby summarizing to obtain a scaled pixel point set.
[0076] S2. Using the trained feature data extraction model to extract the zoomed image to obtain a plurality of feature data, and determining the target area according to the plurality of feature data.
[0077] In the embodiment of the present invention, before extracting and processing the zoomed image using the trained feature region extraction model to obtain a plurality of feature data, the method further includes:
[0078] Get a training sample set;
[0079] The training sample set is input into a convolutional neural network, and the multiple training channels contained in the convolutional neural network are trained using the training sample set until the multiple training channels meet preset convergence conditions, thereby obtaining the trained feature region extraction model.
[0080] In the embodiment of the present invention, the trained feature region extraction model includes multiple training channels that meet the convergence condition.
[0081] In detail, the training sample set is composed of a plurality of pictures (such as workplace floor plans) with target areas marked, and the target area can be any position in the picture, for example, the target area is a workstation area in the workplace floor plan.
[0082] The convolutional neural network (CNN) is a type of feedforward neural network that includes convolution calculations and has a deep structure. In an embodiment of the present invention, the convolutional neural network includes multiple training channels, each of which includes an input layer, a convolution layer, a pooling layer, a fully connected layer, and an output layer. The convolution layer includes a convolution kernel, which can be a matrix for convolving the input image. The specific calculation method is to multiply the elements of different local matrices of the input image and the convolution kernel matrix at each position, and then add them.
[0083] Preferably, in an embodiment of the present invention, each training channel corresponds to a different convolution kernel, and a convolutional neural network may include multiple convolution layers.
[0084] Specifically, the training sample set is input into a convolutional neural network, and a plurality of training channels included in the convolutional neural network are trained using the training sample set until the plurality of training channels meet a preset convergence condition, thereby obtaining the trained feature region extraction model, including:
[0085] Determine the parameters of each training channel, and independently train each training channel through the training sample set to obtain prediction feature data corresponding to each training channel;
[0086] Generating a predicted bounding box for each training channel according to the predicted feature data of each training channel;
[0087] The loss function of each training channel is calculated according to the predicted bounding box of each training channel. For the training channels whose loss functions have not reached the convergence conditions, the internal parameters are adjusted and the training is performed again independently until the loss functions of each training channel reach the convergence conditions, thereby obtaining the trained feature data extraction model.
[0088] In detail, the parameters of each training channel include the parameters corresponding to the convolution kernel of the convolution layer, for example, the size of the convolution matrix. In specific implementation, the convolution matrix can be set to 3*3, and different convolution kernels can be set for different convolution layers. In addition, the parameters of each training channel can also include the parameters of the pooling layer, for example, the size of the pooling matrix, the size of the pooling matrix can be set to 3*3, or the parameters of each training channel can also include the parameters of the output layer, such as the linear coefficient matrix and the offset vector, etc. The parameters corresponding to each training channel can be different.
[0089] Specifically, the step of independently training each training channel through the training sample set to obtain prediction feature data corresponding to each training channel includes:
[0090] Performing vector conversion on the training sample set to obtain a multi-dimensional vector;
[0091] Performing convolution and pooling processing on the multidimensional vector through the convolution layer and pooling layer of each training channel to obtain a feature image;
[0092] The feature image is predicted through the fully connected layer and the output layer of each training channel to obtain the predicted feature data corresponding to each training channel.
[0093] In detail, the predicted feature data includes but is not limited to the probability that a pixel point is located within the target area, the rotation angle of the target area, and the distance from the pixel point located within the target area to each side of the positive sample border. Based on the above predicted feature data, multiple borders that may contain the target area, namely predicted borders, can be obtained.
[0094] Specifically, determining the target area according to the plurality of feature data includes:
[0095] For each pixel point in the target area, generating a plurality of feature points on a preset rotation border according to the predicted rotation angle in the feature data;
[0096] Linear fitting is performed on the feature points on each rotating frame to generate multiple straight lines, which are then intersected to form a closed target area.
[0097] When the rotating border is a polygon, the multiple feature points on the rotating border may be vertices of the polygon.
[0098] S3. Perform traversal search and offset comparison on the zoomed image according to the target area to obtain a search area, and calculate the similarity between the target area and the search area.
[0099] In the embodiment of the present invention, the step of performing traversal search and offset comparison on the zoomed image according to the target area to obtain a search area, and calculating the similarity between the target area and the search area includes:
[0100] Determine the size of the target area as a standard frame selection size;
[0101] According to the standard frame selection size, the target area is offset framed from left to right and from top to bottom on the zoomed image to obtain multiple search areas;
[0102] Acquire a first outer pixel point set of a first outer connected area of the target area and a first inner pixel point set of a first inner connected area of the target area;
[0103] Acquire a second outer pixel point set of a second outer connected area of the plurality of search areas and a second inner pixel point set of a second inner connected area of any one of the plurality of search areas;
[0104] Obtaining the number of common outer pixel points between the first outer pixel point set and the second outer pixel point set, and the number of common inner pixel points between the first inner pixel point set and the second inner pixel point set;
[0105] The similarity calculation is performed according to a similarity calculation formula and the number of identical outer pixels and the number of identical inner pixels to obtain the similarity between the target area and the multiple search areas.
[0106] Furthermore, the first outer pixel point set refers to a set of pixel points on the area contour line of the first outer connected area of the target area, the first inner pixel point set refers to the complete internal connected area of the first outer connected area of the target area, the second outer pixel point set refers to a set of pixel points on the area contour line of the second outer connected area of the search area, and the second inner pixel point set refers to the complete internal connected area of the second internal connected area of the search area.
[0107] In detail, the similarity formula is:
[0108]
[0109] Among them, s is the similarity, w is the number of the same inner pixel points between the first inner pixel point set and the second inner pixel point set, b is the number of the same outer pixel points between the first outer pixel point set and the second outer pixel point set, and k is the point set of the search area and the target area.
[0110] Specifically, if the similarity is greater than or equal to a preset similarity threshold, the search area is determined to be a similar area; if the similarity is less than the preset similarity threshold, the search area is determined to be a non-similar area, and then the similarity between the target area and the next search area is calculated and judged based on the similarity.
[0111] Preferably, in the embodiment of the present invention, the similarity threshold is 0.8.
[0112] In an embodiment of the present invention, the same area in the image is searched based on the local details of the target area. Specifically, the search is performed using the features of the outer contour and the internal area of the target area. Therefore, when performing the feature search for the target area, the requirements for the type and shape of the target are not high. Therefore, it can be used in graphic searches of various graphics and various scenes, and is highly practical.
[0113] S4. If the similarity is greater than or equal to a preset similarity threshold, determine that the search area is a similar area.
[0114] In the embodiment of the present invention, if multiple search areas are obtained, the pixels of the target area are calculated with the pixels of the multiple search areas, so that the search area with the highest similarity is obtained as the similar area.
[0115] S5. Restoring the similar area according to a preset scaling ratio to obtain a target similar area.
[0116] Specifically, the restoring the similar area according to the scaling ratio to obtain the target similar area includes:
[0117] Mapping the similar area to a two-dimensional coordinate system to obtain the abscissa and ordinate of the similar area;
[0118] Dividing the abscissa and the ordinate by the scaling ratio to obtain a target abscissa and a target ordinate;
[0119] A search is performed in the original image according to the target horizontal coordinate and the target vertical coordinate to obtain a target similar area.
[0120] In detail, after the image is scaled, the recognition speed is increased rapidly, and after the target area is recognized, it is restored according to the scaling ratio to obtain a target similar area.
[0121] The embodiment of the present invention first obtains a scaled image by scaling the acquired original image, scaling the original image to an image of a preset scale size to facilitate subsequent feature extraction and traversal search processing, thereby improving search efficiency, extracting and processing the scaled image using a trained feature data extraction model to obtain multiple feature data, determining a target area based on the multiple feature data to improve the accuracy of identifying the target area, performing traversal search and offset comparison on the scaled image based on the target area to obtain a search area, calculating the similarity between the target area and the search area, and if the similarity is greater than or equal to a preset similarity threshold, determining that the search area is a similar area, restoring the similar area according to a preset scaling ratio to obtain a target similar area. Therefore, the similar area search method proposed in the present invention can solve the problem that the accuracy and efficiency of similar area search in an image are not high.
[0122] like Figure 2 FIG. 1 is a schematic diagram of a module of a similar area search device provided in an embodiment of the present invention.
[0123] The similar area search device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the similar area search device 100 can include an image scaling module 101, a target area determination module 102, a similarity calculation module 103, a similar area determination module 104 and a restoration processing module 105. The module of the present invention can also be called a unit, which refers to a series of computer program segments that can be executed by a processor of an electronic device and can complete fixed functions, which are stored in the memory of the electronic device.
[0124] In this embodiment, the functions of each module / unit are as follows:
[0125] The image scaling module 101 is used to obtain an original image, and perform scaling processing on the original image to obtain a scaled image;
[0126] The target region determination module 102 is used to extract and process the zoomed image using a trained feature data extraction model to obtain a plurality of feature data, and determine the target region according to the plurality of feature data;
[0127] The similarity calculation module 103 is used to perform traversal search and offset comparison on the zoomed image according to the target area to obtain a search area, and calculate the similarity between the target area and the search area;
[0128] The similar region determination module 104 is used to determine that the search region is a similar region if the similarity is greater than or equal to a preset similarity threshold;
[0129] The restoration processing module 105 is used to restore the similar area according to a preset scaling ratio to obtain a target similar area.
[0130] In detail, when each module in the similar area search device 100 is executed by a processor of an electronic device, a similar area search method including the following steps can be implemented:
[0131] The image scaling module 101 is used to obtain an original image, and perform scaling processing on the original image to obtain a scaled image.
[0132] In the embodiment of the present invention, the original image may be one or more images, and the original image may contain multiple identical or similar regions.
[0133] For example, the original image may be a workplace floor plan. Specifically, the workplace floor plan may include a plurality of office seats.
[0134] The original image may be obtained by downloading it from other third-party systems, for example, directly downloading a workplace plan from a workstation system.
[0135] Specifically, scaling the original image to obtain a scaled image includes:
[0136] Get the preset zoom ratio;
[0137] Get the position of the i-th pixel in the original image, where the initial value of i is 1 and i is a positive integer;
[0138] Multiplying the scaling ratio by the position to obtain a virtual pixel position of the i-th pixel;
[0139] Perform inference recognition according to the virtual pixel position to obtain a scaled pixel point set of the i-th pixel point;
[0140] Performing interpolation processing on the set of scaled pixel points using a bilinear interpolation algorithm to obtain a true scaled pixel position of the i-th pixel point;
[0141] Let i=i+1, and repeatedly obtain the position of the i-th pixel in the original image until i is equal to the total number of pixels in the original image, and obtain the true scaled pixel position of all pixels in the original image;
[0142] The scaled image is determined according to the actual scaled pixel position.
[0143] The preset scaling ratio is: , .
[0144] Due to the preset zoom ratio and is a floating point number, so the virtual pixel position is also a floating point number, so it is necessary to infer and identify the virtual pixel position to find a preset number of pixel positions near the virtual pixel position, that is, a scaled pixel point set.
[0145] Furthermore, reasoning and identifying based on the virtual pixel position includes: determining the virtual pixel position on a preset two-dimensional coordinate system, finding a preset number of scaled pixel points closest to the virtual pixel position, wherein the position of the scaled pixel point is an integer, thereby summarizing to obtain a scaled pixel point set.
[0146] The target region determination module 102 is used to extract and process the zoomed image using a trained feature data extraction model to obtain a plurality of feature data, and determine the target region according to the plurality of feature data.
[0147] In the embodiment of the present invention, the device further includes a training module, and the training module is used to:
[0148] Before extracting and processing the zoomed image using the trained feature region extraction model to obtain a plurality of feature data, a training sample set is obtained;
[0149] The training sample set is input into a convolutional neural network, and the multiple training channels contained in the convolutional neural network are trained using the training sample set until the multiple training channels meet preset convergence conditions, thereby obtaining the trained feature region extraction model.
[0150] In the embodiment of the present invention, the trained feature region extraction model includes multiple training channels that meet the convergence condition.
[0151] In detail, the training sample set is composed of a plurality of pictures (such as workplace floor plans) with target areas marked, and the target area can be any position in the picture, for example, the target area is a workstation area in the workplace floor plan.
[0152] The convolutional neural network (CNN) is a type of feedforward neural network that includes convolution calculations and has a deep structure. In an embodiment of the present invention, the convolutional neural network includes multiple training channels, each of which includes an input layer, a convolution layer, a pooling layer, a fully connected layer, and an output layer. The convolution layer includes a convolution kernel, which can be a matrix for convolving the input image. The specific calculation method is to multiply the elements of different local matrices of the input image and the convolution kernel matrix at each position, and then add them.
[0153] Preferably, in an embodiment of the present invention, each training channel corresponds to a different convolution kernel, and a convolutional neural network may include multiple convolution layers.
[0154] Specifically, the training sample set is input into a convolutional neural network, and a plurality of training channels included in the convolutional neural network are trained using the training sample set until the plurality of training channels meet a preset convergence condition, thereby obtaining the trained feature region extraction model, including:
[0155] Determine the parameters of each training channel, and independently train each training channel through the training sample set to obtain prediction feature data corresponding to each training channel;
[0156] Generating a predicted bounding box for each training channel according to the predicted feature data of each training channel;
[0157] The loss function of each training channel is calculated according to the predicted bounding box of each training channel. For the training channels whose loss functions have not reached the convergence conditions, the internal parameters are adjusted and the training is performed again independently until the loss functions of each training channel reach the convergence conditions, thereby obtaining the trained feature data extraction model.
[0158] In detail, the parameters of each training channel include the parameters corresponding to the convolution kernel of the convolution layer, for example, the size of the convolution matrix. In specific implementation, the convolution matrix can be set to 3*3, and different convolution kernels can be set for different convolution layers. In addition, the parameters of each training channel can also include the parameters of the pooling layer, for example, the size of the pooling matrix, the size of the pooling matrix can be set to 3*3, or the parameters of each training channel can also include the parameters of the output layer, such as the linear coefficient matrix and the offset vector, etc. The parameters corresponding to each training channel can be different.
[0159] Specifically, the step of independently training each training channel through the training sample set to obtain prediction feature data corresponding to each training channel includes:
[0160] Performing vector conversion on the training sample set to obtain a multi-dimensional vector;
[0161] Performing convolution and pooling processing on the multidimensional vector through the convolution layer and pooling layer of each training channel to obtain a feature image;
[0162] The feature image is predicted through the fully connected layer and the output layer of each training channel to obtain the predicted feature data corresponding to each training channel.
[0163] In detail, the predicted feature data includes but is not limited to the probability that a pixel point is located within the target area, the rotation angle of the target area, and the distance from the pixel point located within the target area to each side of the positive sample border. Based on the above predicted feature data, multiple borders that may contain the target area, namely predicted borders, can be obtained.
[0164] Specifically, determining the target area according to the plurality of feature data includes:
[0165] For each pixel point in the target area, generating a plurality of feature points on a preset rotation border according to the predicted rotation angle in the feature data;
[0166] Linear fitting is performed on the feature points on each rotating frame to generate multiple straight lines, which are then intersected to form a closed target area.
[0167] When the rotating border is a polygon, the multiple feature points on the rotating border may be vertices of the polygon.
[0168] The similarity calculation module 103 is used to perform traversal search and offset comparison on the zoomed image according to the target area to obtain a search area, and calculate the similarity between the target area and the search area.
[0169] In the embodiment of the present invention, the similarity calculation module 103 is specifically used for:
[0170] Determine the size of the target area as a standard frame selection size;
[0171] According to the standard frame selection size, the target area is offset framed from left to right and from top to bottom on the zoomed image to obtain multiple search areas;
[0172] Acquire a first outer pixel point set of a first outer connected area of the target area and a first inner pixel point set of a first inner connected area of the target area;
[0173] Acquire a second outer pixel point set of a second outer connected area of the plurality of search areas and a second inner pixel point set of a second inner connected area of any one of the plurality of search areas;
[0174] Obtaining the number of common outer pixel points between the first outer pixel point set and the second outer pixel point set, and the number of common inner pixel points between the first inner pixel point set and the second inner pixel point set;
[0175] The similarity calculation is performed according to a similarity calculation formula and the number of identical outer pixels and the number of identical inner pixels to obtain the similarity between the target area and the multiple search areas.
[0176] Furthermore, the first outer pixel point set refers to a set of pixel points on the area contour line of the first outer connected area of the target area, the first inner pixel point set refers to the complete internal connected area of the first outer connected area of the target area, the second outer pixel point set refers to a set of pixel points on the area contour line of the second outer connected area of the search area, and the second inner pixel point set refers to the complete internal connected area of the second internal connected area of the search area.
[0177] In detail, the similarity formula is:
[0178]
[0179] Among them, s is the similarity, w is the number of the same inner pixel points between the first inner pixel point set and the second inner pixel point set, b is the number of the same outer pixel points between the first outer pixel point set and the second outer pixel point set, and k is the point set of the search area and the target area.
[0180] Specifically, if the similarity is greater than or equal to a preset similarity threshold, the search area is determined to be a similar area; if the similarity is less than the preset similarity threshold, the search area is determined to be a non-similar area, and then the similarity between the target area and the next search area is calculated and judged based on the similarity.
[0181] Preferably, in the embodiment of the present invention, the similarity threshold is 0.8.
[0182] In an embodiment of the present invention, the same area in the image is searched based on the local details of the target area. Specifically, the search is performed using the features of the outer contour and the internal area of the target area. Therefore, when performing the feature search for the target area, the requirements for the type and shape of the target are not high. Therefore, it can be used in graphic searches of various graphics and various scenes, and is highly practical.
[0183] The similar region determination module 104 is configured to determine that the search region is a similar region if the similarity is greater than or equal to a preset similarity threshold.
[0184] In the embodiment of the present invention, if multiple search areas are obtained, the pixels of the target area are calculated with the pixels of the multiple search areas, so that the search area with the highest similarity is obtained as the similar area.
[0185] The restoration processing module 105 is used to restore the similar area according to a preset scaling ratio to obtain a target similar area.
[0186] Specifically, the restoring the similar area according to the scaling ratio to obtain the target similar area includes:
[0187] Mapping the similar area to a two-dimensional coordinate system to obtain the abscissa and ordinate of the similar area;
[0188] Dividing the abscissa and the ordinate by the scaling ratio to obtain a target abscissa and a target ordinate;
[0189] A search is performed in the original image according to the target horizontal coordinate and the target vertical coordinate to obtain a target similar area.
[0190] In detail, after the image is scaled, the recognition speed is increased rapidly, and after the target area is recognized, it is restored according to the scaling ratio to obtain a target similar area.
[0191] The embodiment of the present invention first obtains a scaled image by scaling the acquired original image, scales the original image to an image of a preset scale size to facilitate subsequent feature extraction and traversal search processing, improves search efficiency, uses a trained feature data extraction model to extract and process the scaled image to obtain multiple feature data, determines a target area based on the multiple feature data, improves the accuracy of identifying the target area, performs traversal search and offset comparison on the scaled image based on the target area to obtain a search area, calculates the similarity between the target area and the search area, and if the similarity is greater than or equal to a preset similarity threshold, determines that the search area is a similar area, restores the similar area according to a preset scaling ratio, and obtains a target similar area. Therefore, the similar area search device proposed by the present invention can solve the problem that the accuracy and efficiency of similar area search in an image are not high.
[0192] like Figure 3 FIG. 1 is a schematic diagram of the structure of an electronic device for implementing the similar area search method of the present invention.
[0193] 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 similar area search program 12 .
[0194] 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. In some embodiments, the memory 11 may be an internal storage unit of the electronic device 1, such as a mobile hard disk of the electronic device 1. In other embodiments, the memory 11 may also be an external storage device of the electronic device 1, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, 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 similar area search program 12, etc., but may also be used to temporarily store data that has been output or is to be output.
[0195] 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 various functions and processes data of the electronic device 1 by running or executing programs or modules stored in the memory 11 (for example, executing similar area search programs, etc.), and calling data stored in the memory 11.
[0196] 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.
[0197] Figure 3 Only an electronic device with components is shown, and those skilled in the art will understand that Figure 3 The 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.
[0198] For example, although not shown, the electronic device 1 may also include a power source (such as a battery) for supplying power to various components. 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 one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0199] 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.
[0200] 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.
[0201] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0202] The similar area search program 12 stored in the memory 11 of the electronic device 1 is a combination of multiple instructions. When running in the processor 10, it can achieve:
[0203] Acquire an original image, and perform scaling processing on the original image to obtain a scaled image;
[0204] Using a trained feature data extraction model to extract the zoomed image to obtain a plurality of feature data, and determining a target area according to the plurality of feature data;
[0205] Perform traversal search and offset comparison on the zoomed image according to the target area to obtain a search area, and calculate the similarity between the target area and the search area;
[0206] If the similarity is greater than or equal to a preset similarity threshold, determining that the search area is a similar area;
[0207] The similar area is restored according to a preset scaling ratio to obtain a target similar area.
[0208] 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 storage medium can be volatile or non-volatile. For example, the computer-readable medium can 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).
[0209] The present invention also 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:
[0210] Acquire an original image, and perform scaling processing on the original image to obtain a scaled image;
[0211] Using a trained feature data extraction model to extract the zoomed image to obtain a plurality of feature data, and determining a target area according to the plurality of feature data;
[0212] Perform traversal search and offset comparison on the zoomed image according to the target area to obtain a search area, and calculate the similarity between the target area and the search area;
[0213] If the similarity is greater than or equal to a preset similarity threshold, determining that the search area is a similar area;
[0214] The similar area is restored according to a preset scaling ratio to obtain a target similar area.
[0215] 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.
[0216] 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.
[0217] 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.
[0218] 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.
[0219] 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.
[0220] 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.
[0221] 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.
[0222] 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 similar area search method, characterized in that: The method comprises: Acquire a training sample set, determine the parameters of each training channel, independently train each training channel through the training sample set to obtain predicted feature data corresponding to each training channel, generate a predicted bounding box for each training channel according to the predicted feature data of each training channel, calculate the loss function of each training channel according to the predicted bounding box of each training channel, adjust the internal parameters of the training channels whose loss functions do not meet the convergence conditions and re-train independently until the loss functions of each training channel meet the convergence conditions, thereby obtaining a trained feature data extraction model; acquire an original image, and scale the original image to obtain a scaled image; Using the multiple training channels of the trained feature data extraction model to extract the zoomed image, obtain multiple feature data, and determine the target area according to the multiple feature data; Perform traversal search and offset comparison on the zoomed image according to the target area to obtain a search area, and calculate the similarity between the target area and the search area; If the similarity is greater than or equal to a preset similarity threshold, determining that the search area is a similar area; The similar area is restored according to a preset scaling ratio to obtain a target similar area.
2. The similar area search method according to claim 1, characterized in that: The scaling process of the original image to obtain the scaled image includes: Get the preset zoom ratio; Get the position of the i-th pixel in the original image, where the initial value of i is 1 and i is a positive integer; Multiplying the scaling ratio by the position to obtain a virtual pixel position of the i-th pixel; Perform inference recognition according to the virtual pixel position to obtain a scaled pixel point set of the i-th pixel point; Performing interpolation processing on the set of scaled pixel points using a bilinear interpolation algorithm to obtain a true scaled pixel position of the i-th pixel point; Let i=i+1, and repeatedly obtain the position of the i-th pixel in the original image until i is equal to the total number of pixels in the original image, and obtain the true scaled pixel position of all pixels in the original image; The scaled image is determined according to the actual scaled pixel position.
3. The similar area search method according to claim 1, characterized in that: The step of independently training each training channel through the training sample set to obtain prediction feature data corresponding to each training channel includes: Performing vector conversion on the training sample set to obtain a multi-dimensional vector; Performing convolution and pooling processing on the multidimensional vector through the convolution layer and pooling layer of each training channel to obtain a feature image; The feature image is predicted through the fully connected layer and the output layer of each training channel to obtain the predicted feature data corresponding to each training channel.
4. The similar area search method according to any one of claims 1 to 3, characterized in that: The step of performing traversal search and offset comparison on the zoomed image according to the target area to obtain a search area, and calculating the similarity between the target area and the search area includes: Determine the size of the target area as a standard frame selection size; According to the standard frame selection size, the target area is offset framed from left to right and from top to bottom on the zoomed image to obtain multiple search areas; Acquire a first outer pixel point set of a first outer connected area of the target area and a first inner pixel point set of a first inner connected area of the target area; Acquire a second outer pixel point set of a second outer connected area of the plurality of search areas and a second inner pixel point set of a second inner connected area of any one of the plurality of search areas; Obtaining the number of common outer pixel points between the first outer pixel point set and the second outer pixel point set, and the number of common inner pixel points between the first inner pixel point set and the second inner pixel point set; The similarity calculation is performed according to a similarity calculation formula and the number of identical outer pixels and the number of identical inner pixels to obtain the similarity between the target area and the multiple search areas.
5. The similar area search method according to any one of claims 1 to 3, characterized in that: The restoring process of the similar region according to a preset scaling ratio to obtain a target similar region includes: Mapping the similar area to a two-dimensional coordinate system to obtain the abscissa and ordinate of the similar area; Dividing the abscissa and the ordinate by the scaling ratio to obtain a target abscissa and a target ordinate; A search is performed in the original image according to the target horizontal coordinate and the target vertical coordinate to obtain a target similar area.
6. A similar area search device, characterized in that: The device comprises: An image scaling module is used to obtain a training sample set, determine the parameters of each training channel, independently train each training channel through the training sample set, obtain predicted feature data corresponding to each training channel, generate a predicted border of each training channel according to the predicted feature data of each training channel, calculate the loss function of each training channel according to the predicted border of each training channel, adjust the internal parameters of the training channel whose loss function does not meet the convergence condition and re-train independently until the loss function of each training channel meets the convergence condition, and obtain a trained feature data extraction model; obtain an original image, and scale the original image to obtain a scaled image; A target region determination module, configured to extract and process the zoomed image using a plurality of training channels of the trained feature data extraction model to obtain a plurality of feature data, and determine the target region according to the plurality of feature data; A similarity calculation module is used to perform traversal search and offset comparison on the zoomed image according to the target area to obtain a search area, and calculate the similarity between the target area and the search area; A similar region determination module, configured to determine that the search region is a similar region if the similarity is greater than or equal to a preset similarity threshold; The restoration processing module is used to restore the similar area according to a preset scaling ratio to obtain a target similar area.
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 computer program instructions that can be executed by the at least one processor, and the computer program instructions are executed by the at least one processor to enable the at least one processor to perform the similar area search method according to any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the similar area search method according to any one of claims 1 to 5 is implemented.
