Image processing method and device, electronic equipment and readable storage medium
By combining global and local features for similarity calculation, the problem of similarity accuracy caused by incomplete image objects is solved, and more accurate image similarity measurement and pedestrian re-identification are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-08
- Publication Date
- 2026-03-24
AI Technical Summary
Existing technologies ignore the incompleteness of objects in images when calculating image similarity, resulting in low similarity accuracy. This is especially true in pedestrian detection, where incomplete body regions make it impossible to accurately measure the semantic similarity of images.
A method combining global and local features is used to calculate the feature similarity of image pairs. By using the cosine similarity calculation formula, a more accurate similarity of images can be obtained, avoiding the influence of object incompleteness.
It improves the accuracy of image similarity calculation, especially in pedestrian detection, and can more robustly measure the semantic similarity between two images, thus enhancing the accuracy of pedestrian re-identification.
Smart Images

Figure CN115240221B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, in particular to an image processing method and device, an electronic device and a readable storage medium. BACKGROUND
[0002] Similarity calculation of images is a classic topic in the field of computer vision, and has a wide range of applications in face recognition, image retrieval, pedestrian re-identification, human following, etc. For example, for a human following task, how to calculate the similarity of two images plays a crucial role. A human following system is often composed of "pedestrian detection-pedestrian re-identification": the pedestrian detection module detects the position of the pedestrian in the original video frame, and the pedestrian re-identification module determines the target pedestrian in the current frame by extracting the features of the pedestrian and calculating the similarity of the features of the pedestrian and the features of the target pedestrian.
[0003] Currently, the similarity of the global features of two images is calculated, and this similarity is taken as the image similarity of the two images. However, due to various factors (such as occlusion of the object), there may be a situation where the object in the image for which the image similarity needs to be calculated is incomplete, such as in two pedestrian images, at least one of the body regions in the pedestrian images is incomplete. In this case, if the global similarity is still taken as the similarity of the two images, the accuracy of the obtained image similarity will be low, which will further lead to inaccurate image recognition, image retrieval results, etc. SUMMARY
[0004] The embodiments of the present application provide an image processing method, device, electronic device and readable storage medium, which can more reasonably and accurately calculate the similarity of an image pair based on global features and local features, thereby at least reducing the situation that the accuracy of the obtained image similarity is low due to the incompleteness of the object in the image.
[0005] The embodiments of the present application can be implemented as follows:
[0006] In a first aspect, the embodiments of the present application provide an image processing method, which comprises:
[0007] obtaining a first global feature and a first local feature of a first image;
[0008] obtaining a second global feature and a second local feature of a second image;
[0009] calculating the similarity between each feature in the first global feature and the first local feature and each feature in the second global feature and the second local feature;
[0010] obtaining the image similarity of the first image and the second image according to the obtained similarity.
[0011] Secondly, embodiments of this application provide an image processing apparatus, the apparatus comprising:
[0012] The feature acquisition module is used to acquire the first global feature and the first local feature of the first image;
[0013] The feature acquisition module is further configured to acquire the second global features and the second local features of the second image;
[0014] The calculation module is used to calculate the similarity between each feature in the first global feature and the first local feature and each feature in the second global feature and the second local feature;
[0015] The processing module is used to obtain the image similarity between the first image and the second image based on the obtained similarity.
[0016] Thirdly, embodiments of this application provide an electronic device, including a processor and a memory, wherein the memory stores machine-executable instructions that can be executed by the processor, and the processor can execute the machine-executable instructions to implement the image processing method described in any of the foregoing embodiments.
[0017] Fourthly, embodiments of this application provide a readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the image processing method as described in any of the foregoing embodiments.
[0018] The image processing method, apparatus, electronic device, and readable storage medium provided in this application calculate the pairwise similarity between each feature in the first global features and first local features of a first image and each feature in the second global features and second local features of a second image, and then obtain the image similarity between the first image and the second image based on the obtained similarity. In this way, image similarity can be obtained based on the pairwise similarity between the global and local features of an image pair, avoiding the inaccurate measurement of the similarity between two images due to ignoring the effects of incomplete objects in the image. Attached Figure Description
[0019] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a schematic diagram of pedestrian image pairs;
[0021] Figure 2 A block diagram illustrating an electronic device provided in an embodiment of this application;
[0022] Figure 3 This is one of the flowcharts illustrating the image processing method provided in the embodiments of this application;
[0023] Figure 4 for Figure 3 A flowchart illustrating the sub-steps included in step S110;
[0024] Figure 5 This is a schematic diagram illustrating the calculation of image similarity between two types.
[0025] Figure 6 A second schematic flowchart illustrating the image processing method provided in this application embodiment;
[0026] Figure 7 This is a block diagram of an image processing apparatus provided in an embodiment of this application.
[0027] Icons: 100 - Electronic device; 110 - Memory; 120 - Processor; 130 - Communication unit; 200 - Image processing device; 210 - Feature acquisition module; 220 - Calculation module; 230 - Processing module. Detailed Implementation
[0028] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0029] Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0030] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0031] Currently, due to various factors, objects in images may be incomplete. In such cases, using the similarity of global features as the similarity between two images will result in low accuracy of the obtained image similarity.
[0032] For example, in human tracking, the limitations of the camera's FOV (Field of View) often result in incomplete detection of the pedestrian's body area by the pedestrian detection module. For example, ... Figure 1 As shown, in a, the pedestrian body regions of the two pedestrian images are relatively complete, but the right arm of one of them is mostly missing; in b and c, one is a pedestrian image with a complete body region, and the other is a pedestrian image with an incomplete body region; in d, the pedestrian body regions of the two pedestrian images are incomplete.
[0033] Existing methods simply calculate the similarity between pedestrian images with complete body regions and those with incomplete body regions, i.e., calculate the global similarity. This approach fails to adequately consider the impact of incomplete body regions, resulting in low similarity even when the pedestrians in the two images are the same person, thus failing to accurately measure the semantic similarity between the two images.
[0034] To address the aforementioned problems, embodiments of this application provide an image processing method, apparatus, electronic device, and readable storage medium. Image similarity is obtained based on the similarity between pairwise features in the global and local features of image pairs, avoiding the inaccurate measurement of image similarity caused by ignoring the incompleteness of objects in the image. It is worth noting that the deficiencies of the above solutions are the result of the inventors' practical experience and careful research. Therefore, the discovery process of the above problems and the solutions proposed in the embodiments of this application below are contributions made by the inventors to this application.
[0035] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.
[0036] Please refer to Figure 2 , Figure 2 This is a block diagram of an electronic device 100 provided in an embodiment of this application. The electronic device 100 may be, but is not limited to, a computer, a server, etc. The electronic device 100 may include a memory 110, a processor 120, and a communication unit 130. The memory 110, processor 120, and communication unit 130 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.
[0037] The memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0038] The processor 120 is used to read / write data or programs stored in the memory 110 and execute corresponding functions. For example, the memory 110 stores an image processing device 200, which includes at least one software function module that can be stored in the memory 110 in the form of software or firmware. The processor 120 executes various functional applications and data processing by running the software programs and modules stored in the memory 110, such as the image processing device 200 in the embodiments of this application, thereby implementing the image processing method in the embodiments of this application.
[0039] The communication unit 130 is used to establish a communication connection between the electronic device 100 and other communication terminals through the network, and to send and receive data through the network.
[0040] It should be understood that, Figure 2 The structure shown is only a schematic diagram of the electronic device 100. The electronic device 100 may also include components that are larger than... Figure 1 The more or fewer components shown, or having the sameFigure 1 The different configurations shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.
[0041] Please refer to Figure 3 , Figure 3 This is one of the schematic flowcharts of an image processing method provided in an embodiment of this application. The method can be applied to the aforementioned electronic device 100. The specific flow of the image processing method is described in detail below. In this embodiment, the method may include steps S110 to S140.
[0042] Step S110: Obtain the first global feature and the first local feature of the first image.
[0043] Step S120: Obtain the second global features and the second local features of the second image.
[0044] In this embodiment, the first image and the second image are two images whose image similarity needs to be analyzed, and can be specifically set according to actual requirements. For example, in a human following scene, the first image can be an image of a pedestrian obtained from the original video frame, and the second image can be an image of a specified target pedestrian. Features can be extracted from the first image and the second image respectively using the same feature extraction method, thereby obtaining a first global feature and at least one first local feature of the first image, and a second global feature and at least one second local feature of the second image. Wherein, the global feature is the feature of the entire image, and the local feature is the feature of a portion of the entire image.
[0045] It is worth noting that if the global and local features of the first or second image have already been obtained, they can be used directly without further feature extraction. For example, in a human tracking scenario, the image of the target pedestrian can be used as the second image, and the second global and second local features of the second image can be obtained in advance. In continuous human tracking, images of different pedestrians can be used as the first image, and then the first global and first local features of the current first image can be obtained through feature extraction. The second global and second local features of the second image can be obtained from the stored content, without having to repeat the feature extraction process on the second image multiple times.
[0046] Steps S110 and S120 can be executed simultaneously, or steps S110 can be executed first and then steps S120, or steps S120 can be executed first and then steps S110. The specific execution order can be determined according to actual needs.
[0047] Step S130: Calculate the similarity between each feature in the first global feature and the first local feature and each feature in the second global feature and the second local feature.
[0048] In this embodiment, for each feature in the first global feature and the first local feature of the first image, the feature similarity between that feature and each feature in the second global feature and the second local feature of the second image can be calculated pairwise. For example, if one first global feature and two first local features of the first image are obtained, and one second global feature and two second local features of the second image are also obtained, nine similarities can be calculated. Thus, the similarity between global features, the similarity between local features, and the similarity between global and local features can be calculated.
[0049] Optionally, when calculating the similarity between two features, the cosine similarity between the two features can be used to calculate the feature similarity. The formula for calculating cosine similarity is: cos(θ) represents the cosine similarity, a and b represent the feature vectors, and a|| and ||b|| represent the magnitudes of the feature vectors.
[0050] Step S140: Based on the obtained similarity, obtain the image similarity between the first image and the second image.
[0051] Based on the multiple similarities obtained in step S130, the image similarity between the first image and the second image is obtained. In this way, image similarity can be obtained based on the similarity between pairwise features in the global and local features of the image pair, avoiding the inaccurate measurement of the similarity between two images due to ignoring the effects of incomplete objects in the image.
[0052] Optionally, in this embodiment, the number of local features in an image can be set according to actual needs, such as 1, 2, 3, etc. As a possible implementation, to avoid omitting local features with obvious physical significance (e.g., omitting local features of the left half of a pedestrian's body), a first global feature of the first image can be obtained, and first local features corresponding to multiple image blocks in the first image can be obtained, wherein the multiple image blocks constitute the first image. That is, the first image is divided into multiple image blocks, and the local features of each image block are obtained, with one image block corresponding to one local feature. The specific division method of the multiple image blocks can be set according to actual needs. For example, the first image can be divided into multiple image blocks along a preset direction. Similarly, the second global feature and second local feature of the second image can be obtained in the same way.
[0053] Optionally, as a possible implementation, a preset feature extraction algorithm can be used to extract features from the first image to obtain the first global features of the first image, and to extract features from each image block of the first image to obtain the first local features of the first image.
[0054] Please refer to Figure 4 , Figure 4 for Figure 3 A flowchart illustrating the sub-steps included in step S110. As another possible implementation, step S110 may include sub-steps S111 to S113.
[0055] Sub-step S111: Obtain the first feature map of the first image through the first preset network.
[0056] The first preset network can be a backbone network. The first preset network can be a pre-trained network model. The first image can be input into the first preset network, and the output of the first preset network can be used as the first feature map of the first image. The first feature map includes high-level semantic features of the first image.
[0057] Sub-step S112: Extract the first global feature from the first feature map.
[0058] The first feature map can be input into a second preset network, and the output of the second preset network can be used as the first global feature of the first image. The second preset network can be a pre-trained network model. The second preset network can sequentially include: two convolutional layers, one pooling layer, and one fully connected layer.
[0059] Sub-step S113: Divide the first feature map into multiple first sub-feature maps, and extract the first local feature corresponding to each first sub-feature map from each first sub-feature map.
[0060] In this system, one first sub-feature map corresponds to one image patch. Similar to obtaining the first global feature, each first sub-feature map can be input into a preset network to obtain the first local feature corresponding to each first sub-feature map. The second feature map corresponding to the second image is divided in the same way as the first feature map; that is, the second feature map of the second image can be divided into multiple second sub-feature maps in the same manner, and the second local feature corresponding to each second sub-feature map can be obtained. In this way, the similarity between two images can be measured more robustly from the perspective of semantic alignment.
[0061] Optionally, the first image can be divided into multiple image blocks, and then the feature map corresponding to each image block can be obtained. Furthermore, the first global feature and the first local feature of the first image can be obtained based on the sub-feature map corresponding to each image block. Similarly, when extracting the second global feature and the second local feature of the second image, the same processing method as for the first image can be used: first, the second image can be divided into multiple image blocks, and then the feature map corresponding to each image block can be obtained. Furthermore, the image block division method for the second image is the same as that for the first image.
[0062] Optionally, the preset direction used to divide the multiple image blocks can be horizontal, vertical, or any other direction. The first image can be divided into multiple image blocks of the same or different sizes along the preset direction. For example, along the vertical direction, the first image can be divided into multiple image blocks in the horizontal direction according to the head, upper body, lower body, etc.
[0063] As one possible implementation, since it's uncertain which part of the object in the image is missing, and to ensure the physical meaning of each image block, the first image can be divided into multiple image blocks along either a horizontal or vertical direction. The number of these multiple image blocks is less than a preset value; for example, the multiple image blocks are two or three image blocks. For instance, the first image can be divided into two vertical regions along the horizontal direction, with each vertical region serving as one image block.
[0064] Alternatively, the first image can be divided into two equal image blocks along the horizontal direction, which can solve the problem of inaccurate calculation of image similarity caused by camera FOV limitations.
[0065] Given the global and local features of two images, the similarity between each feature of one image and each feature of the other image can be calculated. Then, the image similarity is obtained by processing based on these similarities. For example, a certain number of similarities can be selected from the obtained similarities in descending order, their average value can be calculated, and this average value can be used as the image similarity. The number of selected similarities is less than the total number of similarities obtained.
[0066] As one possible implementation, the maximum similarity among the obtained similarities can be selected and then used as the image similarity. This allows for a more accurate measurement of the similarity between two images.
[0067] The following is combined Figure 5To illustrate the above image processing method, we take the calculation of the similarity between two pedestrian images as an example. Given two pedestrian images I1 and I2 (one image is equivalent to the first image mentioned above, and the other image is equivalent to the second image mentioned above), the body region of pedestrian image I1 is relatively complete, while the body region of pedestrian image I2 is incomplete. Figure 5 In this context, "extract feature" means feature extraction, and "compute similarity" means calculating similarity.
[0068] Normal pass Figure 5 The similarity between the two pedestrian images is calculated as shown in section 'a'. First, feature maps I1 and I2 are extracted by Backbone, denoted as F1 and F2 respectively. Then, the global features of the image are obtained from feature maps F1 and F2, denoted as f1 and f2. Finally, the similarity s between f1 and f2 is calculated, which is the similarity between pedestrian images I1 and I2.
[0069] When extracting pedestrian image features using the above method, only global information of the image is considered. Therefore, the similarity s calculated by this method for the image pair composed of images I1 and I2 is often small. This is because f1 comes from a pedestrian image with a complete body region, while f2 comes from a pedestrian image with an incomplete body region, resulting in semantic misalignment between the two features.
[0070] The image processing method provided in this application's embodiments considers both global and local features simultaneously, enabling a more reasonable calculation of the similarity between image pairs. This method... Figure 5 The similarity between the two pedestrian images is calculated as shown in b.
[0071] First, extract the feature maps of the pedestrian images: I1 and I2 feature maps are extracted by Backbone and denoted as F1 and F2 respectively.
[0072] Secondly, global features of pedestrian images are extracted: features of pedestrian images I1 and I2 are extracted from feature maps F1 and F2, respectively, and denoted as f1 and f2. Here, f1 represents the global features of pedestrian image I1, and f2 represents the global features of pedestrian image I2.
[0073] Next, local features of the pedestrian image are extracted: the feature map F1 is divided into two vertical regions along the horizontal direction, and local features f1 are extracted from the two regions respectively. l and F1 r The feature map F2 is then divided into two vertical regions along the horizontal direction, and local features are extracted from each region. and That is, the feature map is divided into left and right parts, and the corresponding local features are obtained from each part of the feature map.
[0074] Then, calculate the similarity matrix S∈R of the global and local features of the two pedestrian images. 3×3 Each element of S represents three features (f1, f2, f3) of the pedestrian image I1. l f1 r ) and the three features of pedestrian image I2 (f2, The similarity between pairs of objects. For example, S 11 S represents the similarity of global features f1 and f2 between two pedestrian images; 12 Represents the global features f1 of pedestrian image I1 and the local features of pedestrian image I2. The similarity between them.
[0075] Among them, the three features of pedestrian image I1 (f1, f1) l f1 r ) and the three features of pedestrian image I2 (f2, The dimensions can be consistent, for example, 1×256, to facilitate the calculation of the similarity between global and local features, thereby obtaining the similarity matrix.
[0076] Finally, the similarity matrix S∈R 3×3 The maximum value among the nine elements is selected as the similarity between pedestrian images I1 and I2.
[0077] The characteristics of image similarity obtained under various conditions using this method are explained below.
[0078] Case 1: When both pedestrian image I1 and pedestrian image I2 are pedestrian images with complete body regions, such as Figure 1 For the image pair shown in (a), the image similarity calculated based on global and local features can be one of two cases: the image similarity is the similarity of global features I1 and I2, or the image similarity is the similarity of a pair of local features (when the similarity of local features is higher), such as f1. l and At this point, the similarity calculation method based on global features and local features is slightly better than the similarity calculation method based on global features.
[0079] Case 2: When one of I1 and I2 is a pedestrian image with a complete body region and the other is a pedestrian image with an incomplete body region, such as... Figure 1 In the image pair shown in (b), the similarity calculation method based on global and local features will select the local feature f1 of the left half of I1's body. lThe similarity between I1 and I2 is calculated using the global feature f2 of I2 as the image similarity between I1 and I2, because the left half of I1 and the entire region of I2 are semantically aligned. In contrast, the similarity calculation method based on global features directly uses the similarity between the global features of I1 and I2 as the image similarity between I1 and I2, which lacks robustness.
[0080] Case 3: When both I1 and I2 are pedestrian images with incomplete body regions, but originate from the same body region (e.g., both from the left half of the body), it is similar to Case 1.
[0081] Scenario 4: When both I1 and I2 are pedestrian images with incomplete body regions, but originating from different body regions (e.g., I1 from the left half of the body and I2 from the right half), neither the method based on global information nor the method based on both global and local information proposed in this application can accurately calculate the semantic alignment similarity. However, due to the symmetry of the pedestrian's body, the global features of I1 and I2 still have a high degree of similarity in this case.
[0082] Therefore, the image similarity calculation method based on global and local information proposed in this application is more robust and can more accurately measure the similarity between two images, especially when there is semantic misalignment between the two images.
[0083] Please refer to Figure 6 , Figure 6 This is a second schematic flowchart of the image processing method provided in this application embodiment. In this embodiment, the first image and the second image are pedestrian images, and after step S140, the method may further include step S150.
[0084] Step S150: Perform pedestrian re-identification based on the image similarity.
[0085] Having obtained the image similarity of two pedestrian images, it can be determined whether the image similarity is greater than a preset similarity. If it is greater than or equal to a preset similarity, the pedestrian in the two images can be considered to be the same pedestrian; if it is less than a preset similarity, the pedestrian in the two images can be considered to be different pedestrians. This completes pedestrian re-identification. After performing complete pedestrian re-identification based on the current image, new image pairs can be determined, and then steps S110 to S150 above can be repeated until the pedestrian re-identification task is completed.
[0086] Optionally, in other vision-related tasks, such as face recognition, image retrieval (e.g., pedestrian image retrieval), and fine-grained image analysis, the image similarity can be obtained through the above steps S110 to S140, and then face recognition, image retrieval, etc. can be performed based on the image similarity.
[0087] To perform the corresponding steps in the above embodiments and various possible methods, an implementation of the image processing apparatus 200 is given below. Optionally, the image processing apparatus 200 can adopt the above-described... Figure 2 The device structure of the electronic device 100 shown. Further, please refer to... Figure 7 , Figure 7 This is a block diagram of the image processing apparatus 200 provided in this embodiment. It should be noted that the image processing apparatus 200 provided in this embodiment has the same basic principle and technical effects as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments. The image processing apparatus 200 may include: a feature acquisition module 210, a calculation module 220, and a processing module 230.
[0088] The feature acquisition module 210 is used to acquire the first global feature and the first local feature of the first image.
[0089] The feature acquisition module 210 is also used to acquire the second global features and the second local features of the second image.
[0090] The calculation module 220 is used to calculate the similarity between each feature in the first global feature and the first local feature and each feature in the second global feature and the second local feature.
[0091] The processing module 230 is used to obtain the image similarity between the first image and the second image based on the obtained similarity.
[0092] Optionally, in this embodiment, the processing module 230 is specifically used to: obtain the maximum similarity among the similarities as the image similarity.
[0093] Optionally, in this embodiment, the first image and the second image are pedestrian images, and the processing module 230 can also be used to: perform pedestrian re-identification based on the image similarity.
[0094] Optionally, the above modules can be stored in the form of software or firmware. Figure 2 The memory 110 shown is either stored in or embedded in the operating system (OS) of the electronic device 100, and can be used by... Figure 2 The processor 120 executes the program. Meanwhile, the data and program code required to execute the above modules can be stored in the memory 110.
[0095] This application also provides a readable storage medium storing a computer program thereon, which, when executed by a processor, implements the image processing method described above.
[0096] In summary, embodiments of this application provide an image processing method, apparatus, electronic device, and readable storage medium. First, the similarity between each feature in the first global features and first local features of a first image and each feature in the second global features and second local features of a second image is calculated pairwise. Then, the image similarity between the first image and the second image is obtained based on the obtained similarity. In this way, image similarity can be obtained based on the similarity between pairwise features in the global and local features of an image pair, avoiding the inaccurate measurement of the similarity between two images due to ignoring the effects of incomplete objects in the image.
[0097] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0098] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0099] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0100] The above description is merely an optional embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. An image processing method, characterized in that, The method includes: Obtain the first global feature and the first local feature of the first image; Obtain the second global feature and the second local feature of the second image; The similarity between each feature in the first global feature and the first local feature and each feature in the second global feature and the second local feature is calculated; Based on the obtained similarity, the image similarity between the first image and the second image is obtained.
2. The method according to claim 1, characterized in that, The process of obtaining the first global feature and the first local feature of the first image includes: A first global feature of the first image is obtained, and a first local feature corresponding to each of the multiple image blocks in the first image is obtained, wherein the multiple image blocks constitute the first image.
3. The method according to claim 2, characterized in that, The step of obtaining the first global feature of the first image and obtaining the first local feature corresponding to each of the multiple image patches in the first image includes: A first feature map of the first image is obtained through a first preset network, wherein the first feature map includes high-level semantic features of the first image; The first global feature is extracted from the first feature map; The first feature map is divided into multiple first sub-feature maps, and the first local features corresponding to each first sub-feature map are extracted from each first sub-feature map. Each first sub-feature map corresponds to one image block. The second feature map corresponding to the second image is divided in the same way as the first feature map.
4. The method according to claim 2, characterized in that, The plurality of image blocks are obtained by dividing the first image equally along the horizontal or vertical direction.
5. The method according to any one of claims 1-4, characterized in that, The step of obtaining the image similarity between the first image and the second image based on the obtained similarity includes: The maximum similarity among the aforementioned similarities will be used as the image similarity score.
6. The method according to claim 5, characterized in that, The first and second images are pedestrian images, and the method further includes: Based on the image similarity, pedestrian re-identification is performed.
7. An image processing apparatus, characterized in that, The device includes: The feature acquisition module is used to acquire the first global feature and the first local feature of the first image; The feature acquisition module is further configured to acquire the second global features and the second local features of the second image; The calculation module is used to calculate the similarity between each feature in the first global feature and the first local feature and each feature in the second global feature and the second local feature; The processing module is used to obtain the image similarity between the first image and the second image based on the obtained similarity.
8. The apparatus according to claim 7, characterized in that, The processing module is specifically used for: The maximum similarity among the aforementioned similarities will be used as the image similarity score.
9. An electronic device, characterized in that, It includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the image processing method according to any one of claims 1-6.
10. A readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the image processing method as described in any one of claims 1-6.
Citation Information
Patent Citations
Image processing method and device and electronic equipment
CN112329889A