Image processing method, device and electronic equipment

By obtaining the global and local feature maps of the image and combining them for comparison, the problem of insufficient image similarity detection accuracy in the existing technology is solved, and a more comprehensive similarity detection is achieved.

CN112329889BActive Publication Date: 2024-10-18GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011356038.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-26
Publication Date
2024-10-18
Estimated Expiration
2040-11-26

AI Technical Summary

Technical Problem

The existing technology has the problem of insufficient accuracy when acquiring similar images.

Method used

By obtaining the global features and local feature maps of the image, similarity detection is performed based on these features, and the global and local features are combined for comparison to improve the accuracy of similarity detection.

Benefits of technology

A more comprehensive image similarity detection is achieved and the accuracy of similarity detection is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112329889B_ABST
    Figure CN112329889B_ABST
Patent Text Reader

Abstract

This application discloses an image processing method, apparatus, and electronic device. The method includes: acquiring a first image and a second image; acquiring a first global feature and a first local feature map, wherein the first global feature is a global feature corresponding to the first image, and the first local feature map includes local features corresponding to the first image; acquiring a second global feature and a second local feature map, wherein the second global feature is a global feature corresponding to the second image, and the second local feature map includes local features corresponding to the second image; and determining whether the first image and the second image are similar based on the first global feature, the first local feature map, the second global feature, and the second local feature map. This method simultaneously combines the global and local features of the first and second images for similarity detection, enabling more comprehensive detection during image similarity detection and improving the accuracy of similarity detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to an image processing method, device and electronic device. Background Art

[0002] Usually, images can have their own features, and similar images can be obtained by comparing the features of the images. However, in the process of obtaining similar images, there is still a problem that similar images cannot be obtained more accurately. Summary of the invention

[0003] In view of the above problems, the present application proposes an image processing method, device and electronic device to improve the above problems.

[0004] In a first aspect, the present application provides an image processing method, the method comprising: acquiring a first image and a second image; acquiring a first global feature and a first local feature map, the first global feature being a global feature corresponding to the first image, and the first local feature map comprising local features corresponding to the first image; acquiring a second global feature and a second local feature map, the second global feature being a global feature corresponding to the second image, and the second local feature map comprising local features corresponding to the second image; determining whether the first image is similar to the second image based on the first global feature, the first local feature map, the second global feature, and the second local feature map.

[0005] In a second aspect, the present application provides an image processing method, the method comprising: obtaining a first image and a first image set; obtaining a first global feature and a first local feature map, the first global feature being a global feature corresponding to the first image, and the first local feature map comprising local features corresponding to the first image; obtaining a global feature and a local feature map corresponding to each image in the first image set; determining a second image set from the first image set based on the first global feature and the global feature corresponding to each image in the first image set; determining an image in the second image set that is similar to the first image based on the first local feature map and the local feature map of each image in the second image set.

[0006] In a third aspect, the present application provides an image processing device, comprising: an image acquisition unit, used to acquire a first image and a second image; a feature acquisition unit, used to acquire a first global feature and a first local feature map, wherein the first global feature is a global feature corresponding to the first image, and the first local feature map includes a local feature corresponding to the first image; the feature acquisition unit is also used to acquire a second global feature and a second local feature map, wherein the second global feature is a global feature corresponding to the second image, and the second local feature map includes a local feature corresponding to the second image; an image comparison unit, used to determine whether the first image is similar to the second image based on the first global feature, the first local feature map, the second global feature, and the second local feature map.

[0007] In a fourth aspect, the present application provides an image processing device, comprising: an image acquisition unit, configured to acquire a first image and a first image set; a feature acquisition unit, configured to acquire a first global feature and a first local feature map, wherein the first global feature is a global feature corresponding to the first image, and the first local feature map includes local features corresponding to the first image; the feature acquisition unit is further configured to acquire the global feature and the local feature map corresponding to each image in the first image set; a first image determination unit, configured to determine a second image set from the first image set based on the first global feature and the global feature corresponding to each image in the first image set; and a second image determination unit, configured to determine an image in the second image set that is similar to the first image based on the first local feature map and the local feature map of each image in the second image set.

[0008] In a fifth aspect, the present application provides an electronic device comprising a processor and a memory; one or more programs are stored in the memory and configured to be executed by the processor to implement the above method.

[0009] In a sixth aspect, the present application provides a computer-readable storage medium, in which a program code is stored, wherein the above method is executed when the program code is started and executed by a controller.

[0010] The present application provides an image processing method, device and electronic device, which further acquires the first global feature and the first local feature map, and acquires the second global feature and the second local feature map after acquiring the first image and the second image, and then determines whether the first image and the second image are similar based on the first global feature, the first local feature map, the second global feature and the second local feature map. Therefore, in the process of judging the similarity between the first image and the second image, the global features and the local features of the first image and the second image can be combined to perform similarity detection at the same time, so that a more comprehensive detection can be performed in the process of image similarity detection, thereby improving the accuracy of similarity detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0012] Figure 1 A schematic diagram showing an application scenario of an image processing method proposed in an embodiment of the present application;

[0013] Figure 2 A flowchart of an image processing method proposed in an embodiment of the present application is shown;

[0014] Figure 3 Shows Figure 2 An implementation of S120 includes a flowchart;

[0015] Figure 4 A schematic diagram of obtaining global features in an embodiment of the present application is shown;

[0016] Figure 5 A schematic diagram showing a feature set corresponding to a position in a first initial feature map in an embodiment of the present application is shown;

[0017] Figure 6 A schematic diagram showing a local feature obtained in an embodiment of the present application is shown;

[0018] Figure 7 Shows Figure 2 An implementation of S130 includes a flowchart;

[0019] Figure 8 A flowchart of an image processing method proposed in another embodiment of the present application is shown;

[0020] Fig. 9A flowchart of determining whether a first image is similar to a second image based on a first global feature, a first local feature map, a second global feature, and a second local feature map in an embodiment of the present application is shown;

[0021] Fig.10 A schematic diagram showing the position correspondence in an embodiment of the present application is shown;

[0022] Fig.11 A flowchart of an image processing method proposed in another embodiment of the present application is shown;

[0023] Fig.12 A structural block diagram of a data processing device proposed in an embodiment of the present application is shown;

[0024] Fig.13 A structural block diagram of a data processing device proposed in another embodiment of the present application is shown;

[0025] Fig.14 A structural block diagram of a data processing device proposed in another embodiment of the present application is shown;

[0026] Fig.15 A structural block diagram of an electronic device for executing an image processing method according to an embodiment of the present application is shown;

[0027] Fig.16 It is a storage unit of an embodiment of the present application for storing or carrying a program code for implementing the image processing method according to an embodiment of the present application. DETAILED DESCRIPTION

[0028] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0029] As the number of images increases, there are more applications related to images. For example, features included in the images can be compared to determine whether two images are similar, or an image can be used as a reference to filter out images similar to the reference image from an image collection.

[0030] However, the inventors have found in their research that in the process of obtaining similar images, there is still a problem that similar images cannot be obtained more accurately.

[0031] Therefore, the inventors have proposed an image processing method, device, and electronic device in the present application that can improve the above-mentioned problems. After acquiring the first image and the second image, the first global feature and the first local feature map, as well as the second global feature and the second local feature map are further acquired, and then based on the first global feature, the first local feature map, the second global feature, and the second local feature map, it is determined whether the first image and the second image are similar. Therefore, in the process of judging the similarity between the first image and the second image, the global features and the local features of the first image and the second image can be combined at the same time to perform similarity detection, so that a more comprehensive detection can be performed in the process of image similarity detection, thereby improving the accuracy of similarity detection.

[0032] It should be noted that the image processing method provided in the embodiment of the present application can be run in electronic devices such as mobile phones and tablet computers, and can also be run in a server. Among them, the server can be a single physical server, or it can be a server cluster or distributed system composed of multiple physical servers, or it can be a cloud server that provides basic cloud computing services such as cloud services, cloud computing, cloud storage, CDN (Content Delivery Network), and artificial intelligence platforms. Among them, in the case where the data processing method provided in the embodiment of the present application is executed by a server cluster or distributed system composed of multiple physical servers, different steps in the data processing method can be executed by different physical servers respectively, or can be executed in a distributed manner by a server built based on a distributed system. For example, Figure 1 As shown, obtaining the first image and the second image, and obtaining the first global feature, the first local feature map, the second global feature and the second local feature map can be performed by the server 110 alone, and the subsequent steps can be performed by the server 120.

[0033] Furthermore, the image processing method provided in this embodiment can also be completed by the electronic device and the server in collaboration. Optionally, the electronic device can acquire the first image and the second image, and then the electronic device sends the acquired first image and the second image to the server, and then the server performs the subsequent acquisition of the first global feature, the first local feature map, the second global feature and the second local feature map, and determines whether the first image is similar to the second image based on the first global feature, the first local feature map, the second global feature and the second local feature map, and after obtaining the similarity judgment result, the server can return the judgment result to the electronic device.

[0034] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0035] See also Figure 2, an image processing method provided in an embodiment of the present application, the method comprising:

[0036] S110: Acquire a first image and a second image.

[0037] The first image and the second image are images for similarity comparison. It should be noted that the image processing method provided in this embodiment can be run in a variety of scenarios, and correspondingly, the first image and the second image are obtained in different ways in different scenarios.

[0038] Optionally, the image processing method provided in this embodiment can be run in a network information search scenario. In this scenario, a user can input an image and then search for images similar to the input image. Correspondingly, the image input by the user can be used as the first image, and the image currently being compared with the first image for similarity can be used as the second image. Optionally, the image processing method provided in this embodiment can be run in an image management program. In this scenario, the image selected by the user from the image management program can be used as the first image, and images other than the selected image can be used as the second image.

[0039] S120: Obtain a first global feature and a first local feature map, where the first global feature is a global feature corresponding to the first image, and the first local feature map includes local features corresponding to the first image.

[0040] Among them, global features can be understood as features that characterize the image content as a whole, and correspondingly, local features can be understood as features that characterize the image content from a local part of the image.

[0041] As a way, Figure 3 As shown, the obtaining of the first global feature and the first local feature map includes:

[0042] S121: Input the first image into a target neural network, and obtain a feature map output by the target neural network as a first initial feature map. Optionally, the target neural network may be a CNN (Convolutional Neural Networks) network. In this embodiment, the target neural network may be a model that has been trained in other tasks, such as a classification model, a segmentation model, etc.

[0043] S122: Perform global average pooling processing on the initial feature map to obtain a first global feature.

[0044] Optionally, global average pooling can be performed based on the following formula:

[0045]

[0046] Where F(i,j) represents the feature vector at position (i,j), w represents the width of the initial feature map, and h represents the height of the initial feature map. Take the initial feature map F with a size of w*h*d as an example, where w represents the width of the initial feature map, h represents the height of the initial feature map, and d represents the number of channels of the initial feature map. Figure 4 As shown, the initial feature map F with a size of w*h*d can be processed by global average pooling to obtain a global image feature G with a size of 1*d as the first global feature.

[0047] S123: Obtain feature sets corresponding to each of the multiple positions in the initial feature map, where the feature set corresponding to each position includes features of each position and features of adjacent positions of each position.

[0048] As a method, the multiple positions may be each position in the initial feature map. It should be noted that the initial feature map may correspond to a channel dimension, and the information of each position (i, j) includes the color information of each channel. For example, Figure 5 As shown, Figure 5 Initial features shown Fig.10 , where the exemplary display is as follows: position a to position i (initial feature Fig.10 It may also include other positions other than position a to position i), where, for position a, the adjacent positions include position b, position e and position d. For example, for position e, the adjacent positions include position a, position b, position c, position f, position i, position h, position g, and position d.

[0049] S124: performing average processing on the feature sets corresponding to each of the positions to obtain the local features corresponding to each of the positions.

[0050] S125: Obtain the first local feature map based on the local features corresponding to each of the positions.

[0051] like Figure 6 As shown, if the size of the first image is W*H*3, then after being processed by the target neural network, an initial feature map F of size w*h*d can be obtained, and then the feature set of position (i, j) can be obtained, and then the feature set of position (i, j) is averaged in the local area (i.e., average processing is performed), and a local feature of size 1*d can be obtained, and then the local features of size 1*d corresponding to each position can be aggregated to obtain the first local feature map corresponding to the first image of size W*H*3.

[0052] It should be noted that the local feature corresponding to each position can also be understood as a local feature vector of each position. Optionally, the local feature vector of each position can be calculated by the following formula:

[0053]

[0054] Among them, F(u,v) represents the feature vector at the position (u,v), and M represents the number of adjacent positions corresponding to the position (u,v).

[0055] S130: Obtain a second global feature and a second local feature map, where the second global feature is a global feature corresponding to the second image, and the second local feature map includes local features corresponding to the second image.

[0056] As a way, Figure 7 As shown, the obtaining of the second global feature and the second local feature map includes:

[0057] S131: Input the second image into the target neural network, and obtain a feature map output by the target neural network as a second initial feature map.

[0058] S132: Perform global average pooling processing on the second initial feature map to obtain a second global feature.

[0059] S133: Obtain feature sets corresponding to each of the plurality of positions in the second initial feature map, wherein the feature set corresponding to each position includes features of each position and features of adjacent positions of each position.

[0060] S134: performing average processing on the feature sets corresponding to each of the positions to obtain the local features corresponding to each of the positions.

[0061] S135: Obtain the second local feature map based on the local features corresponding to each of the positions.

[0062] It should be noted that the principle of inputting the second image into the target neural network to obtain the second global feature and the second local feature map is the same as the principle of obtaining the first global feature and the first local feature map mentioned above, and will not be repeated in this embodiment.

[0063] S140: Determine whether the first image is similar to the second image based on the first global feature, the first local feature map, the second global feature, and the second local feature map.

[0064] In this embodiment, whether the first image and the second image are similar can be determined based on the first global feature, the first local feature map, the second global feature, and the second local feature map. Optionally, the first global feature and the second global feature can be compared, and the first local feature map and the second local feature map can be compared, and then when the first global feature and the second global feature meet certain conditions, and the first local feature map and the second local feature map also meet certain conditions, it is determined that the first image and the second image are similar, and then in the process of image similarity comparison, a more comprehensive feature comparison can be performed to improve accuracy.

[0065] The image processing method provided in this embodiment further acquires the first global feature and the first local feature map, and acquires the second global feature and the second local feature map after acquiring the first image and the second image, and then determines whether the first image and the second image are similar based on the first global feature, the first local feature map, the second global feature and the second local feature map. Thus, in the process of determining the similarity between the first image and the second image, the global features and the local features of the first image and the second image can be combined to perform similarity detection at the same time, so that a more comprehensive detection can be performed in the process of image similarity detection, thereby improving the accuracy of similarity detection.

[0066] See also Figure 8 , an image processing method provided in an embodiment of the present application, the method comprising:

[0067] S210: Acquire a first image and a second image.

[0068] S220: Obtain a first global feature and a first local feature map, where the first global feature is a global feature corresponding to the first image, and the first local feature map includes local features corresponding to the first image.

[0069] S230: Obtain a second global feature and a second local feature map, where the second global feature is a global feature corresponding to the second image, and the second local feature map includes local features corresponding to the second image.

[0070] S240: If the first global feature and the second global feature satisfy a first similarity condition, and the first local feature map and the second local feature map satisfy a second similarity condition, determine that the first image and the second image are similar.

[0071] As a method, after obtaining the first global feature, the first local feature map, the second global feature, and the second local feature map, it is possible to determine whether the first image and the second image are similar based on the process shown in the following figure, such as Fig. 9 As shown, the process includes:

[0072] S250: Detect whether the first global feature and the second global feature satisfy a first similarity condition.

[0073] S251: If the first global feature and the second global feature do not satisfy the first similarity condition, determine that the first image and the second image are not similar.

[0074] It should be noted that in the present embodiment, the global feature can be understood as a vector that characterizes the overall features of an image. In the present embodiment, the local feature map includes local features of multiple regions of the image, that is, the local feature map includes multiple local features. Then the corresponding first global feature can be understood as a vector that characterizes the overall features of the first image, and the first local feature map will include multiple local features corresponding to multiple positions in the first image. Correspondingly, the second global feature can be understood as a vector that characterizes the overall features of the second image, and the second local feature map will include multiple local features corresponding to multiple positions in the second image.

[0075] Then, in the process of similarity comparison based on global features, it can be understood as comparing the distance between two vectors, and in the process of similarity comparison based on local feature maps, it will be compared based on multiple feature vectors. It can be determined that because the number of features to be compared is greater, similarity comparison based on local features will consume more time and computing resources than similarity comparison based on global features. Then, in order to avoid wasting resources, in the process of comparing the similarity between the first image and the second image, the first global feature and the second global feature can be compared first, that is, first determine whether the first global feature and the second global feature meet the first similarity condition.

[0076] If it is determined that the first global feature and the second global feature satisfy the first similarity condition, then it is preliminarily determined that the first image and the second image are very likely to be similar, and in order to further confirm whether they are really similar, a comparison can be performed based on the first local feature map and the second local feature map. Correspondingly, if it is determined that the first global feature and the second global feature do not satisfy the first similarity condition, it can be directly determined that the first image and the second image are not similar.

[0077] S252: If the first global feature and the second global feature satisfy a first similarity condition, detecting whether the first local feature map and the second local feature map satisfy a second similarity condition;

[0078] S253: If the first local feature map and the second local feature map satisfy a second similarity condition, determine that the first image and the second image are similar.

[0079] S254: If the first local feature map and the second local feature map do not satisfy the second similarity condition, determine that the first image and the second image are not similar.

[0080] Wherein, optionally, if the distance between the first global feature and the second global feature is less than a first distance threshold, it is determined that the first global feature and the second global feature meet a first similarity condition. Wherein, as a way, the distance between the first global feature and the second global feature can be calculated based on the Euclidean distance or the cosine distance. In this embodiment, the distance between the first global feature and the second global feature can be calculated based on the following formula, which is:

[0081] D G =||G 1 -G 2 ||2

[0082] Among them, D G Characterizes the distance between the calculated first global feature and the second global feature, G 1 Characterize the first global feature, G 2 Characterize the second global feature.

[0083] Optionally, calculating whether the first local feature map and the second local feature map satisfy the second similarity condition may include:

[0084] A feature distance between mutually corresponding first local features and second local features is calculated, wherein the first local feature is a local feature included in the first local feature map, and the second local feature is a local feature included in the second local feature map.

[0085] It should be noted that the first local feature map is obtained by combining the local features corresponding to the respective positions in the aforementioned first initial feature map. Correspondingly, the second local feature map is obtained by combining the local features corresponding to the respective positions in the aforementioned second initial feature map. Optionally, the positions in the first initial feature map and the second initial feature map can be identified based on coordinates, and then the positions with the same corresponding coordinates can be used as mutually corresponding positions. For example, the coordinates of the position (i1, j1) of the first local feature map and the position (i1, j1) of the second local feature map are both (i1, j1), then the position (i1, j1) in the first local feature map and the position (i1, j1) in the second local feature map are two positions corresponding to each other. Correspondingly, the local features corresponding to the two corresponding positions are the corresponding local features. Then the mutually corresponding first local feature and the second local feature can be understood as the position corresponding to the first local feature and the position corresponding to the second local feature are mutually corresponding.

[0086] like Fig.10 As shown, the first initial feature map 20 and the second initial feature map 30 are shown, wherein the coordinates of position 21 of the first initial feature map 20 are (1, 1), and the coordinates corresponding to position 31 of the second initial feature map 30 are also (1, 1). Because the coordinates of position 21 in the first initial feature map 20 and the coordinates of position 31 in the second initial feature map 30 are the same, then position 21 and position 31 are corresponding positions, and then the first local feature corresponding to position 21 and the first local feature corresponding to position 31 are the corresponding first local feature and second local feature.

[0087] Then as a way, when the size of the first image and the second image is the same, the size of the first initial feature map and the second initial feature map is also the same. Then for each position in the first initial feature map, there will be a corresponding position in the second initial feature map.

[0088] As one way, the feature distance between the first local features and the second local features corresponding to each other may be calculated based on the following formula:

[0089] D L (i, j) = || L 1 (i, j)-L 2 (i, j)||2

[0090] Among them, L 1 (i, j) represents the local feature corresponding to the position (i, j) in the first initial feature map. 2 (i, j) represents the local feature corresponding to the position (i, j) in the second initial feature map.

[0091] The first local feature whose corresponding feature distance is less than the second distance threshold is used as the target local feature.

[0092] As shown in the above content, when each position in the first initial feature map has a corresponding position in the second initial feature map, the feature distance corresponding to the first local feature corresponding to each position in the first initial feature map can be calculated. Among them, the feature distance corresponding to the first local feature can be understood as the feature distance between the first local feature and the second local feature corresponding to the position.

[0093] If the ratio of the number of the target local features to the number of local features included in the first local feature map is greater than a ratio threshold, it is determined that the first local feature map and the second local feature map meet a second similarity condition.

[0094] The ratio can be calculated based on the following formula:

[0095]

[0096] Among them, N L represents the number of local features of the target, w represents the width of the first initial feature map, and h represents the height of the first initial feature map. Optionally, R can be 0.6.

[0097] It should be noted that the product of the width of the first initial feature map and the height of the first initial feature map represents the number of positions in the first initial feature map. When each position corresponds to a local feature, the number of local features included in the first local feature map is the number of positions in the first initial feature map.

[0098] It should be noted that, as a method, before obtaining the first global feature and the first local feature map, the step further includes: if the sizes of the first image and the second image are different, updating the sizes of the first image and the second image to be the same.

[0099] The present application provides an image processing method, after acquiring the first image and the second image, further acquiring the first global feature and the first local feature map, and acquiring the second global feature and the second local feature map, and then determining whether the first image and the second image are similar based on the first global feature, the first local feature map, the second global feature and the second local feature map. Thus, in the process of judging the similarity between the first image and the second image, the global features and the local features of the first image and the second image can be combined to detect the similarity, so that a more comprehensive detection can be performed in the process of image similarity detection, and the accuracy of similarity detection is improved. Moreover, in this embodiment, it can be based on the first global feature and the second global feature to preliminarily determine the possibility of the first image and the second image being similar, and then after the first global feature and the second global feature meet the first similarity condition, the first local feature map and the second local feature map are detected to see whether they meet the second similarity condition, so as to improve the effective utilization of computing resources.

[0100] See also Fig.11 , an image processing method provided in an embodiment of the present application, the method comprising:

[0101] S310: Acquire a first image and a first image set.

[0102] The first image set is a set of images for image similarity matching. In this embodiment, images in the first image set can be matched with the first image to obtain images in the first image set that are similar to the first image.

[0103] S320: Obtain a first global feature and a first local feature map, where the first global feature is a global feature corresponding to the first image, and the first local feature map includes local features corresponding to the first image.

[0104] S330: Obtain global features and local feature maps corresponding to each image in the first image set.

[0105] Optionally, based on the aforementioned method of obtaining the first global feature and the first local feature map, the global feature and the local feature map corresponding to each image in the first image set may be obtained.

[0106] S340: Determine a second image set from the first image set based on the first global feature and the global feature corresponding to each image in the first image set.

[0107] It should be noted that, in this embodiment, the global features corresponding to each image in the first image set can be compared with the first global features of the first image, and then the images corresponding to the global features whose corresponding comparison results satisfy the aforementioned first similarity condition are combined into a second image set. Exemplarily, the first image set includes image A, image B, and image C, wherein the global feature corresponding to image A is global feature t1, the global feature corresponding to image B is global feature t2, and the global feature corresponding to image C is global feature t3. Then the global feature t1 is compared with the first global feature, then the global feature corresponding to the comparison result is the global feature t1, and the image corresponding to the global feature t1 is image A.

[0108] S350: Determine an image in the second image set that is similar to the first image based on the first local feature map and the local feature map of each image in the second image set.

[0109] After obtaining the second image set, the local feature map of each image in the second image set can be compared with the first local feature map, and then the image corresponding to the local feature map whose corresponding comparison result satisfies the aforementioned second similarity condition is taken as an image similar to the first image. Exemplarily, the first image set includes image A, image B, and image C, and the screened second image set includes image B and image C. If the image corresponding to the local feature map whose corresponding comparison result satisfies the aforementioned second similarity condition is image B, it can be determined that image B is an image similar to the first image.

[0110] An image processing method provided by the present application further acquires a first global feature and a first local feature map after acquiring a first image and a second image, and acquires a global feature and a local feature map corresponding to each image in the first image set, and then determines a second image set from the first image set based on the first global feature and the global feature corresponding to each image in the first image set, and then determines an image in the second image set that is similar to the first image based on the first local feature map and the local feature map of each image in the second image set.

[0111] Therefore, in the process of screening images similar to the first image from the first image set based on the first image, a preliminary screening can be performed based on the first global feature and the global feature corresponding to each image in the first image set to obtain the second image set, so that the images in the first image set that are actually not similar to the first image can be eliminated more quickly, and then based on the first local feature map and the local features of each image in the second image set, the images in the second image set that are similar to the first image are determined, so that actually similar images can be determined based on the local features of the image within a relatively smaller range.

[0112] See also Fig.12 , an image processing device 400 provided in an embodiment of the present application, the device 400 includes:

[0113] The image acquisition unit 410 is used to acquire a first image and a second image.

[0114] The feature acquisition unit 420 is used to acquire a first global feature and a first local feature map, where the first global feature is a global feature corresponding to the first image, and the first local feature map includes a local feature corresponding to the first image.

[0115] The feature acquisition unit 420 is further used to acquire a second global feature and a second local feature map, where the second global feature is a global feature corresponding to the second image, and the second local feature map includes a local feature corresponding to the second image.

[0116] As a method, the feature acquisition unit 420 is specifically used to input the first image into the target neural network, obtain the feature map output by the target neural network as the initial feature map; perform global average pooling processing on the initial feature map to obtain a first global feature; obtain feature sets corresponding to multiple positions in the initial feature map, and the feature sets corresponding to each position include the features of each position and the features of adjacent positions of each position; perform average processing on the feature sets corresponding to each position to obtain local features corresponding to each position; and obtain the first local feature map based on the local features corresponding to each position.

[0117] As a method, the feature acquisition unit 420 is specifically used to input the second image into the target neural network, obtain the feature map output by the target neural network as the second initial feature map; perform global average pooling processing on the second initial feature map to obtain a second global feature; obtain feature sets corresponding to multiple positions in the second initial feature map, and the feature set corresponding to each position includes the feature of each position and the feature of the adjacent positions of each position; perform average processing on the feature set corresponding to each position to obtain the local feature corresponding to each position; and obtain the second local feature map based on the local feature corresponding to each position.

[0118] The image comparison unit 430 is used to determine whether the first image is similar to the second image based on the first global feature, the first local feature map, the second global feature and the second local feature map.

[0119] Among them, optionally, the image comparison unit 430 is specifically used to determine that the first image is similar to the second image if the first global feature and the second global feature meet a first similarity condition, and the first local feature map and the second local feature map meet a second similarity condition.

[0120] Optionally, the image comparison unit 430 is specifically used to detect whether the first local feature map and the second local feature map meet a second similarity condition if the first global feature and the second global feature meet a first similarity condition; if the first global feature and the second global feature do not meet the first similarity condition, determine that the first image and the second image are not similar.

[0121] As one approach, the image comparison unit 430 is specifically configured to determine that the first global feature and the second global feature satisfy a first similarity condition if the distance between the first global feature and the second global feature is less than a first distance threshold.

[0122] As a method, the image comparison unit 430 is specifically used to calculate the feature distance between the first local feature and the second local feature corresponding to each other, where the first local feature is the local feature included in the first local feature map, and the second local feature is the local feature included in the second local feature map; the first local feature whose corresponding feature distance is less than the second distance threshold is used as the target local feature; if the ratio of the number of target local features to the number of local features included in the first local feature map is greater than the ratio threshold, it is determined that the first local feature and the second local feature meet the first similarity condition.

[0123] like Fig.13 As shown, the device 400 further includes:

[0124] The size processing unit 440 is configured to update the sizes of the first image and the second image to be the same if the sizes of the first image and the second image are different.

[0125] See also Fig.14 , an image processing device 500 provided in an embodiment of the present application, the device 500 includes:

[0126] An image acquisition unit 510, configured to acquire a first image and a first image set;

[0127] A feature acquisition unit 520 is configured to acquire a first global feature and a first local feature map, wherein the first global feature is a global feature corresponding to the first image, and the first local feature map includes a local feature corresponding to the first image;

[0128] The feature acquisition unit 520 is further used to acquire the global features and local feature maps corresponding to each image in the first image set;

[0129] A first image determining unit 530, configured to determine a second image set from the first image set based on the first global feature and a global feature corresponding to each image in the first image set;

[0130] The second image determining unit 540 is configured to determine an image in the second image set that is similar to the first image based on the first local feature map and the local feature map of each image in the second image set.

[0131] The present application provides an image processing device, which, after acquiring the first image and the second image, further acquires the first global feature and the first local feature map, and acquires the second global feature and the second local feature map, and then determines whether the first image and the second image are similar based on the first global feature, the first local feature map, the second global feature and the second local feature map. Therefore, in the process of determining the similarity between the first image and the second image, the global features and the local features of the first image and the second image can be combined to perform similarity detection at the same time, so that a more comprehensive detection can be performed in the process of image similarity detection, thereby improving the accuracy of similarity detection.

[0132] It should be noted that the device embodiment in the present application corresponds to the aforementioned method embodiment. The specific principles in the device embodiment can be found in the contents of the aforementioned method embodiment and will not be repeated here.

[0133] The following will be combined Fig.15 An electronic device provided by the present application is described.

[0134] See also Fig.15 Based on the above-mentioned image processing method and apparatus, the embodiment of the present application also provides another electronic device 200 that can execute the above-mentioned image processing method. The electronic device 200 includes one or more (only one is shown in the figure) processors 102, a memory 104 and a network module 106 that are coupled to each other. Among them, the memory 104 stores a program that can execute the content of the above-mentioned embodiment, and the processor 102 can execute the program stored in the memory 104.

[0135] Among them, the processor 102 may include one or more cores for processing data. The processor 102 uses various interfaces and lines to connect various parts of the entire electronic device 200, and executes various functions and processes data of the electronic device 200 by running or executing instructions, programs, code sets or instruction sets stored in the memory 104, and calling data stored in the memory 104. Optionally, the processor 102 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 102 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 102, but may be implemented separately through a communication chip.

[0136] The memory 104 may include a random access memory (RAM) or a read-only memory (ROM). The memory 104 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 104 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the terminal 100 during use.

[0137] The network module 106 is used to receive and send electromagnetic waves, realize the mutual conversion between electromagnetic waves and electrical signals, so as to communicate with a communication network or other devices, such as communicating with an audio playback device. The network module 106 may include various existing circuit elements for performing these functions, such as antennas, radio frequency transceivers, digital signal processors, encryption / decryption chips, user identity modules (SIM) cards, memories, etc. The network module 106 may communicate with various networks such as the Internet, corporate intranets, wireless networks, or communicate with other devices via wireless networks. The above-mentioned wireless networks may include cellular telephone networks, wireless local area networks, or metropolitan area networks. For example, the network module 106 may exchange information with a base station.

[0138] Please refer to Fig.16 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 1100 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0139] The computer readable storage medium 1100 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 1100 includes a non-transitory computer-readable storage medium. The computer readable storage medium 1100 has storage space for program code 1110 that executes any method step in the above method. These program codes can be read from or written to one or more computer program products. The program code 1110 can be compressed, for example, in an appropriate form.

[0140] In summary, the image processing method, device and electronic device provided by the present application will further acquire the first global feature and the first local feature map, and acquire the second global feature and the second local feature map after acquiring the first image and the second image, and then determine whether the first image is similar to the second image based on the first global feature, the first local feature map, the second global feature and the second local feature map. Therefore, in the process of judging the similarity between the first image and the second image, the global features and the local features of the first image and the second image can be combined at the same time to perform similarity detection, so that a more comprehensive detection can be performed in the process of image similarity detection, thereby improving the accuracy of similarity detection.

[0141] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical feature diagrams therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. An image processing method, characterized in that: The method comprises: Acquire a first image and a second image; Obtaining a first global feature and a first local feature map, wherein the first global feature is a global feature corresponding to the first image, and the first local feature map includes local features corresponding to the first image, wherein the first local feature map includes local features corresponding to each position in the first initial feature map, and the local features are obtained by averaging feature sets corresponding to each position, and the first initial feature map is obtained by inputting the first image into a target neural network; Obtain a second global feature and a second local feature map, wherein the second global feature is a global feature corresponding to the second image, and the second local feature map includes local features corresponding to the second image, wherein the second local feature map includes local features corresponding to each position in the second initial feature map, and the local features are obtained by averaging the feature sets corresponding to each position, and the second initial feature map is obtained by inputting the second image into a target neural network, wherein the feature set corresponding to each position includes features of each position and features of adjacent positions of each position, and the multiple positions include each position in the initial feature map; If the first global feature and the second global feature satisfy a first similarity condition, and the first local feature map and the second local feature map satisfy a second similarity condition, determining that the first image is similar to the second image; The method further includes: calculating the feature distance between a first local feature and a second local feature corresponding to each other, the first local feature being a local feature included in the first local feature map, and the second local feature being a local feature included in the second local feature map; taking the first local feature whose corresponding feature distance is less than a second distance threshold as a target local feature; if the ratio of the number of target local features to the number of local features included in the first local feature map is greater than a ratio threshold, determining that the first local feature map and the second local feature map satisfy a second similarity condition.

2. The method according to claim 1, characterized in that The method further comprises: If the first global feature and the second global feature satisfy a first similarity condition, detecting whether the first local feature map and the second local feature map satisfy a second similarity condition; If the first global feature and the second global feature do not satisfy the first similarity condition, it is determined that the first image and the second image are not similar.

3. The method according to claim 1 or 2, characterized in that: The method further comprises: If the distance between the first global feature and the second global feature is less than a first distance threshold, it is determined that the first global feature and the second global feature satisfy a first similarity condition.

4. The method according to claim 1, characterized in that: Before obtaining the first global feature and the first local feature map, the method further includes: If the sizes of the first image and the second image are different, the sizes of the first image and the second image are updated to be the same.

5. An image processing method, characterized in that: The method comprises: Acquire a first image and a first image set; Obtain a first global feature and a first local feature map, wherein the first global feature is a global feature corresponding to the first image, and the first local feature map includes local features corresponding to the first image, wherein the first local feature map includes local features corresponding to each position in the first initial feature map, and the local features are obtained by averaging the feature sets corresponding to each position, and the first initial feature map is obtained by inputting the first image into a target neural network, wherein the feature set corresponding to each position includes features of each position and features of adjacent positions of each position, and the multiple positions include each position in the initial feature map; Obtaining global features and local feature maps corresponding to each image in the first image set; Determine a second image set from the first image set based on the first global feature and a global feature corresponding to each image in the first image set; Based on the first local feature map and the local feature map of each image in the second image set, determine the image in the second image set that is similar to the first image; wherein the method also includes: calculating the feature distance between the first local feature and the second local feature that correspond to each other, the first local feature is the local feature included in the first local feature map, and the second local feature is the local feature included in the local feature map of any image in the second image set; taking the first local feature whose corresponding feature distance is less than the second distance threshold as the target local feature; if the ratio of the number of the target local features to the number of the local features included in the first local feature map is greater than the ratio threshold, determine that the first local feature map and the second local feature map meet the similarity condition.

6. An image processing device, characterized in that: The device comprises: An image acquisition unit, used to acquire a first image and a second image; a feature acquisition unit, configured to acquire a first global feature and a first local feature map, wherein the first global feature is a global feature corresponding to the first image, and the first local feature map includes local features corresponding to the first image, wherein the first local feature map includes local features corresponding to each position in the first initial feature map, and the local features are obtained by averaging feature sets corresponding to each position, and the first initial feature map is obtained by inputting the first image into a target neural network; The feature acquisition unit is further used to acquire a second global feature and a second local feature map, wherein the second global feature is a global feature corresponding to the second image, and the second local feature map includes local features corresponding to the second image, wherein the second local feature map includes local features corresponding to each position in the second initial feature map, and the local features are obtained by averaging the feature sets corresponding to each position, and the second initial feature map is obtained by inputting the second image into a target neural network, wherein the feature set corresponding to each position includes features of each position and features of adjacent positions of each position, and the multiple positions include each position in the initial feature map; An image comparison unit is used to determine that the first image is similar to the second image if the first global feature and the second global feature meet a first similarity condition, and the first local feature map and the second local feature map meet a second similarity condition; wherein the image comparison unit is also used to calculate the feature distance between the first local features and the second local features corresponding to each other, the first local feature is the local feature included in the first local feature map, and the second local feature is the local feature included in the second local feature map; the first local feature whose corresponding feature distance is less than a second distance threshold is used as the target local feature; if the ratio of the number of the target local features to the number of the local features included in the first local feature map is greater than a ratio threshold, it is determined that the first local feature map and the second local feature map meet the second similarity condition.

7. An image processing device, characterized in that: The device comprises: An image acquisition unit, configured to acquire a first image and a first image set; A feature acquisition unit, used to acquire a first global feature and a first local feature map, wherein the first global feature is a global feature corresponding to the first image, and the first local feature map includes local features corresponding to the first image, wherein the first local feature map includes local features corresponding to each position in the first initial feature map, and the local features are obtained by averaging the feature sets corresponding to each position, and the first initial feature map is obtained by inputting the first image into a target neural network, wherein the feature set corresponding to each position includes features of each position and features of adjacent positions of each position, and the multiple positions include each position in the initial feature map; The feature acquisition unit is further used to acquire the global features and local feature maps corresponding to each image in the first image set; A first image determining unit, configured to determine a second image set from the first image set based on the first global feature and a global feature corresponding to each image in the first image set; A second image determination unit is used to determine an image in the second image set that is similar to the first image based on the first local feature map and the local feature map of each image in the second image set; the second image determination unit is also used to calculate the feature distance between the first local features and the second local features that correspond to each other, the first local feature is the local feature included in the first local feature map, and the second local feature is the local feature included in the local feature map of any image in the second image set; the first local feature whose corresponding feature distance is less than a second distance threshold is used as a target local feature; if the ratio of the number of target local features to the number of local features included in the first local feature map is greater than a ratio threshold, it is determined that the first local feature map and the second local feature map meet a similarity condition.

8. An electronic device, characterized in that: including a processor and a memory; One or more programs are stored in the memory and configured to be executed by the processor to implement the method of any one of claims 1 to 4 or the method of claim 5.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, wherein when the program codes are executed by a processor, the method according to any one of claims 1 to 4 or the method according to claim 5 is executed.

Citation Information

Patent Citations

  • Image retrieval method and device, equipment and medium

    CN111522986A