CN117726570A - Image processing method, device, electronic equipment and readable storage medium - Google Patents

Image processing method, device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN117726570A
CN117726570A CN202310169020.0A CN202310169020A CN117726570A CN 117726570 A CN117726570 A CN 117726570A CN 202310169020 A CN202310169020 A CN 202310169020A CN 117726570 A CN117726570 A CN 117726570A
Authority
CN
China
Prior art keywords
image
processed
target object
shadow
spotlight
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310169020.0A
Other languages
Chinese (zh)
Inventor
袁知洪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xiaohongshu Technology Co ltd
Original Assignee
Xiaohongshu Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xiaohongshu Technology Co ltd filed Critical Xiaohongshu Technology Co ltd
Priority to CN202310169020.0A priority Critical patent/CN117726570A/en
Publication of CN117726570A publication Critical patent/CN117726570A/en
Pending legal-status Critical Current

Links

Abstract

The application discloses an image processing method, an image processing device, an electronic device and a readable storage medium, wherein the image processing method comprises the following steps: acquiring an image to be processed; performing target object extraction processing on the image to be processed to obtain a target object image; adding illumination shadows to the target object image to obtain a spot shadow image; and fusing the spotlight region shade corresponding to the image to be processed and the spotlight shadow image into the image to be processed to obtain a spotlight effect diagram. Therefore, the image processing method provided by the embodiment of the application can integrate the special effect of illumination shadow and the light-gathering special effect provided by the light-gathering area shade into the image to be processed at the same time, so that the shadow effect generated after the spotlight is irradiated is reflected, and the obtained spotlight effect diagram is more real.

Description

Image processing method, device, electronic equipment and readable storage medium
Technical Field
The present disclosure relates to the field of image processing technologies, and in particular, to an image processing method, an image processing device, an electronic device, and a readable storage medium.
Background
In order to make the image more beautiful, there are various methods for processing the image, and various image effects can be added to the image. One popular image processing method is to add a spotlight effect to an image to be processed so as to highlight objects such as people and animals in the image.
However, the effects currently used to add spotlight spotlights produce a spotlight effect map that is not realistic.
Disclosure of Invention
The application provides an image processing method, an image processing device, electronic equipment and a readable storage medium, and aims to solve the technical problem that a spotlight effect graph generated by an existing image processing method is unreal.
In a first aspect, the present application provides an image processing method, including:
acquiring an image to be processed;
performing target object extraction processing on the image to be processed to obtain a target object image;
adding illumination shadows to the target object image to obtain a spot shadow image;
and fusing the spotlight region shade corresponding to the image to be processed and the spotlight shadow image into the image to be processed to obtain a spotlight effect diagram.
In one possible implementation manner of the present application, the adding an illumination shadow to the target object image to obtain a spot shadow image includes:
and carrying out Gaussian blur processing on the target object image to obtain a spot shadow image, wherein the Gaussian blur processing is used for carrying out blur processing on the edge of the target object in the target object image so as to add an illumination shadow.
In a possible implementation manner of the present application, before the target object extracting processing is performed on the image to be processed to obtain a target object image, the method further includes:
inquiring a preset pixel brightening table to obtain a brightening pixel value corresponding to an initial pixel value of each pixel point in the image to be processed;
updating the initial pixel value of each pixel point by the corresponding brightness-improving pixel value of each pixel point to obtain each updated pixel point and a new image to be processed formed by each updated pixel point.
In a possible implementation manner of the present application, before adding an illumination shadow to the target object image to obtain a spot shadow image, the method further includes:
and responding to the adjustment operation of the target object image, and adjusting the pixel value in the target object image according to the pixel value adjustment parameter carried by the adjustment operation to obtain a new target object image.
In one possible implementation of the present application, the adjustment operation includes a hue adjustment operation, a saturation adjustment operation, a brightness adjustment operation, and/or a transparency adjustment operation.
In a possible implementation manner of the present application, before the fusing the preset spotlight region mask and the spotlight shadow image into the image to be processed to obtain the spotlight effect diagram, the method further includes:
Acquiring a first light gathering area in the image to be processed and a second light gathering area in the first light gathering area;
generating an initial mask of the image to be processed according to the position of the first light gathering area, wherein the initial mask comprises a third light gathering area corresponding to the first light gathering area and a fourth light gathering area corresponding to the second light gathering area;
and carrying out gradual change treatment on the non-overlapped area between the third light condensation area and the fourth light condensation area to obtain a light condensation area shade corresponding to the image to be treated.
In one possible implementation manner of the present application, the acquiring a first light-focusing area in the image to be processed and a second light-focusing area in the first light-focusing area includes:
acquiring an image position of a target object in the image to be processed;
determining a first light gathering area according to the image position and a preset first area size;
and determining a second light condensing area in the first light condensing area according to the image position and a preset second area size, wherein the second area size is smaller than the first area size.
In a possible implementation manner of the present application, the fusing, into the image to be processed, a spotlight region mask corresponding to the image to be processed and the spotlight shadow image to obtain a spotlight effect diagram includes:
Performing single-channel extraction on the spot shadow image to obtain a target shade of the spot shadow image;
mixing the pixel value of each pixel point in the spot light shadow image and the pixel value of each pixel point in the image to be processed according to the weight of each pixel point in the target shade to obtain a mixed image;
and merging the light focusing area shade corresponding to the image to be processed into the mixed image to obtain a spotlight effect diagram.
In a second aspect, the present application provides an image processing apparatus comprising:
an acquisition unit configured to acquire an image to be processed;
the object extraction unit is used for carrying out object extraction processing on the image to be processed to obtain a target object image;
the shadow adding unit is used for adding illumination shadows for the target object image to obtain a spot light shadow image;
and the fusion unit is used for fusing the spotlight region shade corresponding to the image to be processed and the spotlight shadow image into the image to be processed to obtain a spotlight effect diagram.
In a possible implementation of the present application, the shadow adding unit is further configured to:
and carrying out Gaussian blur processing on the target object image to obtain a spot shadow image, wherein the Gaussian blur processing is used for carrying out blur processing on the edge of the target object in the target object image so as to add an illumination shadow.
In a possible implementation manner of the present application, the object extraction unit is further configured to:
inquiring a preset pixel brightening table to obtain a brightening pixel value corresponding to an initial pixel value of each pixel point in the image to be processed;
updating the initial pixel value of each pixel point by the corresponding brightness-improving pixel value of each pixel point to obtain each updated pixel point and a new image to be processed formed by each updated pixel point.
In a possible implementation of the present application, the shadow adding unit is further configured to:
and responding to the adjustment operation of the target object image, and adjusting the pixel value in the target object image according to the pixel value adjustment parameter carried by the adjustment operation to obtain a new target object image.
In one possible implementation of the present application, the adjustment operation includes a hue adjustment operation, a saturation adjustment operation, a brightness adjustment operation, and/or a transparency adjustment operation.
In a possible implementation of the present application, the fusion unit is further configured to:
acquiring a first light gathering area in the image to be processed and a second light gathering area in the first light gathering area;
Generating an initial mask of the image to be processed according to the position of the first light gathering area, wherein the initial mask comprises a third light gathering area corresponding to the first light gathering area and a fourth light gathering area corresponding to the second light gathering area;
and carrying out gradual change treatment on the non-overlapped area between the third light condensation area and the fourth light condensation area to obtain a light condensation area shade corresponding to the image to be treated.
In a possible implementation of the present application, the fusion unit is further configured to:
acquiring an image position of a target object in the image to be processed;
determining a first light gathering area according to the image position and a preset first area size;
and determining a second light condensing area in the first light condensing area according to the image position and a preset second area size, wherein the second area size is smaller than the first area size.
In a possible implementation of the present application, the fusion unit is further configured to:
performing single-channel extraction on the spot shadow image to obtain a target shade of the spot shadow image;
mixing the pixel value of each pixel point in the spot light shadow image and the pixel value of each pixel point in the image to be processed according to the weight of each pixel point in the target shade to obtain a mixed image;
And merging the light focusing area shade corresponding to the image to be processed into the mixed image to obtain a spotlight effect diagram.
In a third aspect, the present application also provides an electronic device comprising a processor, a memory and a computer program stored in the memory and executable on the processor, the processor executing steps in any of the image processing methods provided herein when the processor invokes the computer program in the memory.
In a fourth aspect, the present application also provides a readable storage medium having stored thereon a computer program which, when executed by a processor, performs steps in any of the image processing methods provided herein.
In summary, the image processing method provided in the embodiment of the present application includes: acquiring an image to be processed; performing target object extraction processing on the image to be processed to obtain a target object image; adding illumination shadows to the target object image to obtain a spot shadow image; and fusing the spotlight region shade corresponding to the image to be processed and the spotlight shadow image into the image to be processed to obtain a spotlight effect diagram.
Therefore, the image processing method provided by the embodiment of the application can integrate the special effect of illumination shadow and the light-gathering special effect provided by the light-gathering area shade into the image to be processed at the same time, so that the shadow effect generated after the spotlight is irradiated is reflected, and the obtained spotlight effect diagram is more real.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly introduced below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is an application scenario schematic diagram of an image processing method provided in an embodiment of the present application;
FIG. 2 is a schematic flow chart of an image processing method provided in an embodiment of the present application;
FIG. 3 is a schematic illustration of the special effects of a spotlight provided in an embodiment of the present application;
FIG. 4 is a schematic flow chart of obtaining a spotlight effect diagram according to an embodiment of the present application;
FIG. 5 is a schematic flow chart of the process of brightening an image to be processed according to the embodiment of the present application;
FIG. 6 is a schematic flow chart of a mask for obtaining a condensing area according to an embodiment of the present application;
FIG. 7 is a schematic view showing the structure of an embodiment of an image processing apparatus provided in an embodiment of the present application;
fig. 8 is a schematic structural diagram of an embodiment of an electronic device provided in an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
In the description of the embodiments of the present application, it should be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or an implicit indication of the number of features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more of the described features. In the description of the embodiments of the present application, the meaning of "a plurality" is two or more, unless explicitly defined otherwise.
The following description is presented to enable any person skilled in the art to make and use the application. In the following description, details are set forth for purposes of explanation. It will be apparent to one of ordinary skill in the art that the present application may be practiced without these specific details. In other instances, well-known processes have not been described in detail in order to avoid unnecessarily obscuring descriptions of the embodiments of the present application. Thus, the present application is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features disclosed in the embodiments of the present application.
The embodiment of the application provides an image processing method, an image processing device, electronic equipment and a readable storage medium. The image processing apparatus may be integrated in an electronic device, which may be a server or a terminal.
The execution main body of the image processing method in the embodiment of the present application may be an image processing apparatus provided in the embodiment of the present application, or different types of electronic devices such as a server device, a physical host, or a special effect maker device (UE) that is integrated with the image processing apparatus, where the image processing apparatus may be implemented in a hardware or software manner, and the UE may specifically be a terminal device such as a smart phone, a tablet computer, a notebook computer, a palm computer, a desktop computer, or a personal digital assistant (Personal Digital Assistant, PDA).
The electronic device may be operated in a single operation mode, or may also be operated in a device cluster mode.
Referring to fig. 1, fig. 1 is a schematic view of a scenario of an image processing system provided in an embodiment of the present application. The image processing system may include an electronic device 100, and an image processing apparatus is integrated in the electronic device 100.
In addition, as shown in FIG. 1, the image processing system may also include a memory 200 for storing data, such as text data.
It should be noted that, the schematic view of the image processing system shown in fig. 1 is only an example, and the image processing system and the scene described in the embodiments of the present application are for more clearly describing the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application, and those skilled in the art can know that, with the evolution of the image processing system and the appearance of a new service scene, the technical solutions provided in the embodiments of the present invention are equally applicable to similar technical problems.
Next, an image processing method provided in an embodiment of the present application, in which an electronic device is used as an execution body, is described beginning to be described, and in order to simplify and facilitate description, the execution body will be omitted in a subsequent method embodiment, and the image processing method includes: acquiring an image to be processed; performing target object extraction processing on the image to be processed to obtain a target object image; adding illumination shadows to the target object image to obtain a spot shadow image; and fusing the spotlight region shade corresponding to the image to be processed and the spotlight shadow image into the image to be processed to obtain a spotlight effect diagram.
Referring to fig. 2, fig. 2 is a schematic flow chart of an image processing method according to an embodiment of the present application. It should be noted that although a logical order is depicted in the flowchart, in some cases the steps depicted or described may be performed in a different order than presented herein. The image processing method specifically may include the following steps 201 to 204, in which:
201. and acquiring an image to be processed.
The image to be processed may refer to an image to which a spotlight special effect is to be added. For ease of understanding, referring to fig. 3, fig. 3 is a schematic diagram of a spotlight effect, where the spotlight effect may be understood as an effect that a part of an image area 301 is blocked in an image 300, and a part of the image area 302 is displayed to present a visual effect that an illumination range of a spotlight is focused on a specific object in the image area 302. 1. Presenting special effects of visual effects that the irradiation range of the spotlight is focused on a specific object; 2. shadow special effects of specific objects in the image to be processed.
In some embodiments, the user may open a functional interface for adding a spotlight effect in the image processing software, and input a to-be-processed image of the to-be-added spotlight effect in the functional interface.
It should be noted that, in order to facilitate calculation of the subsequent position, after the image to be processed is obtained, normalization processing may be performed on the position of each pixel point in the image to be processed, and the position of each pixel point may be normalized to be within the range of coordinates (0, 1), and when any position is referred to hereinafter, processing may be performed based on the normalized position.
202. And carrying out target object extraction processing on the image to be processed to obtain a target object image.
The target object extraction processing of the image to be processed may be a processing procedure of detecting an image area where the target object is located from the image to be processed, and clipping the image area to obtain an image with the same size as the image to be processed. It can be understood that the obtained target object image contains the image information in the image area where the target object is located, and the size of the target object image is the same as the size of the image to be processed.
The target object is an object to be added with the special effect of the spotlight in the image to be processed. The kind of the target object is not particularly limited in the embodiments of the present application, and the target object may refer to one of different kinds of people, animals, furniture, and the like. The specific kind of the target object may be set in advance by a developer of the image processing software.
In some embodiments, the target object may be one of a plurality of preset objects. For example, a developer may set a person, an animal, and furniture as preset objects, respectively, and set different virtual controls for different preset objects in the image processing software, each virtual control being used to trigger an extraction operation for a different preset object. When the user wants to add the special effect of the spotlight to the person in the image to be processed, the virtual control corresponding to the person can be operated, and the electronic device takes the person as a target object at this time, and step 202 is executed.
The image area of the target object in the image to be processed can be obtained by detecting the trained target detection model, and then the image area is cut to obtain the target object image. For example, training an open-source target detection model such as YOLO through a preset sample data set to obtain a trained target detection model, inputting an image to be processed into the trained target detection model to obtain an image area where a target object is located in the image to be processed, and cutting to obtain a target object image.
203. And adding an illumination shadow to the target object image to obtain a spot light shadow image.
An illuminated shadow can be understood as a blurred shadow that is generated at the edge of a target object by light striking the target object.
In some embodiments, edges of the target object may be detected and blurred to add an illumination shadow. For example, the edge of the target object in the target object image can be detected through edge detection algorithms such as a Sobel operator, a Kirsch operator, a compass operator and the like, and then the edge is blurred through filtering and the like so as to add illumination shadows.
204. And fusing the spotlight region shade corresponding to the image to be processed and the spotlight shadow image into the image to be processed to obtain a spotlight effect diagram.
The light-condensing area mask is a mask for showing a visual effect that the irradiation range of the spotlight is condensed on a specific object, and for convenience of understanding, fig. 3 is taken as an example. In fig. 3 the spotlight region mask may obstruct the image region 301 to present the visual effect that the illumination range of the spotlight is focused on a specific object in the image region 302.
In some embodiments, the spotlight region mask may be input by a user. For example, in the image processing software, a user can adjust the position of the center point of the light-gathering area mask in the image to be processed and the radius of the light-gathering area mask through a preset virtual control so as to generate a circular light-gathering area mask, and through setting the transparency of the light-gathering area mask, the image area of the image to be processed outside the light-gathering area mask can be covered.
For example, the electronic device may fuse the spotlight region mask corresponding to the image to be processed and the spotlight shadow image into the image to be processed in a manner of overlapping the layers, so as to obtain a spotlight effect diagram. For example, the layers may be sequentially arranged from top to bottom in the order of the spotlight region mask, spotlight shadow image, image to be processed, so as to obtain a spotlight effect map. It can be understood that the spotlight effect graph includes both the special effect of presenting the visual effect that the irradiation range of the spotlight is focused on the specific object and the shadow special effect of the specific object in the image to be processed, so that a more real spotlight special effect is provided.
In summary, the image processing method provided in the embodiment of the present application includes: acquiring an image to be processed; performing target object extraction processing on the image to be processed to obtain a target object image; adding illumination shadows to the target object image to obtain a spot shadow image; and fusing the spotlight region shade corresponding to the image to be processed and the spotlight shadow image into the image to be processed to obtain a spotlight effect diagram.
Therefore, the image processing method provided by the embodiment of the application can integrate the special effect of illumination shadow and the light-gathering special effect provided by the light-gathering area shade into the image to be processed at the same time, so that the shadow effect generated after the spotlight is irradiated is reflected, and the obtained spotlight effect diagram is more real.
In some embodiments, the image obtained by the method of overlapping the layers in step 204 includes three layers, so that the data size is large, and the excessive storage space of the device is occupied. Referring to fig. 4, at this time, the step of "fusing the spotlight region mask corresponding to the image to be processed and the spotlight shadow image into the image to be processed to obtain a spotlight effect diagram" includes:
401. and carrying out single-channel extraction on the spot shadow image to obtain a target shade of the spot shadow image.
Single channel extraction refers to extracting an image of one of the channels from the spot shadow image. For example, when the spot shadow image is an RGB image, an image of any one of R, G, B channels may be extracted from the spot shadow image as a target mask.
It will be appreciated that since the spot shadow image is an image with an added illumination shadow, there will be pixel values in the target mask for the region corresponding to the illumination shadow, and by taking the pixel values in the target mask as weights, the illumination shadow can be blended in the corresponding region in the image to be processed.
402. And mixing the pixel value of each pixel point in the spot light shadow image and the pixel value of each pixel point in the image to be processed according to the weight of each pixel point in the target shade to obtain a mixed image.
Illustratively, the pixel value of each pixel in the spot-light image, and the pixel value of each pixel in the image to be processed, may be blended by the following algorithm formula (1):
highshadow=mix (blursshadow, lightTex, blurmsk) algorithm formula (1)
Wherein highShadow refers to the pixel value in the blended image, blurShadow refers to the pixel value in the spot shadow image, lightTex refers to the pixel value in the image to be processed, blurMask refers to the weight in the target mask, mix refers to the blending function.
403. And merging the light focusing area shade corresponding to the image to be processed into the mixed image to obtain a spotlight effect diagram.
In step 403, the layer overlapping or pixel value blending may be performed. For example, a spotlight region mask may be placed over the blended image to obtain a spotlight effect image comprising two layers. Alternatively, the following algorithm formula (2) may be adopted, wherein the pixel values in the light-condensing region mask are used as weights, and the pixel values in the mixed image are mixed with preset pixel values for transparentization, so that the image region outside the light-condensing region of the spotlight effect graph is transparentized, and the spotlight effect graph is obtained:
finalcolor=mix (highShadow, vec (0.0), circle. R) algorithm formula (2)
Where finalColor refers to the pixel values in the spotlight effect map, highShadow refers to the pixel values in the blended image, circle. R refers to the spotlight region mask, vec (0.0) is the preset pixel values for blending, to transparence the image region outside the spotlight region of the spotlight effect map, and mix refers to the blending function.
It can be seen that by the method from step 401 to step 403, the number of layers in the spotlight effect diagram can be reduced, the data amount of the spotlight effect diagram can be reduced, and in the process of obtaining the blended image by blending, the weights corresponding to the other image areas except the image area containing the target object in the target mask are all 0, so that the other image areas except the image area containing the target object in the image to be processed are not affected.
In some embodiments, in order to improve the display effect of the spotlight effect graph, the image to be processed may be first brightened, and the brightened image to be processed is used as a new image to be processed. Referring to fig. 5, at this time, before the step of "performing the target object extraction process on the image to be processed to obtain the target object image", the method further includes:
501. And inquiring a preset pixel brightening table to obtain a brightening pixel value corresponding to the initial pixel value of each pixel point in the image to be processed.
The pixel brightening table is used for storing the pixel values after brightening corresponding to different pixel values, and the pixel value of each pixel point in the image to be processed is updated by inquiring the pixel brightening table, so that the image to be processed can be brightened. Illustratively, the pixel brightness table may refer to a LUT (Look Up Table) map.
The pixel brightness table may be designed in advance by a developer of the image processing software and stored in a background database of the image processing software or a background database of the electronic device, and when step 501 is executed, the electronic device may directly acquire the pixel brightness table.
502. Updating the initial pixel value of each pixel point by the corresponding brightness-improving pixel value of each pixel point to obtain each updated pixel point and a new image to be processed formed by each updated pixel point.
Although a method of adding an illumination shadow is provided in step 203, this method requires identifying the edges of the target object to achieve this, which is inefficient. The present application also provides a method for adding an illumination shadow through gaussian blur, namely, the steps of adding an illumination shadow to the target object image to obtain a spot shadow image, including:
And carrying out Gaussian blur processing on the target object image to obtain a spot shadow image.
The Gaussian blur processing is used for carrying out blur processing on the edge of the target object in the target object image so as to add illumination shadows.
When gaussian blur is performed, the electronic device may perform weighted average processing of adjacent pixel values on each pixel point in the target object image, and when average processing is performed on pixel points at an edge of the target object, since pixel values of adjacent pixel points that partially belong to the target object are not 0 and pixel values of adjacent pixel points that partially do not belong to the target object are 0, a blur effect may be provided for the edge of the target object, and even if the pixel values of the adjacent pixel points that do not belong to the target object are unchanged after weighted average processing. And if the illumination shadow is added through Gaussian blur and the spotlight effect diagram is obtained through a mixing mode, the illumination shadow can be added in the spotlight effect diagram on the one hand, and on the other hand, the image noise in the spotlight effect diagram can be reduced through Gaussian blur, and detailed description is omitted for specific reasons that the Gaussian blur can reduce the image noise.
In some embodiments, the present application further provides a method for enabling a user to adjust pixel values in an image of a target object to make an image beautify and improve a visual effect of the target object in a spotlight effect map. The step of adding an illumination shadow to the target object image to obtain a spot shadow image, before the step of adding the illumination shadow to the target object image to obtain a spot shadow image, further comprises:
and responding to the adjustment operation of the target object image, and adjusting the pixel value in the target object image according to the pixel value adjustment parameter carried by the adjustment operation to obtain a new target object image.
Wherein the adjustment operation includes a hue adjustment operation, a saturation adjustment operation, a brightness adjustment operation, and/or a transparency adjustment operation.
It is understood that when the adjustment operation is a hue adjustment operation, a saturation adjustment operation, a brightness adjustment operation, and/or a transparency adjustment operation, the pixel value adjustment parameter may refer to a hue adjustment value, a saturation adjustment value, a brightness adjustment value, and/or a transparency adjustment value.
For example, the user may perform the adjustment operation through a virtual control preset in the functional interface for adding the special effects of the spotlight. For example, the user may reduce or increase the hue, saturation, brightness, and/or transparency of each pixel point in the target object image as a whole by triggering the virtual control. Or, in order to avoid adjusting other image areas except for the image area containing the target object in the target object image, and influence the visual effect of the mixed spotlight effect image, a single-channel image in the target object image can be extracted by a single-channel extraction method, the extracted single-channel image is used as a mask, and according to the weight of each pixel point in the mask, the pixel value adjusting parameter corresponding to each pixel point and the pixel value of each pixel point in the target object image are mixed, and the specific mixing method can refer to the algorithm formula and is not repeated.
In some embodiments, to improve the display effect after the light-condensing region mask is fused into the image to be processed, the edge of the light-condensing region may be processed to obtain the light-condensing region mask in which the edge of the light-condensing region exhibits a gradual change effect. Referring to fig. 6, at this time, before the step of fusing the preset spotlight region mask and the spotlight shadow image into the image to be processed to obtain the spotlight effect map, the method further includes:
601. and acquiring a first light condensing area in the image to be processed and a second light condensing area in the first light condensing area.
In some embodiments, the first light-gathering area and the second light-gathering area may be set by a user, and a specific setting method may refer to the above and will not be described again.
In other embodiments, to reduce the complexity of the user operation, the electronic device may further automatically determine the first light focusing region and the second light focusing region. Namely, the step of acquiring a first light condensing area in the image to be processed and a second light condensing area in the first light condensing area comprises the following steps:
(1.1) acquiring an image position of a target object in the image to be processed.
The method of acquiring the image position may refer to the method of detecting the target object above. It should be noted that, if the target object has been detected, the step (1.1) may be performed without detecting the image position of the target object again. Or if the image position is obtained by performing the step (1.1), the image position of the target object does not need to be detected again when the target object extraction process is performed.
(1.2) determining a first light gathering area according to the image position and a preset first area size.
(1.3) determining a second light condensing region in the first light condensing region according to the image position and a preset second region size, wherein the second region size is smaller than the first region size.
Specific values of the first area size and the second area size may be changed according to requirements of an actual scene, which is not limited in the embodiment of the present application.
The purpose of acquiring two light gathering areas is to determine the area between the two light gathering areas where a gradual change needs to be produced. For example, when the first light-condensing region and the second light-condensing region are both circular regions, a ring-shaped region that is not overlapped between the first light-condensing region and the second light-condensing region may be used as a region where gradual change is required to be generated.
602. And generating an initial mask of the image to be processed according to the position of the first light gathering region, wherein the initial mask comprises a third light gathering region corresponding to the first light gathering region and a fourth light gathering region corresponding to the second light gathering region.
It will be appreciated that the position of the third light concentrating region in the initial mask is the same as the position of the first light concentrating region in the image to be processed, and that the position of the fourth light concentrating region in the initial mask is the same as the position of the second light concentrating region in the image to be processed.
603. And carrying out gradual change treatment on the non-overlapped area between the third light condensation area and the fourth light condensation area to obtain a light condensation area shade corresponding to the image to be treated.
For example, the gradual change may be performed by feathering (that is, a non-overlapping region between the third light-focusing region and the fourth light-focusing region, by a smoothstep algorithm or the like, so as to obtain a light-focusing region mask that exhibits a gradual change effect in the non-overlapping region, where a specific parameter of the feathering may be a preset value or a value input by a user, which is not limited in the embodiment of the present application.
It can be seen that, by the method from step 601 to step 603, a spotlight region mask with a gradually changed visual effect at the edge of the spotlight region can be obtained, so as to improve the visual effect of the spotlight effect graph.
In order to better implement the image processing method in the embodiment of the present application, an image processing apparatus is further provided in the embodiment of the present application, as shown in fig. 7, which is a schematic structural diagram of an embodiment of the image processing apparatus in the embodiment of the present application, where the image processing apparatus 700 includes:
an acquiring unit 701 for acquiring an image to be processed;
An object extraction unit 702, configured to perform target object extraction processing on the image to be processed, so as to obtain a target object image;
a shadow adding unit 703, configured to add an illumination shadow to the target object image, so as to obtain a spot light shadow image;
and a fusion unit 704, configured to fuse the spotlight region mask corresponding to the image to be processed and the spotlight shadow image into the image to be processed, so as to obtain a spotlight effect diagram.
In a possible implementation of the present application, the shadow adding unit 703 is further configured to:
and carrying out Gaussian blur processing on the target object image to obtain a spot shadow image, wherein the Gaussian blur processing is used for carrying out blur processing on the edge of the target object in the target object image so as to add an illumination shadow.
In a possible implementation manner of the present application, the object extraction unit 702 is further configured to:
inquiring a preset pixel brightening table to obtain a brightening pixel value corresponding to an initial pixel value of each pixel point in the image to be processed;
updating the initial pixel value of each pixel point by the corresponding brightness-improving pixel value of each pixel point to obtain each updated pixel point and a new image to be processed formed by each updated pixel point.
In a possible implementation of the present application, the shadow adding unit 703 is further configured to:
and responding to the adjustment operation of the target object image, and adjusting the pixel value in the target object image according to the pixel value adjustment parameter carried by the adjustment operation to obtain a new target object image.
In one possible implementation of the present application, the adjustment operation includes a hue adjustment operation, a saturation adjustment operation, a brightness adjustment operation, and/or a transparency adjustment operation.
In a possible implementation manner of the present application, the fusing unit 704 is further configured to:
acquiring a first light gathering area in the image to be processed and a second light gathering area in the first light gathering area;
generating an initial mask of the image to be processed according to the position of the first light gathering area, wherein the initial mask comprises a third light gathering area corresponding to the first light gathering area and a fourth light gathering area corresponding to the second light gathering area;
and carrying out gradual change treatment on the non-overlapped area between the third light condensation area and the fourth light condensation area to obtain a light condensation area shade corresponding to the image to be treated.
In a possible implementation manner of the present application, the fusing unit 704 is further configured to:
acquiring an image position of a target object in the image to be processed;
determining a first light gathering area according to the image position and a preset first area size;
and determining a second light condensing area in the first light condensing area according to the image position and a preset second area size, wherein the second area size is smaller than the first area size.
In a possible implementation manner of the present application, the fusing unit 704 is further configured to:
performing single-channel extraction on the spot shadow image to obtain a target shade of the spot shadow image;
mixing the pixel value of each pixel point in the spot light shadow image and the pixel value of each pixel point in the image to be processed according to the weight of each pixel point in the target shade to obtain a mixed image;
and merging the light focusing area shade corresponding to the image to be processed into the mixed image to obtain a spotlight effect diagram.
In the implementation, each module may be implemented as an independent entity, or may be combined arbitrarily, and implemented as the same entity or several entities, and the implementation of each module may be referred to the foregoing method embodiment, which is not described herein again.
Since the image processing apparatus may execute steps in the image processing method in any embodiment, the beneficial effects that can be achieved by the image processing method in any embodiment of the present application may be achieved, which is described in detail in the foregoing description and will not be repeated here.
In addition, in order to better implement the image processing method in the embodiment of the present application, on the basis of the image processing method, the embodiment of the present application further provides an electronic device, referring to fig. 8, fig. 8 shows a schematic structural diagram of the electronic device in the embodiment of the present application, and specifically, the electronic device provided in the embodiment of the present application includes a processor 801, where the processor 801 is configured to implement each step of the image processing method in any embodiment when executing a computer program stored in a memory 802; alternatively, the processor 801 is configured to implement the functions of the respective modules in the corresponding embodiment of fig. 7 when executing the computer program stored in the memory 802.
By way of example, a computer program may be partitioned into one or more modules/units that are stored in memory 802 and executed by processor 801 to accomplish the embodiments of the present application. One or more of the modules/units may be a series of computer program instruction segments capable of performing particular functions to describe the execution of the computer program in a computer device.
Electronic devices may include, but are not limited to, processor 801, memory 802. It will be appreciated by those skilled in the art that the illustrations are merely examples of electronic devices and are not limiting of electronic devices, and may include more or fewer components than illustrated, or may combine certain components, or different components.
The processor 801 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, which is a control center for an electronic device, with various interfaces and lines connecting various parts of the overall electronic device.
The memory 802 may be used to store computer programs and/or modules, and the processor 801 implements various functions of the computer device by running or executing the computer programs and/or modules stored in the memory 802 and invoking data stored in the memory 802. The memory 802 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like; the storage data area may store data (such as audio data, video data, etc.) created according to the use of the electronic device, and the like. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as a hard disk, memory, plug-in hard disk, smart Media Card (SMC), secure Digital (SD) Card, flash Card (Flash Card), at least one disk storage device, flash memory device, or other volatile solid-state storage device.
It will be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process of the image processing apparatus, the electronic device and the corresponding modules described above may refer to the description of the image processing method in any embodiment, and will not be described in detail herein.
Those of ordinary skill in the art will appreciate that all or a portion of the steps of the various methods of the above embodiments may be performed by instructions or by controlling associated hardware, which may be stored on a readable storage medium and loaded and executed by a processor.
To this end, the embodiments of the present application provide a readable storage medium, on which a computer program is stored, which when executed by a processor performs steps in the image processing method in any embodiment of the present application, and specific operations may be referred to in the description of the image processing method in any embodiment.
Wherein the readable storage medium may include: read Only Memory (ROM), random access Memory (RAM, random Access Memory), magnetic or optical disk, and the like.
The steps in the image processing method in any embodiment of the present application may be executed due to the instructions stored in the readable storage medium, so that the beneficial effects that can be achieved by the image processing method in any embodiment of the present application may be achieved, which are described in detail in the foregoing description and are not repeated herein.
The foregoing describes in detail an image processing method, apparatus, storage medium and electronic device provided in the embodiments of the present application, and specific examples are applied to illustrate principles and implementations of the present application, where the foregoing description of the embodiments is only used to help understand the method and core idea of the present application; meanwhile, those skilled in the art will have variations in the specific embodiments and application scope in light of the ideas of the present application, and the present description should not be construed as limiting the present application in view of the above.

Claims (11)

1. An image processing method, comprising:
acquiring an image to be processed;
performing target object extraction processing on the image to be processed to obtain a target object image;
adding illumination shadows to the target object image to obtain a spot shadow image;
and fusing the spotlight region shade corresponding to the image to be processed and the spotlight shadow image into the image to be processed to obtain a spotlight effect diagram.
2. The image processing method according to claim 1, wherein adding an illumination shadow to the target object image to obtain a spot shadow image includes:
And carrying out Gaussian blur processing on the target object image to obtain a spot shadow image, wherein the Gaussian blur processing is used for carrying out blur processing on the edge of the target object in the target object image so as to add an illumination shadow.
3. The image processing method according to claim 1, wherein before the target object extraction processing is performed on the image to be processed to obtain a target object image, further comprising:
inquiring a preset pixel brightening table to obtain a brightening pixel value corresponding to an initial pixel value of each pixel point in the image to be processed;
updating the initial pixel value of each pixel point by the corresponding brightness-improving pixel value of each pixel point to obtain each updated pixel point and a new image to be processed formed by each updated pixel point.
4. The image processing method according to claim 1, wherein before adding an illumination shadow to the target object image to obtain a spot shadow image, further comprising:
and responding to the adjustment operation of the target object image, and adjusting the pixel value in the target object image according to the pixel value adjustment parameter carried by the adjustment operation to obtain a new target object image.
5. The image processing method according to claim 4, wherein the adjustment operation includes a hue adjustment operation, a saturation adjustment operation, a brightness adjustment operation, and/or a transparency adjustment operation.
6. The image processing method according to claim 1, wherein the fusing the preset spotlight region mask and the spotlight shadow image into the image to be processed, before obtaining the spotlight effect map, further comprises:
acquiring a first light gathering area in the image to be processed and a second light gathering area in the first light gathering area;
generating an initial mask of the image to be processed according to the position of the first light gathering area, wherein the initial mask comprises a third light gathering area corresponding to the first light gathering area and a fourth light gathering area corresponding to the second light gathering area;
and carrying out gradual change treatment on the non-overlapped area between the third light condensation area and the fourth light condensation area to obtain a light condensation area shade corresponding to the image to be treated.
7. The image processing method according to claim 6, wherein the acquiring a first condensed region in the image to be processed and a second condensed region within the first condensed region includes:
Acquiring an image position of a target object in the image to be processed;
determining a first light gathering area according to the image position and a preset first area size;
and determining a second light condensing area in the first light condensing area according to the image position and a preset second area size, wherein the second area size is smaller than the first area size.
8. The image processing method according to any one of claims 1 to 7, wherein the fusing the spotlight region mask corresponding to the image to be processed and the spotlight shadow image into the image to be processed to obtain a spotlight effect map includes:
performing single-channel extraction on the spot shadow image to obtain a target shade of the spot shadow image;
mixing the pixel value of each pixel point in the spot light shadow image and the pixel value of each pixel point in the image to be processed according to the weight of each pixel point in the target shade to obtain a mixed image;
and merging the light focusing area shade corresponding to the image to be processed into the mixed image to obtain a spotlight effect diagram.
9. An image processing apparatus, comprising:
An acquisition unit configured to acquire an image to be processed;
the object extraction unit is used for carrying out object extraction processing on the image to be processed to obtain a target object image;
the shadow adding unit is used for adding illumination shadows for the target object image to obtain a spot light shadow image;
and the fusion unit is used for fusing the spotlight region shade corresponding to the image to be processed and the spotlight shadow image into the image to be processed to obtain a spotlight effect diagram.
10. An electronic device comprising a processor, a memory and a computer program stored in the memory and executable on the processor, the processor implementing the steps in the image processing method according to any one of claims 1 to 8 when the computer program is executed by the processor.
11. A readable storage medium, characterized in that the readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the image processing method of any of claims 1 to 8.
CN202310169020.0A 2023-02-24 2023-02-24 Image processing method, device, electronic equipment and readable storage medium Pending CN117726570A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310169020.0A CN117726570A (en) 2023-02-24 2023-02-24 Image processing method, device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310169020.0A CN117726570A (en) 2023-02-24 2023-02-24 Image processing method, device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN117726570A true CN117726570A (en) 2024-03-19

Family

ID=90209317

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310169020.0A Pending CN117726570A (en) 2023-02-24 2023-02-24 Image processing method, device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN117726570A (en)

Similar Documents

Publication Publication Date Title
US11410277B2 (en) Method and device for blurring image background, storage medium and electronic apparatus
RU2622874C1 (en) Method, device and server of recognizing confidential photograph
US11210541B2 (en) Liveness detection method, apparatus and computer-readable storage medium
CN111523438B (en) Living body identification method, terminal equipment and electronic equipment
US9734591B2 (en) Image data processing method and electronic device supporting the same
KR101725884B1 (en) Automatic processing of images
US9881202B2 (en) Providing visual effects for images
GB2553641B (en) Techniques for selecting objects in images
CN109685746A (en) Brightness of image method of adjustment, device, storage medium and terminal
CN108830892B (en) Face image processing method and device, electronic equipment and computer readable storage medium
CN108921856B (en) Image cropping method and device, electronic equipment and computer readable storage medium
US10222930B2 (en) Method, apparatus, and storage medium for playing control processing of audio file
US9799099B2 (en) Systems and methods for automatic image editing
WO2019085698A1 (en) White balance processing method and device, electronic device and computer readable storage medium
EP3254283B1 (en) User sliders for simplified adjustment of images
CN105430269B (en) A kind of photographic method and device applied to mobile terminal
US20230162419A1 (en) Picture processing method and apparatus, device, and storage medium
CN108921798B (en) Image processing method and device and electronic equipment
JP2015075920A (en) Image processing apparatus, image processing method, and program
CN108494996A (en) Image processing method, device, storage medium and mobile terminal
US20190205689A1 (en) Method and device for processing image, electronic device and medium
US8804029B2 (en) Variable flash control for improved image detection
US20210084223A1 (en) Apparatus and methods for camera selection in a multi-camera
CN109934777B (en) Image local invariant feature extraction method, device, computer equipment and storage medium
CN117726570A (en) Image processing method, device, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination