Image processing method and device, electronic device and computer readable storage medium

By determining the bright area and the target area in the image processing method, and adding the special effect material when the center of the special effect material coincides with the center of mass of the target area, the problem that the prior art cannot effectively highlight the brighter area in the image is solved, and efficient and Add special effects materials with good results.

CN117726669BActive Publication Date: 2025-02-25SHUXING TECH (BEIJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310331327.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-30
Publication Date
2025-02-25
Estimated Expiration
2043-03-30

AI Technical Summary

Technical Problem

The prior art cannot effectively highlight brighter areas in the image by adding special effect materials to images, and the data processing volume of adding special effect materials at random or gradient positions is large and has poor results.

Method used

By obtaining the image to be processed, determine the bright area and the target area, obtain the special effect material, and add the special effect material to the target area when the center of the special effect material coincides with the center of the target area.

Benefits of technology

The special effect materials are used to highlight areas with high brightness in the image, while improving the special effect effects presented by the special effect materials, solving the problems of large data processing volume and poor results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117726669B_ABST
    Figure CN117726669B_ABST
Patent Text Reader

Abstract

The present application discloses an image processing method and device, an electronic device and a computer-readable storage medium. The method comprises: obtaining an image to be processed; determining a bright area from the image to be processed; determining an area within a target area range from the bright area as a target area; obtaining special effect material, and adding the special effect material to the target area.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to an image processing method and device, an electronic device, and a computer-readable storage medium. Background Art

[0002] By adding special effects materials to an image, the interest of the image can be enhanced, for example, by adding special effects materials to the brighter areas of the image, the brighter areas of the image can be highlighted. In previous technologies, special effects materials are usually added to the image randomly, that is, the adding position of the special effects materials is randomly determined, so it is not possible to highlight the brighter areas of the image by adding special effects materials to the image. Summary of the invention

[0003] The present application provides an image processing method and device, an electronic device, and a computer-readable storage medium.

[0004] In a first aspect, an image processing method is provided, the method comprising:

[0005] Get the image to be processed;

[0006] Determining a bright area from the image to be processed;

[0007] Determine, from the bright area, an area within the target area range as the target area;

[0008] Acquire special effect material, and add the special effect material to the target area.

[0009] In combination with any implementation manner of the present application, the step of determining a bright area from the image to be processed includes:

[0010] Determine bright pixels from the image to be processed, wherein the bright pixels are pixels with high brightness;

[0011] Determine the connected area of ​​the bright pixels as the bright area.

[0012] In combination with any implementation manner of the present application, the step of determining bright pixels from the image to be processed includes:

[0013] Converting the image to be processed into a grayscale image;

[0014] Determine, from the grayscale image, a target pixel whose grayscale value is greater than or equal to a grayscale threshold;

[0015] A pixel corresponding to the target pixel in the image to be processed is determined as the bright pixel.

[0016] In combination with any implementation manner of the present application, the adding the special effect material to the target area includes:

[0017] determining the centroid of the target area;

[0018] When the center of the special effect material coincides with the centroid, the special effect material is added to the target area.

[0019] In combination with any implementation manner of the present application, after adding the special effect material to the target area, the method further includes:

[0020] Displaying the image to be processed including the special effect material;

[0021] When a size adjustment instruction for the special effect material is received, the size of the special effect material in the image to be processed is adjusted according to the size adjustment instruction.

[0022] In combination with any implementation manner of the present application, the adding the special effect material to the target area includes:

[0023] Get the target angle;

[0024] When the special effect material is rotated to the target angle, the special effect material is added to the target area.

[0025] In combination with any embodiment of the present application, the adding the special effect material to the target area when the special effect material is rotated to the target angle includes:

[0026] Determine a reference area from the image to be processed, wherein the minimum distances from pixels in the reference area to pixels in the target area are all less than or equal to a distance threshold;

[0027] determining a target difference between the brightness of the target area and the brightness of the reference area;

[0028] When the special effect material is rotated by the target angle and the target difference is greater than or equal to a difference threshold, the special effect material is added to the target area.

[0029] In combination with any implementation manner of the present application, the special effect material is a pixel area whose brightness is greater than or equal to a brightness threshold.

[0030] In a second aspect, an image processing device is provided, the device comprising:

[0031] An acquisition unit, used for acquiring an image to be processed;

[0032] A determination unit, used for determining a bright area from the image to be processed;

[0033] The determining unit is further used to determine, from the bright area, an area within a target area range as a target area;

[0034] The acquisition unit is also used to acquire special effect materials;

[0035] An adding unit is used to add the special effect material to the target area.

[0036] In combination with any implementation manner of the present application, the determining unit is used to:

[0037] Determine bright pixels from the image to be processed, wherein the bright pixels are pixels with high brightness;

[0038] Determine the connected area of ​​the bright pixels as the bright area.

[0039] In combination with any implementation manner of the present application, the determining unit is used to:

[0040] Converting the image to be processed into a grayscale image;

[0041] Determine, from the grayscale image, a target pixel whose grayscale value is greater than or equal to a grayscale threshold;

[0042] A pixel corresponding to the target pixel in the image to be processed is determined as the bright pixel.

[0043] In combination with any embodiment of the present application, the adding unit is used to:

[0044] determining the centroid of the target area;

[0045] When the center of the special effect material coincides with the centroid, the special effect material is added to the target area.

[0046] In combination with any embodiment of the present application, the image processing device further includes:

[0047] A display unit, used for displaying the image to be processed including the special effect material;

[0048] An adjusting unit is used to adjust the size of the special effect material in the image to be processed according to the size adjustment instruction when a size adjustment instruction for the special effect material is received.

[0049] In combination with any embodiment of the present application, the adding unit is used to:

[0050] Get the target angle;

[0051] When the special effect material is rotated to the target angle, the special effect material is added to the target area.

[0052] In combination with any embodiment of the present application, the adding unit is used to:

[0053] Determine a reference area from the image to be processed, wherein the minimum distances from pixels in the reference area to pixels in the target area are all less than or equal to a distance threshold;

[0054] determining a target difference between the brightness of the target area and the brightness of the reference area;

[0055] When the special effect material is rotated by the target angle and the target difference is greater than or equal to a difference threshold, the special effect material is added to the target area.

[0056] In combination with any implementation manner of the present application, the special effect material is a pixel area whose brightness is greater than or equal to a brightness threshold.

[0057] According to a third aspect, an electronic device is provided, comprising: a processor and a memory, wherein the memory is used to store computer program code, the computer program code includes computer instructions, and when the processor executes the computer instructions, the electronic device executes the method according to the first aspect and any possible implementation thereof.

[0058] In a fourth aspect, another electronic device is provided, comprising: a processor, a sending device, an input device, an output device and a memory, wherein the memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the electronic device executes the first aspect and any one of its embodiments.

[0059] In a fifth aspect, a computer-readable storage medium is provided, in which a computer program is stored. The computer program includes program instructions. When the program instructions are executed by a processor, the processor is caused to execute the first aspect and any one of its embodiments.

[0060] In a sixth aspect, a computer program product is provided, wherein the computer program product comprises a computer program or instructions, and when the computer program or instructions are run on a computer, the computer is enabled to execute the above-mentioned first aspect and any embodiment thereof.

[0061] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application.

[0062] In the present application, the image processing device obtains the image to be processed, determines the bright area from the image to be processed, and then determines the area within the target area from the bright area as the target area. Finally, after obtaining the special effect material, the special effect material is added to the target area, so that the image to be processed can present special effects. And because the area of ​​the target area is within the target area, the target area is a bright area of ​​appropriate area in the image to be processed. Therefore, by adding the special effect material to the target area, the special effect material can be used to highlight the area with larger brightness in the image to be processed, while enhancing the effect of the special effect presented by the special effect material. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the background technology, the drawings required for use in the embodiments of the present application or the background technology will be described below.

[0064] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.

[0065] Figure 1 A flowchart of an image processing method provided in an embodiment of the present application;

[0066] Figure 2 A schematic diagram of a special effects material provided in an embodiment of the present application;

[0067] Figure 3 A schematic diagram of another special effects material provided in an embodiment of the present application;

[0068] Figure 4 A schematic diagram of an image to be processed provided in an embodiment of the present application;

[0069] Figure 5 A schematic diagram of an image to be processed after adding special effect materials provided in an embodiment of the present application;

[0070] Figure 6 A schematic diagram of a grayscale image provided in an embodiment of the present application;

[0071] Figure 7 A schematic diagram of a grayscale image mask provided in an embodiment of the present application;

[0072] Figure 8 A schematic diagram of the structure of an image processing device provided in an embodiment of the present application;

[0073] Fig. 9 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

[0075] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. 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 limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0076] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0077] By adding special effects materials to an image, the interest of the image can be enhanced. In previous technologies, special effects materials are either randomly added to the image or added to a location with a large gradient in the image. Randomly adding special effects materials to an image cannot highlight the brighter areas in the image by adding special effects materials. Since calculating the gradient of an image will bring a large amount of data processing, adding special effects materials to a location with a large gradient in the image will require a large amount of data processing, and the area with a large gradient is not necessarily an area with high brightness. Therefore, adding special effects materials to a location with a large gradient in the image cannot highlight the brighter areas in the image by adding special effects materials. In general, previous technologies cannot highlight the brighter areas in an image by adding special effects materials to the image. Based on this, an embodiment of the present application provides an image processing method to highlight the brighter areas in an image by adding special effects materials to the image.

[0078] The execution subject of the embodiment of the present application is an image processing device, wherein the image processing device can be any electronic device that can execute the technical solution disclosed in the embodiment of the method of the present application. Optionally, the image processing device can be one of the following: a computer, a server.

[0079] It should be understood that the method embodiment of the present application can also be implemented by a processor executing a computer program code. The following describes the embodiment of the present application in conjunction with the drawings in the embodiment of the present application. Figure 1 , Figure 1 It is a flowchart of an image processing method provided in an embodiment of the present application.

[0080] 101. Obtain an image to be processed.

[0081] In the embodiment of the present application, the image to be processed may be any image. For example, the image to be processed may contain a person; for another example, the image to be processed may contain a vehicle. The present application does not limit the content contained in the image to be processed.

[0082] In an implementation of acquiring an image to be processed, an image processing device receives an image to be processed input by a user through an input component to acquire the image to be processed. The input component includes: a keyboard, a mouse, a touch screen, a touch pad, an audio input device, and the like.

[0083] In another implementation of obtaining the image to be processed, the image processing device receives the image to be processed sent by the terminal to obtain the image to be processed. Optionally, the terminal can be any of the following: a mobile phone, a computer, a tablet computer, a server, and a wearable device.

[0084] In another implementation of acquiring the image to be processed, the image processing device is equipped with a camera assembly, wherein the camera assembly includes a camera. The image processing device acquires the image to be processed by using the camera assembly.

[0085] 102. Determine a bright area from the image to be processed.

[0086] In the embodiment of the present application, the bright area is an area with higher brightness in the image to be processed. In one possible implementation, the image processing device obtains the brightness value of pixels in the image to be processed, and determines that the pixel area with a brightness value greater than or equal to the highlight threshold is the bright area.

[0087] In another possible implementation manner, the image processing device obtains the gradient of pixels in the image to be processed, and determines that a pixel area whose gradient value is greater than or equal to a gradient threshold is a bright area.

[0088] 103. Determine, from the bright area, an area within the target area range as the target area.

[0089] In order to improve the display effect of the image to be processed and enrich the interest of the image to be processed, special effects can be added to the bright area of ​​the image to be processed, for example, adding a star-shaped special effect to the bright area, or adding a sparkling special effect to the bright area. The size of the special effect added to the bright area is usually positively correlated with the area of ​​the bright area, that is, the larger the area of ​​the bright area, the larger the size of the added special effect. On the one hand, if the size of the added special effect is too large, it may block the image content in the image to be processed. On the other hand, if the size of the added special effect is too small, it is difficult to reflect the effect of the special effect. Therefore, before adding special effects to the bright area in the image to be processed, it is necessary to determine a bright area of ​​appropriate area from the image to be processed as the area to be added with the special effect.

[0090] In the embodiment of the present application, the target area range is used as a basis for determining whether the area of ​​the bright area is appropriate. Specifically, if the area of ​​the bright area is within the target area range, the area of ​​the bright area is considered appropriate, and if the area of ​​the bright area is outside the target area range, the area of ​​the bright area is considered inappropriate. Therefore, the image processing device determines an area within the target area range from the bright area as the target area, wherein the target area is the area to be added with special effects.

[0091] 104. Obtain special effect materials, and add the special effect materials to the target area.

[0092] In the embodiment of the present application, the special effect material includes the special effects that need to be added. For example, Figure 2 is a schematic diagram of a special effect material, such as Figure 2 As shown, the special effect material is a star-shaped pattern. For another example, Figure 3 is a schematic diagram of another special effect material, such as Figure 3 As shown, the special effect material is a light spot. For another example, the special effect material can be a regular hexagonal pattern.

[0093] In an implementation method of acquiring special effect material, an image processing device receives special effect material input by a user through an input component to acquire the special effect material.

[0094] In another implementation method of acquiring special effect materials, an image processing device receives special effect materials sent by a terminal to acquire the special effect materials.

[0095] In another implementation of acquiring special effect material, the special effect material is stored in a storage medium of the image processing device, and the image processing device acquires the special effect material by reading the special effect material from the storage medium.

[0096] After acquiring the special effect material, the image processing device can add the special effect material to the target area to make the target area present the special effect of the special effect material. Figure 2 In the case of the star-shaped pattern shown above, by adding the special effect material to Figure 4 The target area in the image to be processed shown can be obtained Figure 5 It should be understood that Figure 4 The rectangular blank area at the face of the person in Figure 5 The rectangular blank areas at the faces in the figure are used to block the faces and should not be understood as bright areas, target areas, or the effects of image processing.

[0097] Optionally, the special effect material is a pixel area whose brightness is greater than or equal to the brightness threshold, that is, the special effect material can be regarded as a pixel area, and the brightness of the special effect material is large, in other words, the special effect material is an image with high brightness. In this case, by adding the special effect material to the target area, the target area in the image to be processed can be made brighter, thereby achieving the effect of highlighting the bright area in the image to be processed.

[0098] In the embodiment of the present application, the image processing device obtains the image to be processed, determines the bright area from the image to be processed, and then determines the area within the target area from the bright area as the target area. Finally, after obtaining the special effect material, the special effect material is added to the target area, so that the image to be processed can present special effects. Moreover, since the area of ​​the target area is within the target area, the target area is a bright area of ​​appropriate area in the image to be processed. Therefore, by adding the special effect material to the target area, the special effect material can be used to highlight the area with larger brightness in the image to be processed, while enhancing the effect of the special effect presented by the special effect material.

[0099] As an optional implementation manner, the image processing apparatus performs the following steps during the process of executing step 102:

[0100] 201. Determine bright pixels from the image to be processed.

[0101] In an embodiment of the present application, a bright pixel is a pixel with high brightness. In one possible implementation, the image processing device converts the image to be processed into a grayscale image, determines from the grayscale image a target pixel whose grayscale value is greater than or equal to a grayscale threshold, and determines that the pixel corresponding to the target pixel in the image to be processed is a bright pixel.

[0102] For example, the image to be processed includes pixel a and pixel b, and the grayscale image includes pixel c and pixel d, wherein pixel c corresponds to pixel a, pixel d corresponds to pixel b, the grayscale value of pixel c is 230, and the grayscale value of pixel d is 100. If the grayscale threshold is 220, then since the grayscale value of pixel c is greater than the grayscale threshold, pixel c is the target pixel, and since the grayscale value of pixel d is less than the grayscale threshold, pixel d is not the target pixel. The pixel corresponding to pixel c in the image to be processed is pixel a, that is, pixel a is a bright pixel.

[0103] Optionally, Figure 4The image to be processed is converted into a grayscale image, and we can get Figure 6 It should be understood that Figure 6 The rectangular blank area at the face of the image is used to block the face and should not be understood as a bright area, target area, or the effect of image processing. Figure 6 In the grayscale image shown in the figure, the target pixel with a grayscale value greater than or equal to the grayscale threshold is determined, and the result is Figure 7 The mask of the grayscale image shown, Figure 7 The white pixel in the middle is the target pixel. Figure 6 The brightness of the pixels in (i.e., grayscale value) and the brightness range of the pixels with large brightness generate Figure 6 The image processing device can then use the grayscale image mask shown in FIG. Figure 7 The results shown identify bright pixels in the image to be processed.

[0104] In another possible implementation manner, the image processing device obtains brightness values ​​of pixels in the image to be processed, and determines from the image to be processed pixels whose brightness values ​​are greater than or equal to a highlight threshold as bright pixels.

[0105] In another possible implementation, the image processing device calculates the gradient of the image to be processed, determines a position in the image to be processed that is greater than or equal to a gradient threshold as a target position, and determines a pixel located at the target position as a bright pixel. Optionally, the image processing device calculates the gradient of the image to be processed using a Sobel operator.

[0106] 202. Determine the connected area of ​​the bright pixels as the bright area.

[0107] Since bright pixels are pixels with high brightness, and the connected region of bright pixels is a pixel region with high brightness, the image processing device determines that the connected region of bright pixels is a bright region.

[0108] In this implementation, the image processing device first determines bright pixels from the image to be processed, and then determines the connected area of ​​the bright pixels as the bright area.

[0109] As an optional implementation manner, the image processing device adds the special effect material to the target area by performing the following steps:

[0110] 301. Determine the centroid of the target area.

[0111] 302. When the center of the special effect material coincides with the centroid, add the special effect material to the target area.

[0112] In the embodiment of the present application, the center of the special effect material is the geometric center of the special effect material. When the center of the special effect material coincides with the centroid of the target area, the image processing device adds the special effect material to the target area to make the special effect material more matched with the target area.

[0113] As an optional implementation, after determining the center of the target area, the image processing device may add the special effects material to the target area if the center of the special effects material coincides with the center of the target area, which may also make the special effects material more matched with the target area.

[0114] As an optional implementation, after determining the center of gravity of the target area, the image processing device may add the special effects material to the target area if the center of gravity of the special effects material coincides with the center of the target area, which may also make the special effects material more matched with the target area.

[0115] As an optional implementation manner, after adding the special effect material to the target area, the image processing device further performs the following steps:

[0116] 401. Display the above-mentioned image to be processed including the above-mentioned special effect material.

[0117] After the image processing device adds the special effect material to the target area in the image to be processed, the image to be processed includes the special effect material. At this time, the image to be processed displayed by the image processing device also includes the special effect material.

[0118] 402. When a size adjustment instruction for the special effect material is received, adjust the size of the special effect material in the image to be processed according to the size adjustment instruction.

[0119] In the embodiment of the present application, the size adjustment instruction is an instruction for instructing the image processing device to adjust the size of the special effect material. In one possible implementation, the user inputs the size of the special effect material to the image processing device through a keyboard (including a physical keyboard and a virtual keyboard displayed by a touch screen), thereby inputting the size adjustment instruction for the special effect material to the image processing device. The image processing device then adjusts the size of the special effect material in the image to be processed according to the size adjustment instruction.

[0120] In another possible implementation, the user uses the mouse to scale the special effects material in the image to be processed, thereby inputting a size adjustment instruction for the special effects material to the image processing device, and the image processing device then adjusts the size of the special effects material in the image to be processed according to the size adjustment instruction.

[0121] In another possible implementation, the user scales the special effects material in the image to be processed through the touch screen to input a size adjustment instruction for the special effects material to the image processing device, and the image processing device then adjusts the size of the special effects material in the image to be processed according to the size adjustment instruction.

[0122] In this embodiment, after adding the special effect material to the target area of ​​the image to be processed, the image processing device displays the image to be processed so that the user can determine whether the size of the special effect material added to the image to be processed is appropriate. If the size of the added special effect material is not appropriate, the user can input a size adjustment instruction for the special effect material to the image processing device so that the image processing device adjusts the size of the special effect material according to the size adjustment instruction.

[0123] As an optional implementation, the image processing device obtains a target ratio, wherein when the ratio of the size of the special effects material to the size of the target area is the target ratio, the matching degree between the special effects material and the target area is the highest. When the ratio of the size of the special effects material to the size of the target area is not equal to the target ratio, the image processing device adjusts the size of the special effects material so that the ratio of the size of the special effects material to the size of the target area is the target ratio. In this implementation, the image processing device adjusts the size of the special effects material so that the ratio of the size of the special effects material to the size of the target area is the target ratio, thereby improving the matching degree between the special effects material and the target area.

[0124] As an optional implementation, the image processing device determines the subject in the image to be processed by performing target detection on the image to be processed. In the case where the special effects material blocks the subject, the size of the special effects material is adjusted so that the special effects material does not block the subject. For example, if the subject is a face, the image processing device can determine the face area in the image to be processed by performing face detection on the image to be processed. In the case where it is determined that the pixel area covered by the special effects material and the face area intersect, it is determined that the special effects material has blocked the face area, and then the size of the special effects material is adjusted so that the pixel area covered by the special effects material and the face area do not intersect, so that the special effects material does not block the face area.

[0125] As an optional implementation, the image processing device determines a reference distance from the centroid of the target area to the center of the image to be processed, and determines the size of the special effect material according to the reference distance, wherein the size of the special effect material is positively correlated with the reference distance. In other words, the larger the distance between the target area and the image to be processed, the larger the size of the special effect material added to the target area.

[0126] As an optional implementation, after adding the special effect material to the target area, the special effect material will cover part of the pixel area in the image to be processed, that is, the image to be processed can be divided into a pixel area covered by the special effect material and a pixel area not covered by the special effect material. For the convenience of description, the pixel area not covered by the special effect material in the image to be processed is called the original area. After adding the special effect material to the target area, the image processing device determines the edge pixels in the special effect material whose distance to the edge of the special effect material is less than or equal to the edge threshold. Determine the pixel closest to the edge pixel from the original area as the reference pixel. Determine the first weight of the edge pixel according to the minimum distance from the edge pixel to the edge of the special effect material, wherein the first weight is positively correlated with the minimum distance. Determine the second weight of the reference pixel according to the first weight, wherein the sum of the first weight and the second weight is 1. Use the first weight as the fusion weight of the edge pixel and the second weight as the fusion weight of the reference pixel to fuse the edge pixel and obtain a fused pixel. Use the fused pixel to replace the edge pixel in the special effect material.

[0127] For example, if the edge threshold is 5, then the pixels in the special effects material whose distance to the edge of the special effects material is less than or equal to 5 are edge pixels. If pixel a in the special effects material is an edge pixel, the pixel closest to pixel a in the original area is determined to be pixel b, and pixel b is the reference pixel of pixel a. According to the minimum distance from pixel a to the edge of the special effects material, the first weight of pixel a is determined to be 0.7. According to the first weight of 0.7, the second weight of pixel b can be determined to be 0.3. Using 0.7 as the fusion weight of pixel a and 0.3 as the fusion weight of pixel b, pixel a and pixel b are fused to obtain a fused pixel. Finally, the fused pixel is used to replace pixel a in the special effects material.

[0128] Since the special effects material is quite different from the original area in the image to be processed, adding the special effects material to the target area may cause an abrupt and unnatural transition between the special effects material and the original area. In other words, the edge of the special effects material has a large contrast with the edge of the original area. Therefore, in this embodiment, the image processing device determines the edge pixels in the special effects material by determining the pixels in the special effects material whose distance to the edge of the special effects material is less than or equal to the edge threshold, wherein the edge pixels have a high probability of having a large contrast with the edge of the original area. Then, the pixel closest to the edge pixel is determined from the original area as a reference pixel, and the reference pixel is used as the basis for the subsequent correction of the edge pixel. Specifically, the difference between the reference pixel and the edge pixel is reduced by fusing the edge pixel and the reference pixel.

[0129] Because the closer the edge pixel is to the original area, the more obvious the contrast with the original area, so the image processing device determines the first weight according to the minimum distance between the edge pixel and the edge of the special effect material when the minimum distance is negatively correlated with the first weight of the edge pixel. After determining the first weight of the edge pixel, the second weight of the reference pixel is further determined according to the first weight. Thus, the edge pixel and the reference pixel are weightedly fused according to the first weight and the second weight to obtain a fused pixel, and the edge pixel in the special effect material is replaced with the fused pixel, which can reduce the contrast between the edge of the special effect material and the edge of the original area, thereby making the transition between the special effect material and the original area more natural.

[0130] As an optional implementation manner, the image processing device adds the special effect material to the target area by performing the following steps:

[0131] 501. Obtain the target angle.

[0132] The line connecting the center of the special effect material and the center of the image to be processed is called the target line segment, and the angle between the target line segment and the coordinate axis of the pixel coordinate system of the image to be processed is called the target angle. The target angle can be the angle between the target line segment and the horizontal axis of the pixel coordinate system. For example, the positive direction of the horizontal axis is rotated clockwise until it coincides with the target line segment. At this time, the rotation angle is the angle between the target line segment and the horizontal axis. The target angle can also be the angle between the target line segment and the vertical axis of the pixel coordinate system. For example, the positive direction of the vertical axis is rotated clockwise until it coincides with the target line segment. At this time, the rotation angle is the angle between the target line segment and the vertical axis.

[0133] By adjusting the target angle, special effect materials can be added to the image to be processed at different angles. In the embodiment of the present application, the target angle is the angle at which the special effect materials need to be rotated.

[0134] 502. After rotating the special effect material to the target angle, add the special effect material to the target area.

[0135] The image processing device can adjust the target angle by rotating the special effect material by the target angle, and further can adjust the angle at which the special effect material is added to the image to be processed.

[0136] In this embodiment, after acquiring the target angle, the image processing device adds the special effect material to the target area while rotating the special effect material to the target angle, thereby adjusting the angle of the special effect material.

[0137] It should be understood that when the size of the special effects material is positively correlated with the reference distance and the special effects material is rotated to the target angle, adding the special effects material to the target area can produce a rotation and focus effect in the special effects material, thereby enhancing the spatial sense of the image to be processed.

[0138] As an optional implementation manner, the image processing apparatus performs the following steps during the process of executing step 502:

[0139] 601. Determine a reference area from the image to be processed.

[0140] In the embodiment of the present application, the minimum distance from the pixels in the reference area to the target area is less than or equal to the distance threshold, that is, the reference area is a pixel area in the image to be processed that is closer to the target area.

[0141] 602. Determine a target difference between the brightness of the target area and the brightness of the reference area.

[0142] In the embodiment of the present application, the brightness of the target area may be the average brightness of the pixels in the target area, and the brightness of the reference area may be the average brightness of the pixels in the reference area. The target difference is the difference between the brightness of the target area and the brightness of the reference area, and optionally, the target difference is the absolute value of the difference between the brightness of the target area and the brightness of the reference area.

[0143] 603. When the special effect material is rotated to the target angle and the target difference is greater than or equal to the difference threshold, the special effect material is added to the target area.

[0144] If the target difference is greater than or equal to the difference threshold, it means that the brightness of the target area is significantly different from that of the reference area, that is, the target area is an isolated area with high brightness in the image to be processed. At this time, adding the special effect material to the target area can better highlight the target area. Therefore, when the image processing device rotates the special effect material by the target angle and the target difference is greater than or equal to the difference threshold, the special effect material is added to the target area, which can not only highlight the isolated area with high brightness in the image to be processed, but also adjust the angle of the special effect material.

[0145] In a possible implementation, the image processing device, when the target difference is greater than or equal to the difference threshold, performs the step of adding the special effects material to the target area while rotating the special effects material by the target angle. Optionally, when the target difference is greater than or equal to the difference threshold, the image processing device rotates the special effects material by the target angle to obtain the rotated special effects material, and then adds the rotated special effects material to the target area. Optionally, when the target difference is greater than or equal to the difference threshold, the image processing device adds the special effects material to the target area, and then rotates the special effects material by the target angle.

[0146] In this embodiment, the image processing device first determines a reference area from the image to be processed, and then determines a target difference between the brightness of the target area and the brightness of the reference area, and then determines whether the target difference is an isolated bright area in the image to be processed based on the target difference. When the target difference is greater than or equal to the difference threshold, the target difference is determined to be an isolated bright area in the image to be processed, and then the special effect material is added to the target area while rotating the special effect material by a target angle, thereby achieving the effect of highlighting the isolated bright area in the image to be processed and adjusting the angle of the special effect material.

[0147] Based on the technical solution provided in the embodiment of the present application, the embodiment of the present application also provides a possible application scenario. With the rapid development of user generated content (UGC) communities, the application of UGC communities is becoming more and more extensive, including users sharing images through UGC communities. Specifically, users upload images to the UGC community so that all users in the UGC community can view the images. Based on the technical solution provided in the embodiment of the present application, editing images can enrich the effects of uploaded images, thereby improving the fun of UGC images.

[0148] Specifically, first determine the target area range and brightness range, and store the target area range and brightness range in the image processing device. After obtaining the image to be processed uploaded by the user, the image processing device converts the image to be processed into a grayscale image, and then determines the target pixel whose grayscale value is greater than or equal to the grayscale threshold from the grayscale image. Specifically, the target pixel is determined according to the brightness and brightness range of the pixel in the grayscale image. Determine the connected area of ​​the target pixel and the contour of each connected area, and store the coordinates of the contour of each connected area in the image to be processed. The image processing device calculates the contour moment of each connected area and the centroid of each connected area according to the contour of each connected area, and stores the contour moment of each connected area and the centroid of each connected area. After the image processing device obtains the special effect material, the special effect material is added to each connected area by replacing the pixel value in the contour moment of each connected area with the pixel value of the special effect material. At the same time, in the process of adding the special effect material to each connected area, the center of the special effect material is aligned with the centroid of each connected area. In this way, the special effect material can be added to the area with high brightness in the image to be processed, thereby enriching the interest of the image to be processed.

[0149] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.

[0150] If the technical solution of this application involves personal information, the product using the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using the technical solution of this application has obtained the individual's separate consent before processing the sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that he or she agrees to the collection of his or her personal information; or on the device that processes personal information, the personal information processing rules are notified by obvious signs / information, and the individual's authorization is obtained through pop-up information or by asking the individual to upload his or her personal information; among which, personal information processing may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.

[0151] The method of the embodiment of the present application is described in detail above, and the device of the embodiment of the present application is provided below.

[0152] See also Figure 8 , Figure 8 The schematic diagram of the structure of an image processing device 1 provided in an embodiment of the present application includes an acquisition unit 11, a determination unit 12, and an adding unit 13. Optionally, the image processing device 1 also includes: a display unit 14 and an adjustment unit 15. Specifically:

[0153] An acquisition unit 11, used for acquiring an image to be processed;

[0154] A determination unit 12, configured to determine a bright area from the image to be processed;

[0155] The determining unit 12 is further configured to determine, from the bright area, an area within a target area range as a target area;

[0156] The acquisition unit 11 is also used to acquire special effect materials;

[0157] The adding unit 13 is used to add the special effect material to the target area.

[0158] In combination with any implementation manner of the present application, the determining unit 12 is used to:

[0159] Determine bright pixels from the image to be processed, wherein the bright pixels are pixels with high brightness;

[0160] Determine the connected area of ​​the bright pixels as the bright area.

[0161] In combination with any implementation manner of the present application, the determining unit 12 is used to:

[0162] Converting the image to be processed into a grayscale image;

[0163] Determine, from the grayscale image, a target pixel whose grayscale value is greater than or equal to a grayscale threshold;

[0164] A pixel corresponding to the target pixel in the image to be processed is determined as the bright pixel.

[0165] In combination with any embodiment of the present application, the adding unit 13 is used to:

[0166] determining the centroid of the target area;

[0167] When the center of the special effect material coincides with the centroid, the special effect material is added to the target area.

[0168] In combination with any embodiment of the present application, the image processing device 1 further includes:

[0169] A display unit 14, used for displaying the image to be processed including the special effect material;

[0170] The adjusting unit 15 is configured to adjust the size of the special effect material in the image to be processed according to the size adjustment instruction when receiving the size adjustment instruction for the special effect material.

[0171] In combination with any embodiment of the present application, the adding unit 13 is used to:

[0172] Get the target angle;

[0173] When the special effect material is rotated to the target angle, the special effect material is added to the target area.

[0174] In combination with any embodiment of the present application, the adding unit 13 is used to:

[0175] Determine a reference area from the image to be processed, wherein the minimum distances from pixels in the reference area to pixels in the target area are all less than or equal to a distance threshold;

[0176] determining a target difference between the brightness of the target area and the brightness of the reference area;

[0177] When the special effect material is rotated by the target angle and the target difference is greater than or equal to a difference threshold, the special effect material is added to the target area.

[0178] In combination with any implementation manner of the present application, the special effect material is a pixel area whose brightness is greater than or equal to a brightness threshold.

[0179] In the embodiment of the present application, the image processing device obtains the image to be processed, determines the bright area from the image to be processed, and then determines the area within the target area from the bright area as the target area. Finally, after obtaining the special effect material, the special effect material is added to the target area, so that the image to be processed can present special effects. Moreover, since the area of ​​the target area is within the target area, the target area is a bright area of ​​appropriate area in the image to be processed. Therefore, by adding the special effect material to the target area, the special effect material can be used to highlight the area with larger brightness in the image to be processed, while enhancing the effect of the special effect presented by the special effect material.

[0180] In some embodiments, the functions or modules included in the device provided in the embodiments of the present application can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments. For the sake of brevity, it will not be repeated here.

[0181] Fig. 9 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. The electronic device 2 includes a processor 21 and a memory 22. Optionally, the electronic device 2 also includes an input device 23 and an output device 24. The processor 21, the memory 22, the input device 23 and the output device 24 are coupled via a connector, and the connector includes various interfaces, transmission lines or buses, etc., which are not limited in the embodiments of the present application. It should be understood that in each embodiment of the present application, coupling refers to mutual connection in a specific manner, including direct connection or indirect connection through other devices, for example, it can be connected through various interfaces, transmission lines, buses, etc.

[0182] The processor 21 may include one or more processors, for example, one or more central processing units (CPUs). When the processor is a CPU, the CPU may be a single-core CPU or a multi-core CPU. Optionally, the processor 21 may be a processor group consisting of multiple CPUs, and the multiple processors are coupled to each other via one or more buses. Optionally, the processor may also be other types of processors, etc., which are not limited in the embodiments of the present application.

[0183] The memory 22 can be used to store computer program instructions and various computer program codes including the program code for executing the program code of the present application. Optionally, the memory includes but is not limited to random access memory (RAM), read-only memory (ROM), erasable programmable read only memory (EPROM), or portable read only memory (CD-ROM), which is used for related instructions and data.

[0184] The input device 23 is used to input data and / or signals, and the output device 24 is used to output data and / or signals. The input device 23 and the output device 24 can be independent devices or an integrated device.

[0185] It can be understood that in the embodiment of the present application, the memory 22 can be used not only to store relevant instructions, but also to store relevant data. For example, the memory 22 can be used to store images to be processed and special effects materials obtained through the input device 23, etc. The embodiment of the present application does not limit the specific data stored in the memory.

[0186] Understandably, Fig. 9 Only a simplified design of an electronic device is shown. In practical applications, the electronic device may also include other necessary components, including but not limited to any number of input / output devices, processors, memories, etc., and all electronic devices that can implement the embodiments of the present application are within the protection scope of the present application.

[0187] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0188] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. Those skilled in the art can also clearly understand that the descriptions of the various embodiments of the present application have different focuses. For the convenience and brevity of description, the same or similar parts may not be repeated in different embodiments. Therefore, for parts not described or not described in detail in a certain embodiment, refer to the records of other embodiments.

[0189] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

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

[0191] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0192] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital versatile disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).

[0193] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by a computer program to instruct the relevant hardware, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above-mentioned method embodiments. The aforementioned storage medium includes: a read-only memory (ROM) or a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

Claims

1. An image processing method, characterized in that: The method comprises: Get the image to be processed; Determine a bright area from the image to be processed; the determining the bright area from the image to be processed comprises: determining bright pixels from the image to be processed, the bright pixels being pixels with high brightness; determining a connected area of ​​the bright pixels as the bright area; Determine, from the bright area, an area within the target area range as the target area; Acquire special effect material, and add the special effect material to the target area; The adding the special effect material to the target area includes: acquiring a target angle; and adding the special effect material to the target area while rotating the special effect material to the target angle; The adding of the special effects material to the target area when the special effects material is rotated by the target angle comprises: determining a reference area from the image to be processed, wherein the minimum distance from pixels in the reference area to the target area is less than or equal to a distance threshold; determining a target difference between the brightness of the target area and the brightness of the reference area; and adding the special effects material to the target area when the special effects material is rotated by the target angle and the target difference is greater than or equal to the difference threshold; Determine edge pixels in the special effect material whose distance to the edge of the special effect material is less than or equal to an edge threshold; Determine, from a pixel area in the image to be processed that is not covered by the special effect material, a pixel closest to the edge pixel as a reference pixel; Fusing the edge pixel and the reference pixel to obtain a fused pixel; The edge pixels in the special effect material are replaced by the fused pixels.

2. The method according to claim 1, characterized in that Determining bright pixels from the image to be processed includes: Converting the image to be processed into a grayscale image; Determine, from the grayscale image, a target pixel whose grayscale value is greater than or equal to a grayscale threshold; A pixel corresponding to the target pixel in the image to be processed is determined as the bright pixel.

3. The method according to claim 1 or 2, characterized in that: The adding the special effect material to the target area includes: determining the centroid of the target area; When the center of the special effect material coincides with the centroid, the special effect material is added to the target area.

4. The method according to claim 1 or 2, characterized in that: After adding the special effect material to the target area, the method further includes: Displaying the image to be processed including the special effect material; When a size adjustment instruction for the special effect material is received, the size of the special effect material in the image to be processed is adjusted according to the size adjustment instruction.

5. The method according to claim 1, characterized in that The special effect material is a pixel area whose brightness is greater than or equal to a brightness threshold.

6. An image processing device, characterized in that: The device comprises: An acquisition unit, used for acquiring an image to be processed; A determination unit, configured to determine a bright area from the image to be processed; the determination of the bright area from the image to be processed comprises: determining bright pixels from the image to be processed, the bright pixels being pixels with high brightness; and determining a connected area of ​​the bright pixels as the bright area; The determining unit is further used to determine, from the bright area, an area within a target area range as a target area; The acquisition unit is also used to acquire special effect materials; An adding unit, used for adding the special effect material to the target area; The adding the special effect material to the target area includes: acquiring a target angle; and adding the special effect material to the target area while rotating the special effect material to the target angle; The adding of the special effects material to the target area when the special effects material is rotated by the target angle comprises: determining a reference area from the image to be processed, wherein the minimum distance from pixels in the reference area to the target area is less than or equal to a distance threshold; determining a target difference between the brightness of the target area and the brightness of the reference area; and adding the special effects material to the target area when the special effects material is rotated by the target angle and the target difference is greater than or equal to the difference threshold; The determining unit is used to determine edge pixels in the special effect material whose distance to the edge of the special effect material is less than or equal to an edge threshold; The determining unit is used to determine, from a pixel area in the image to be processed that is not covered by the special effect material, a pixel closest to the edge pixel as a reference pixel; A fusion unit, used for fusing the edge pixel and the reference pixel to obtain a fused pixel; A replacement unit is used to replace the edge pixels in the special effect material with the fused pixels.

7. An electronic device, characterized in that: include: A processor and a memory, wherein the memory is used to store computer program codes, wherein the computer program codes include computer instructions, and when the processor executes the computer instructions, the electronic device executes the method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor is caused to execute the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Image processing method and device, storage medium

    CN109035136A

  • Star awn adding method and device, computer equipment and readable storage medium

    CN114022390A