Image processing method and device, storage medium and electronic device

By scaling and reducing the target image, the problem of unclear display after the target image is merged with the background image is solved, thus improving the efficiency of the target detection training set.

CN115829889BActive Publication Date: 2025-08-19GUANGZHOU KUGOU COMP TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111088393.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-16
Publication Date
2025-08-19
Estimated Expiration
2041-09-16

AI Technical Summary

Technical Problem

When creating a training set for object detection, the target image becomes unclear after being fused with the background image, resulting in reduced detection efficiency.

Method used

The second texture image is obtained by scaling the first texture image according to the first preset ratio. The target scaling factor is determined according to the product of the first scaling factor and the aspect ratio of the first texture image. The second texture image is scaled down and adjusted until the preset clarity is achieved. Then it is merged with the first image.

Benefits of technology

This method preserves the sharpness of the target image after fusing it with the background image, thus improving the efficiency of creating a target detection training set.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115829889B_ABST
    Figure CN115829889B_ABST
Patent Text Reader

Abstract

The present invention discloses an image processing method and device, a storage medium, and an electronic device. The method includes: scaling a first texture image according to a first preset ratio to obtain a second texture image; processing the first image to a second preset aspect ratio to obtain a second image; further processing the second texture image to the first preset aspect ratio to obtain a third texture image; further fusing the third texture image with the second image, and then reducing the third texture image to a reduction factor that achieves a preset clarity; determining a target reduction coefficient by multiplying the first reduction coefficient and the aspect ratio of the first texture image; and reducing and adjusting the second texture image according to the target reduction coefficient to obtain a fourth texture image; and fusing the fourth texture image into the first image to obtain a fused image. The present invention solves the technical problem of unclear display of a target image after fusion with a background image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to an image processing method and device, a storage medium, and an electronic device. Background Art

[0002] In the process of using known objects to be detected and a large number of unlabeled images to create a target detection training set, the target image (such as a logo) is usually pasted on background images of various sizes and dimensions. However, the target images and background images are of various types. Usually, the background images in actual scenes are of different sizes, lengths and widths, and the size, aspect ratio, and content richness of the target category images are also diverse. In addition, the image area changes caused by rotation. When the target image is pasted on the background image, the target image will be smaller in size, resulting in the problem of being unable to recognize the display information of the target image. Moreover, when the image data after the fusion of the above target image and the background image is sent to the target detection network for training, it will also cause many false detections, reducing the detection efficiency of the target object.

[0003] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention

[0004] Embodiments of the present invention provide an image processing method and apparatus, a storage medium, and an electronic device to at least solve the technical problem that a target image is not displayed clearly after being fused with a background image.

[0005] According to one aspect of an embodiment of the present invention, there is provided an image processing method, comprising: acquiring a first image and a first texture image; enlarging the first texture image according to a first preset ratio to obtain a second texture image; wherein the long side of the second texture image is less than or equal to the short side of the first image; determining a target reduction coefficient based on the product of a first reduction coefficient and the aspect ratio of the first texture image; the first reduction coefficient comprising: after fusing a third texture image with the second image, reducing the third texture image to a reduction factor at which the third texture image reaches a preset clarity; the third texture image is obtained by processing the second texture image into a first preset aspect ratio; the second image is obtained by processing the first image into a second preset aspect ratio; reducing and adjusting the second texture image according to the target reduction coefficient to obtain a fourth texture image; and fusing the fourth texture image into the first image to obtain a fused image.

[0006] According to another aspect of an embodiment of the present invention, an image processing device is also provided, including: a first acquisition unit, used to acquire a first image and a first texture image; a first scaling unit, used to enlarge the first texture image according to a first preset ratio to obtain a second texture image; wherein the long side of the second texture image is less than or equal to the short side of the first image; a fusion determination unit, used to determine a target reduction coefficient based on the product of a first reduction coefficient and the aspect ratio of the first texture image; the first reduction coefficient includes: after fusing the third texture image with the second image, reducing it to a reduction multiple that the third texture image reaches a preset clarity; the third texture image is obtained by processing the second texture image into the first preset aspect ratio; the second image is obtained by processing the first image into the second preset aspect ratio; a first adjustment unit, used to reduce and adjust the second texture image according to the target reduction coefficient to obtain a fourth texture image; and a fusion unit, used to fuse the fourth texture image into the first image to obtain a fused image.

[0007] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the above-mentioned image processing method when running.

[0008] According to another aspect of an embodiment of the present invention, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the image processing method through the computer program.

[0009] In an embodiment of the present invention, a first texture image is scaled according to a first preset ratio to obtain a second texture image; the first image is processed into a second preset aspect ratio to obtain a second image, and the second texture image is processed into the first preset aspect ratio to obtain a third texture image, and the third texture image is further fused with the second image and then reduced to a reduction factor at which the third texture image achieves a preset clarity; the target reduction coefficient is determined by multiplying the first reduction coefficient and the aspect ratio of the first texture image, and the second texture image is reduced and adjusted according to the target reduction coefficient to obtain a fourth texture image, and the fourth texture image is fused into the first image to obtain a fused image, thereby achieving the purpose of ensuring the clarity of the target image after the target image is fused with the background image, thereby achieving the technical effect of avoiding unclear display of the target image after the target image and the background image are fused, and improving the efficiency of producing the target detection training set, thereby solving the technical problem of unclear display of the target image after the target image and the background image are fused. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0011] Figure 1 is a schematic diagram of an application environment of an optional image processing method according to an embodiment of the present application;

[0012] Figure 2 is a schematic diagram of an application environment of another optional image processing method according to an embodiment of the present application;

[0013] Figure 3 is a flowchart of an optional image processing method according to an embodiment of the present application;

[0014] Figure 4 is a target detection image according to an optional image processing method of an embodiment of the present application;

[0015] Figure 5 is a schematic diagram of image scaling according to an optional image processing method of an embodiment of the present application;

[0016] Figure 6 is a schematic diagram of image scaling according to another optional image processing method according to an embodiment of the present application;

[0017] Figure 7 is a schematic diagram of image fusion according to another optional image processing method of an embodiment of the present application;

[0018] Figure 8 is a schematic diagram of a map display according to an optional image processing method of an embodiment of the present application;

[0019] Figure 9 is a schematic diagram of a map display according to another optional image processing method of an embodiment of the present application;

[0020] Figure 10 is a schematic diagram of a map display according to another optional image processing method of an embodiment of the present application;

[0021] Figure 11 is a schematic diagram of a map display according to another optional image processing method of an embodiment of the present application;

[0022] Figure 12 is a schematic structural diagram of an optional image processing device according to an embodiment of the present application;

[0023] Figure 13 It is a schematic structural diagram of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0024] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.

[0025] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0026] In the embodiments of this application, the following technical terms may be used, but are not limited to:

[0027] Object detection: Finding all objects in an image and determining their categories and locations—addressing the two questions of "where and what?"—is a core problem in computer vision. This involves not only identifying the type of object in an image but also identifying its location.

[0028] False detection rate: Assume there are 1000 images without targets, but x images are detected, then the false detection rate is x / 1000.

[0029] According to one aspect of an embodiment of the present invention, an image processing method is provided. Optionally, as an optional implementation, the image processing method can be applied to, but is not limited to, Figure 1The hardware environment shown in FIG. This hardware environment includes: a terminal device 102 for human-computer interaction with a user, a network 104, and a server 106. A user 108 can interact with the terminal device 102, and an image processing application client runs on the terminal device 102. The terminal device 102 includes a human-computer interaction screen 1022, a processor 1024, and a memory 1026. The human-computer interaction screen 1022 is used to present a first image, a first textured image, a second textured image, and also to present a fused image; the processor 1024 is used to generate an image adjustment request, wherein the image adjustment request carries the first image and the first textured image; and the memory 108 is used for the first image, the first textured image, the second textured image, and also to store the fused image.

[0030] In addition, the server 106 includes a database 1062 and a processing engine 1064. The database 1062 is used to store the first image, the first texture image, the second texture image, and the fused image. The processing engine 1064 is configured to scale the first texture image according to a first preset ratio to obtain a second texture image; process the first image to a second preset aspect ratio to obtain a second image; further process the second texture image to the first preset aspect ratio to obtain a third texture image; further fuse the third texture image with the second image, and then reduce the third texture image to a reduction factor that achieves a preset clarity for the third texture image; then determine a target reduction factor by multiplying the first reduction factor by the aspect ratio of the first texture image; reduce and adjust the second texture image according to the target reduction factor to obtain a fourth texture image; and fuse the fourth texture image into the first image to obtain a fused image.

[0031] The specific process is as follows: Assume that Figure 1 An image processing application client is running in the terminal device 102 shown, and the user 108 operates the human-computer interaction screen 1022 to manage and operate the first image and the second image, such as steps S102-S104, to obtain an image adjustment request, which is used to request adjustment of the first image and the first map image; and send the image adjustment request to the server 106 via the network 104.

[0032] In steps S106-S112, the first texture image is scaled according to a first preset ratio to obtain a second texture image; the first image is processed to a second preset aspect ratio to obtain a second image; the second texture image is further processed to the first preset aspect ratio to obtain a third texture image; the third texture image is further fused with the second image and scaled down to a reduction factor that achieves a preset clarity for the third texture image; a target reduction factor is then determined by multiplying the first reduction factor by the aspect ratio of the first texture image; the second texture image is scaled down according to the target reduction factor to obtain a fourth texture image; the fourth texture image is fused into the first image to obtain a fused image. Furthermore, in steps S114-S116, the terminal device 102 is notified via the network 104, and the fused image is returned.

[0033] As another optional implementation, the above image processing method of the present application can be applied to Figure 2 In. Figure 2 As shown, human-computer interaction can be performed between user 202 and terminal device 204. User device 204 includes memory 206 and processor 208. In this embodiment, terminal device 204 can, but is not limited to, perform the operations performed by the terminal device 102 to obtain a fused image.

[0034] Optionally, the terminal devices 102 and 204 may be, but are not limited to, mobile phones, tablet computers, laptop computers, PCs, and the like. The network 104 may include, but is not limited to, a wireless network or a wired network. Wireless networks include Wi-Fi and other networks that enable wireless communication. Wired networks may include, but are not limited to, wide area networks, metropolitan area networks, and local area networks. The server 106 may include, but is not limited to, any hardware device capable of computing.

[0035] Optionally, the terminal device 102 and the terminal device 204 can be terminal devices configured with a target server, which can include but are not limited to at least one of the following: mobile phones (such as Android phones, iOS phones, etc.), laptops, tablet computers, PDAs, MIDs (Mobile Internet Devices), PADs, desktop computers, smart TVs, etc. The target client can be a video client, an instant messaging client, a browser client, an education client, etc. The target server can be a video server, an instant messaging server, a browser server, an education server, etc. The network 104 can include but is not limited to: a wired network, a wireless network, wherein the wired network includes: a local area network, a metropolitan area network and a wide area network, and the wireless network includes: Bluetooth, WIFI and other networks that realize wireless communication. The server 106 can be a single server, or a server cluster composed of multiple servers, or a cloud server. The above is only an example, and this embodiment does not impose any limitation on this.

[0036] In one or more embodiments, Figure 3 As shown, the above image processing method includes:

[0037] S302, obtaining a first image and a first mapping image;

[0038] S304: Enlarging the first image according to a first preset ratio to obtain a second image; wherein the long side of the second image is smaller than or equal to the short side of the first image;

[0039] S306: Determine a target reduction factor based on the product of the first reduction factor and the aspect ratio of the first texture image; the first reduction factor includes: a reduction factor for reducing the third texture image to a preset resolution after fusing the third texture image with the second image; the third texture image is obtained by processing the second texture image to the first preset aspect ratio; and the second image is obtained by processing the first image to the second preset aspect ratio.

[0040] S308, scaling down the second texture image according to the target scaling factor to obtain a fourth texture image;

[0041] S310: Fusing the fourth texture image into the first image to obtain a fused image.

[0042] In step S302, in actual application, the first image can be various background images of different sizes or dimensions, or can be images of various picture types, such as images in jpg, bmp, gif and other formats, without any limitation here. Scaling the first image according to a preset ratio to obtain a scaled image can facilitate the input of the target detection network for training to have a uniform size and dimension, thereby improving the efficiency of the target detection network in processing images (or it can be understood that the first image is a scaled image obtained by scaling according to a preset ratio). Figure 4 As shown, the training image 400 is an image of a preset size with a long side size of 640, which facilitates the target detection network to detect the target object 402 in the training image 400; Figure 5 As shown, the aspect ratio of the first image 502 is 9:5, and the long side of the first image 502 is 720 mm. After the first image 502 is resized with the aspect ratio unchanged, a scaled image 504 (second image) of 640*400 is obtained.

[0043] In step S304, in actual application, the first image can be various logo or label images of different sizes or dimensions, or can be images of various picture types, such as images in jpg, bmp, gif, etc., without any limitation. The first image is scaled according to a first preset ratio to obtain a size smaller than the second image; Figure 6 As shown, the size of the first texture image 602 is 20*10; the first texture image 602 is enlarged in a manner that keeps the aspect ratio unchanged, and after the long side is enlarged to 640, the short side is correspondingly changed to 320, and a second texture image 604 of 640*320 size can be obtained.

[0044] In steps S306-S308, in actual application, the second texture image is scaled down according to the target scale-down coefficient determined by multiplying the first scale-down coefficient by the aspect ratio of the first texture image to obtain a fourth texture image. For example, Figure 5 The first image 502 in the image is processed into a second preset aspect ratio to obtain a scaled image 504 (second image), and then Figure 6 The second texture image 604 in the image is processed into the first preset aspect ratio to obtain a third texture image, and the third texture image is further fused with the second image and then reduced to a reduction factor that achieves a preset definition of the third texture image; and then the first reduction coefficient and the Figure 6 The target reduction coefficient is determined by multiplying the aspect ratio of the first texture image 602 in the image 600 by the target reduction coefficient, and the scaled image 504 (second image) is obtained according to the target reduction coefficient. Figure 6 The second texture image 604 in the image is scaled down to obtain a fourth texture image, and the fourth texture image is fused into Figure 5 From the first image 502 in , a fused image is obtained.

[0045] Specifically, optionally Figure 6 The second texture image 604 in Figure 5 In the scaled image 504 (second image), when the first scaling factor is determined to be 0.1, the size of the first texture image 602 is 20*10 and the aspect ratio is 2. The size of the second texture image 604 can be multiplied by the first scaling factor and the aspect ratio of the second texture image 604 to obtain a third texture image 606 of size 128*64. It should be noted that the first scaling factor is the value obtained by reducing the second scaled image with an aspect ratio of 1 by fusing it to the scaled image 504 (second image) with an aspect ratio of 1, and then reducing it. The first scaling factor is typically determined by the value obtained by whr / 28, where whr is the aspect ratio of the image. The target scaling factor is determined based on the product of the first scaling factor and the aspect ratio of the first texture image.

[0046] In steps S308-S310, in actual application, the second texture image is scaled down according to the target scaling factor to obtain a fourth texture image; the fourth texture image is fused into the first image to obtain a fused image; Figure 7 As shown, the fourth texture image 704 is fused into the first image 702 to obtain a fused image 700 , and the fourth texture image 704 can be displayed clearly.

[0047] In an embodiment of the present invention, a first texture image is scaled according to a first preset ratio to obtain a second texture image; the first image is processed into a second preset aspect ratio to obtain a second image, and the second texture image is processed into the first preset aspect ratio to obtain a third texture image, and the third texture image is further fused with the second image and then reduced to a reduction factor at which the third texture image achieves a preset clarity; the target reduction coefficient is determined by multiplying the first reduction coefficient and the aspect ratio of the first texture image, and the second texture image is reduced and adjusted according to the target reduction coefficient to obtain a fourth texture image, and the fourth texture image is fused into the first image to obtain a fused image, thereby achieving the purpose of ensuring the clarity of the target image after the target image is fused with the background image, thereby achieving the technical effect of avoiding unclear display of the target image after the target image and the background image are fused, and improving the efficiency of producing the target detection training set.

[0048] As an optional solution, determining the target reduction coefficient based on the product of the first reduction coefficient and the aspect ratio of the first map image includes:

[0049] S1, determining a content parameter of a first texture image, where the content parameter is used to indicate the total number of pixels included in the first texture image after binarization processing;

[0050] S2, determining a scaling factor level according to the pixel sum, wherein each scaling factor level corresponds to a second scaling factor;

[0051] S3, determining a second scaling factor corresponding to the first texture image according to the scaling factor level;

[0052] S4, determining a target reduction coefficient according to the first reduction coefficient, the second reduction coefficient, and the aspect ratio of the first image.

[0053] For example, combined with Figure 6 To illustrate, assume Figure 6 The second binarized texture image 604 in the image is a black and white image, including a LOGO edge image with a white edge, and the total number of pixels is 300. When other characters are added to the second texture image 604, the total number of pixels of different colors is 900. Therefore, the second scaling factor corresponding to the total number of pixels of 300 can be set to 1, and the second scaling factor corresponding to the total number of pixels of 900 can be set to 3. The second scaled image is adjusted according to the first scaling factor, the second scaling factor and the aspect ratio of the second image to obtain the first adjusted image. Assuming that Figure 6 The second texture image 604 in Figure 5 In the first scaled image in , it is determined that when the first scaling factor is 0.1 and the second scaling factor is 3, the size of the first texture image 602 is 20*10 and the aspect ratio is 2. The size of the second texture image 604 can be multiplied by the first scaling factor, the second scaling factor and the aspect ratio of the second texture image 604 to obtain the size of the third texture image 606 as 384*192.

[0054] As an optional solution, determining the target reduction coefficient according to the first reduction coefficient, the second scaling coefficient, and the aspect ratio of the first image includes:

[0055] S1, when it is determined that the second texture image has been rotated and adjusted, determining a ratio of the areas of the second texture image after rotation to the areas of the second texture image before rotation as a third scaling factor;

[0056] S2: Determine a target scaling factor based on the first scaling factor, the second scaling factor, the third scaling factor, and the aspect ratio of the first map image.

[0057] For example, suppose Figure 6The second image 604 in the image is rotated and adjusted, and the ratio of the area of the second scaled image after rotation to the area of the second image before rotation is determined as the third scaling factor. The rotation here can be a rotation in two-dimensional space or a rotation in three-dimensional space. For example, if the ratio of the area of the second image 604 to the area before rotation is 1.5, then 1.5 can be determined as the third scaling factor. Assume that Figure 6 The second texture image 604 in Figure 5 In the first scaled image in , it is determined that when the first scaling factor is 0.1 and the second scaling factor is 3, the first scaling factor is 0.1, the size of the first texture image 602 is 10*20, and the aspect ratio is 2. The size of the second texture image 604 can be multiplied by the first scaling factor, the second scaling factor, the third scaling factor and the aspect ratio of the second texture image 604 to obtain the size of the third texture image 606 as 576*258.

[0058] As an optional solution, before obtaining the first image and the first texture image, the method further includes:

[0059] S1, obtaining a first original image;

[0060] S2: scaling the long side of the first original image to a preset length, and adjusting the short side of the first original image accordingly according to the aspect ratio of the first original image, to obtain a first image.

[0061] For example, the aspect ratio of the first original image is 9:5; the long side of the first original image is 720 mm. The first original image is scaled and adjusted to a size that keeps the aspect ratio unchanged, and the long side becomes 640, corresponding to the short side being 400, so a first image of 640*400 size can be obtained.

[0062] As an optional solution, determining the content parameters of the first texture image includes:

[0063] Binarize the first texture image to obtain a binary image corresponding to the first texture image;

[0064] The sum of the pixels in the binary image is used as the content parameter.

[0065] It should be noted here that if Figure 6As shown, the edges of the second texture image 604 are extracted to obtain a binary image, and then the sum of the pixels of the binary image is calculated. The richer the content and the more edges of the second texture image 604, the larger the pixel sum. Here, after determining the number of pixels contained in the binary image for multiple second scaled images of different sizes or types, the images can be divided into n levels based on their size. Each level has a different second scaling factor a. For example, the image can be divided into 5 levels. The higher the level, from 1 to 5, the richer the content of the image. For a level 1 image, the second scaling factor a is 1, for a level 2 image, the second scaling factor a is 1.5, and for a level 5 image, the second scaling factor a is 3.

[0066] As an optional solution, scaling the first texture image according to a first preset ratio to obtain a second texture image includes:

[0067] The long side of the first texture image is enlarged to be the same size as the short side of the first image, and the short side of the first texture image is adjusted accordingly according to the aspect ratio of the first texture image to obtain a second texture image.

[0068] It should be noted that in the embodiment of the present application, the initial scaling factor is whr / 28, where whr represents the aspect ratio of the base image, and 28 is an empirical value. The standard for setting the initial scaling factor is: a logo with an aspect ratio of 1 is pasted on a base image with a different aspect ratio, and it can be seen clearly after being scaled down by x times. This x is the initial scaling factor.

[0069] Therefore, the reduction factor of the preset definition may be 28. The step of reducing the second scaled image fused with the first scaled image to achieve the reduction factor of the preset definition includes determining the first scale factor based on a ratio of an aspect ratio of the second scaled image to 28.

[0070] Assuming that the ratio of the area of the second texture image 604 to the area before rotation is 1.5, then 1.5 can be determined as the third scaling factor. Figure 6 The second texture image 604 in Figure 5 In the scaled image 504 (second image), it is determined that when the first scaling factor is 1 / 14 and the second scaling factor is 3, the first scaling factor is 0.1, the size of the first texture image 602 is 10*20, and the aspect ratio is 2. The size of the second texture image 604 can be multiplied by the first scaling factor, the second scaling factor, the third scaling factor and the aspect ratio of the second texture image 604 to obtain the size of the third texture image 606 as 411*184.

[0071] According to the embodiments provided herein, after a second scaled image with an aspect ratio of 1 is fused to a first scaled image with an aspect ratio of 1 and scaled down, the first scaling factor is determined based on the reduction factor required to achieve a preset definition for the second scaled image. This avoids the problem of unclear display of the target image after fusion of the target image and the background image, thereby improving the efficiency of target object recognition.

[0072] In one or more embodiments, the above-mentioned step S304, scaling the first texture image according to the first preset ratio to obtain the second texture image, includes: enlarging the long side of the first texture image to the same size as the short side of the first image, and adjusting the short side of the first texture image according to the aspect ratio of the first texture image to obtain the second texture image.

[0073] For example, Figure 5 As shown, the size of the zoomed image 504 (second image) is 640*400; Figure 6 As shown, assuming that the aspect ratio of the first texture image 602 is 2:1; the size of the first image is 20*10, the long side of the first texture image 602 is enlarged to the same size as the short side of the second image, and the short side of the first image is adjusted accordingly according to the aspect ratio of the first image, and the size of the second texture image is obtained to be 400*200.

[0074] According to the embodiments provided in the present application, the second image is obtained by enlarging the long side of the first image to the same size as the short side of the first image and adjusting the short side of the first image according to the aspect ratio of the first image. This can further avoid the problem that the label image exceeds the background image after being enlarged, resulting in the loss of part of the label image after the label image and the background image are merged. Based on the above embodiments, in one or more embodiments, when the aspect ratio of the base image (i.e., the background image) is different, pasting the same logo in the same ratio will cause some to be clear and some to be blurred and unrecognizable, such as Figure 8 As shown, the aspect ratio of background image 802 is 2.5, the aspect ratio of background image 804 is 1, and the aspect ratio of background image 806 is 2.9. It can be seen that only label image 804a on background image 804 is relatively clear, while label image 802a and label image 806a are relatively blurred.

[0075] Based on the above embodiments, in one or more embodiments, if the base image has the same aspect ratio, and logos with different aspect ratios are pasted at the same ratio, some logos may be clear while others may be blurry and unrecognizable; Figure 9 As shown, in the base image 900 , the first label image 902 (the Weibo logo) is relatively clear, while the logo of the second label image 904 is very small and cannot be displayed clearly.

[0076] Based on the above embodiments, in one or more embodiments, for example, Figure 10 In the figure, the base map 1000 has the same aspect ratio, and label images with different content richness are pasted in the same ratio. The first label image 1002 (low content richness) is very clear, while the second label image 1004 (high content richness) is very blurry. Therefore, under the same base map, some label images are clear while some are blurry and unrecognizable.

[0077] Based on the above embodiments, in one or more embodiments, the base image has the same aspect ratio, and the same logo is pasted in the same proportion, but rotating the image will also cause some images to be clear and some to be blurred and unrecognizable; Figure 11 As shown, in the base image 1100 , the first label image 1102 is clearly visible. When the first label image 1102 is rotated to become the rotated label image 1104 , the specific content of the rotated label image 1104 is no longer visible due to the different rotation angles.

[0078] Based on the above embodiments, in one or more embodiments, in order to solve the above technical problems, the embodiments of the present application provide an image processing method, including the following steps:

[0079] S1. Since base images vary in size, ranging from tens to thousands of pixels, they are first scaled to the same size. For example, the longest side is scaled to 640, and the shorter side is scaled according to the actual aspect ratio, which means that the aspect ratio of the image itself is not changed. To ensure that logos of different sizes can be obtained, in the application example, the logo is first scaled. The scaling criteria are: the logo area is as close as possible to the area of the base image, but the length and width of the logo must not exceed the length and width of the base image, and the aspect ratio of the logo itself cannot be changed.

[0080] S2, then specify the initial scaling factor as whr / 28, where whr represents the aspect ratio of the base map and 28 is an empirical value. The standard setting is: if a simple logo with an aspect ratio of 1 is pasted on a base map with an aspect ratio of 1, it can be seen clearly after being scaled down x times. whr / x is the initial scaling factor.

[0081] S3 calculates the content richness of the logo. For logos with richer content, the initial reduction factor needs to be multiplied by a coefficient a. Content richness is measured by extracting the logo's edges to create a binary image. The sum of the pixels in this binary image is then calculated. The richer the content and the more edges, the larger this value. After calculating the content richness of all logos, they can be divided into n levels based on their size. Each level has a different coefficient a. For example, if the content richness is divided into five levels, with levels 1 to 5 becoming increasingly rich, the coefficient a for logos in level 1 is 1, for logos in level 2 it is 1.5, and for logos in level 5 it is 3.

[0082] S4, calculate the aspect ratio b of the unrotated logo, and then multiply it by the initial reduction factor.

[0083] S5. If the logo is rotated, record the area before and after rotation, obtain the area ratio (after rotation / before rotation) c, and then multiply it by the initial reduction factor.

[0084] In step S6, the final scaling factor of the logo is factor*a*b*c, where factor is the initial scaling factor. Finally, the fused image obtained after scaling can be input into the target detection training set to obtain a clear target image.

[0085] It should be noted that for the aforementioned method embodiments, for simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should be aware that the present invention is not limited by the order of the actions described, because according to the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0086] According to another aspect of the embodiments of the present invention, an image processing device for implementing the above image processing method is also provided. Figure 12 As shown, the device includes:

[0087] A first acquiring unit 1202 is configured to acquire a first image and a first texture image;

[0088] A first scaling unit 1204 is configured to amplify the first image according to a first preset ratio to obtain a second image; wherein the longer side of the second image is smaller than or equal to the shorter side of the first image;

[0089] The fusion determination unit 1206 is configured to determine a target reduction factor based on the product of the first reduction factor and the aspect ratio of the first texture image; the first reduction factor includes: a reduction factor that reduces the third texture image to a predetermined resolution after the third texture image is fused with the second image; the third texture image is obtained by processing the second texture image to the first predetermined aspect ratio; and the second image is obtained by processing the first image to the second predetermined aspect ratio.

[0090] A first adjustment unit 1208 is configured to reduce the second texture image according to a target reduction coefficient to obtain a fourth texture image;

[0091] The fusion unit 1210 is configured to fuse the fourth map image into the first image to obtain a fused image.

[0092] For specific embodiments, reference may be made to the examples shown in the above-mentioned method for dynamic region adjustment, which will not be described in detail in this example.

[0093] In an embodiment of the present invention, a first texture image is scaled according to a first preset ratio to obtain a second texture image; the first image is processed into a second preset aspect ratio to obtain a second image, and the second texture image is processed into the first preset aspect ratio to obtain a third texture image, and the third texture image is further fused with the second image and then reduced to a reduction factor at which the third texture image achieves a preset clarity; the target reduction coefficient is determined by multiplying the first reduction coefficient and the aspect ratio of the first texture image, and the second texture image is reduced and adjusted according to the target reduction coefficient to obtain a fourth texture image, and the fourth texture image is fused into the first image to obtain a fused image, thereby achieving the purpose of ensuring the clarity of the target image after the target image is fused with the background image, thereby achieving the technical effect of avoiding unclear display of the target image after the target image and the background image are fused, and improving the efficiency of producing the target detection training set.

[0094] As an optional solution, the fusion determination unit 1206 includes:

[0095] A first determining module is used to determine a content parameter of the first texture image, where the content parameter is used to indicate the total number of pixels included in the first texture image after binarization processing;

[0096] A second determining module is configured to determine a scaling factor level according to the pixel sum; wherein each scaling factor level corresponds to a second scaling factor;

[0097] A third determining module is used to determine a second scaling factor corresponding to the first texture image according to the scaling factor level;

[0098] The fourth determining module is configured to determine a target reduction coefficient according to the first reduction coefficient, the second scaling coefficient, and the aspect ratio of the first image.

[0099] For specific embodiments, reference may be made to the examples shown in the above-mentioned method for dynamic region adjustment, which will not be described in detail in this example.

[0100] As an optional solution, the fourth determining module includes:

[0101] A first determining submodule is configured to, when it is determined that the second texture image has been rotated, determine a ratio of areas of the second texture image after rotation to those before rotation as a third scaling factor;

[0102] The second determining submodule is configured to determine a target scaling factor based on the first scaling factor, the second scaling factor, the third scaling factor, and the aspect ratio of the first texture image.

[0103] For specific embodiments, reference may be made to the examples shown in the above-mentioned method for dynamic region adjustment, which will not be described in detail in this example.

[0104] As an optional solution, it also includes:

[0105] A second acquiring unit, configured to acquire a first original image before acquiring the first image and the first mapped image;

[0106] The second scaling unit is configured to scale the long side of the first original image to a preset length and adjust the short side of the first original image according to the aspect ratio of the first original image before acquiring the first image and the first mapped image, so as to obtain the first image.

[0107] For specific embodiments, reference may be made to the examples shown in the above-mentioned method for dynamic region adjustment, which will not be described in detail in this example.

[0108] As an optional solution, the first determination module includes:

[0109] A first processing submodule is configured to perform binarization processing on the first texture image to obtain a binary image corresponding to the first texture image;

[0110] The second processing submodule is configured to use the sum of pixels in the binary image as a content parameter.

[0111] For specific embodiments, reference may be made to the examples shown in the above-mentioned method for dynamic region adjustment, which will not be described in detail in this example.

[0112] As an optional solution, the first scaling unit 1204 includes:

[0113] The adjustment module is used to enlarge the long side of the first texture image to the same size as the short side of the first image, and adjust the short side of the first texture image according to the aspect ratio of the first texture image to obtain a second texture image.

[0114] For specific embodiments, reference may be made to the examples shown in the above-mentioned method for dynamic region adjustment, which will not be described in detail in this example.

[0115] According to another aspect of the embodiments of the present invention, an electronic device for implementing the above image processing method is also provided. Figure 13 As shown, the electronic device includes a memory 1302 and a processor 1304. The memory 1302 stores a computer program, and the processor 1304 is configured to execute the steps in any of the above method embodiments through the computer program.

[0116] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.

[0117] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:

[0118] S1, obtaining a first image and a first mapping image;

[0119] S2, enlarging the first image according to a first preset ratio to obtain a second image; wherein the long side of the second image is smaller than or equal to the short side of the first image;

[0120] S3, determining a target reduction factor based on the product of the first reduction factor and the aspect ratio of the first texture image; the first reduction factor includes: a reduction factor that reduces the third texture image to a predetermined resolution after fusing the third texture image with the second image; the third texture image is obtained by processing the second texture image to the first predetermined aspect ratio; and the second image is obtained by processing the first image to the second predetermined aspect ratio;

[0121] S4, scaling down the second texture image according to the target scaling factor to obtain a fourth texture image;

[0122] S5: Fusing the fourth map image into the first image to obtain a fused image.

[0123] Alternatively, those skilled in the art will appreciate that Figure 13 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, or other terminal devices. Figure 13 It does not limit the structure of the above electronic device. For example, the electronic device may also include Figure 13 More or fewer components (such as network interfaces, etc.) as shown in, or with Figure 13 Different configurations shown.

[0124] Among them, the memory 1302 can be used to store software programs and modules, such as program instructions / modules corresponding to the image processing method and device in the embodiment of the present invention. The processor 1304 executes various functional applications and data processing by running the software programs and modules stored in the memory 1302, that is, realizing the above-mentioned image processing method. The memory 1302 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1302 may further include a memory remotely located relative to the processor 1304, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include but are not limited to the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 1302 can be used specifically but not limited to store information such as the first image, the first textured image, and the fused image. As an example, such as Figure 13 As shown, the memory 1302 may include, but is not limited to, the first acquisition unit 1202, the first scaling unit 1204, the fusion determination unit 1206, the first adjustment unit 1208, and the fusion unit 1210 of the image processing apparatus. Furthermore, the memory 1302 may also include, but is not limited to, other modules and units of the prop acquisition apparatus, which will not be described in detail in this example.

[0125] Optionally, the transmission device 1306 is configured to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one embodiment, the transmission device 1306 includes a network interface controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In one embodiment, the transmission device 1306 is a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.

[0126] In addition, the electronic device further includes: a display 1308 for displaying the first image, the first texture image and the fused image; and a connection bus 1310 for connecting various module components in the electronic device.

[0127] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the steps of any of the above method embodiments when run.

[0128] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:

[0129] S1, obtaining a first image and a first mapping image;

[0130] S2, enlarging the first image according to a first preset ratio to obtain a second image; wherein the long side of the second image is smaller than or equal to the short side of the first image;

[0131] S3, determining a target reduction factor based on the product of the first reduction factor and the aspect ratio of the first texture image; the first reduction factor includes: a reduction factor that reduces the third texture image to a predetermined resolution after fusing the third texture image with the second image; the third texture image is obtained by processing the second texture image to the first predetermined aspect ratio; and the second image is obtained by processing the first image to the second predetermined aspect ratio;

[0132] S4, scaling down the second texture image according to the target scaling factor to obtain a fourth texture image;

[0133] S5: Fusing the fourth map image into the first image to obtain a fused image.

[0134] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing the hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0135] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.

[0136] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above-mentioned computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the existing technology, or all or part 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 a number of instructions for causing one or more computer devices (such as personal computers, servers, or network devices) to execute all or part of the steps of the methods described in various embodiments of the present invention.

[0137] In the above embodiments of the present invention, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0138] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, and can be electrical or other forms.

[0139] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0140] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0141] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.

Claims

1. An image processing method, characterized in that: include: Obtaining a first image and a first texture image; Enlarging the first texture image according to a first preset ratio to obtain a second texture image; wherein the long side of the second texture image is smaller than or equal to the short side of the first image; A target reduction factor is determined based on the product of a first reduction factor and an aspect ratio of the first texture image; the first reduction factor includes: a reduction factor obtained by reducing the third texture image to a predetermined resolution after fusing the third texture image with the second image; the third texture image is obtained by processing the second texture image to a first predetermined aspect ratio; and the second image is obtained by processing the first image to a second predetermined aspect ratio; scaling down the second texture image according to the target scaling factor to obtain a fourth texture image; The fourth map image is fused into the first image to obtain a fused image.

2. The method according to claim 1, characterized in that The determining of the target reduction coefficient based on the product of the first reduction coefficient and the aspect ratio of the first mapping image comprises: Determining a content parameter of the first texture image, where the content parameter is used to indicate a total number of pixels included in the first texture image after binarization processing; Determining a scaling factor level according to the pixel sum; wherein each scaling factor level corresponds to a second scaling factor; Determining a second scaling factor corresponding to the first texture image according to the scaling factor level; The target reduction coefficient is determined according to the first reduction coefficient, the second scaling coefficient, and the aspect ratio of the first map image.

3. The method according to claim 2, characterized in that Determining the target reduction coefficient according to the first reduction coefficient, the second scaling coefficient, and the aspect ratio of the first map image includes: When it is determined that the second texture image has been rotated and adjusted, a ratio of the areas of the second texture image after rotation to the areas of the second texture image before rotation is determined as a third scaling factor; The target reduction factor is determined based on the first reduction factor, the second scaling factor, the third scaling factor, and an aspect ratio of the first map image.

4. The method according to claim 1, wherein Before acquiring the first image and the first texture image, the method further includes: Acquire a first original image; The long side of the first original image is scaled to a preset length, and the short side of the first original image is correspondingly adjusted according to the aspect ratio of the first original image to obtain a first image.

5. The method according to claim 2, characterized in that The determining of the content parameters of the first texture image includes: Binarize the first texture image to obtain a binary image corresponding to the first texture image; The sum of the pixels in the binary image is used as the content parameter.

6. The method according to claim 1, characterized in that The step of enlarging the first texture image according to a first preset ratio to obtain a second texture image includes: The long side of the first texture image is enlarged to be the same size as the short side of the first image, and the short side of the first texture image is adjusted accordingly according to the aspect ratio of the first texture image to obtain a second texture image.

7. An image processing device, characterized in that include: A first acquisition unit, configured to acquire a first image and a first texture image; a first scaling unit, configured to amplify the first texture image according to a first preset ratio to obtain a second texture image; wherein the longer side of the second texture image is smaller than or equal to the shorter side of the first image; a fusion determination unit, configured to determine a target reduction factor based on a product of a first reduction factor and an aspect ratio of the first texture image; the first reduction factor comprising: a reduction factor by which the third texture image is reduced to a preset clarity after being fused with the second image; the third texture image being obtained by processing the second texture image to a first preset aspect ratio; and the second image being obtained by processing the first image to a second preset aspect ratio; a first adjustment unit, configured to reduce the second texture image according to the target reduction coefficient to obtain a fourth texture image; The fusion unit is used to fuse the fourth map image into the first image to obtain a fused image.

8. The device according to claim 7, characterized in that The fusion determination unit includes: A first determining module is configured to determine a content parameter of the first texture image, wherein the content parameter is used to indicate the total number of pixels included in the first texture image after binarization processing; a second determining module, configured to determine a scaling factor level according to the pixel sum; wherein each scaling factor level corresponds to a second scaling factor; a third determining module, configured to determine a second scaling factor corresponding to the first texture image according to the scaling factor level; The fourth determining module is configured to determine the target reduction coefficient according to the first reduction coefficient, the second scaling coefficient, and the aspect ratio of the first texture image.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 6 when executed.

10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 6 through the computer program.

Citation Information

Patent Citations

  • Picture processing method and device, computer equipment and storage medium

    CN111192195A

  • Image processing method and device, storage medium and electronic equipment

    CN113379662A