Image processing method and device
By using the luminous grayscale map generated by the two-dimensional Gaussian function in image processing, the problem of low image quality shooting without turning on the flash is solved, and the image brightness is improved and the luminous effect is simulated.
Patent Information
- Application Number
- CN202111218571.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-19
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2041-10-19
AI Technical Summary
Images captured without the flash turned on have poor image quality due to lack of lighting effects.
By obtaining the image to be processed, the face area is determined, and a luminescent grayscale map is generated based on the preset two-dimensional Gaussian function, the center position and width of the face area, and superimposing it to the image to be processed to add the luminescent effect.
The overall brightness of the image is improved, especially in the face area, and the lighting effect of the flash is simulated, thereby improving the image quality.
Smart Images

Figure CN114066909B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of computer technology, and in particular, to an image processing method, device, electronic device, computer-readable storage medium, and computer program product. Background Art
[0002] With the continuous development of electronic technology, people have more and more opportunities to take photos through electronic devices. How to take better photos is a current research topic.
[0003] When shooting portraits in many darker scenes today, if you want to get high-quality photos, in addition to increasing the brightness of the shooting scene through additional light sources, you can also turn on the flash of the shooting equipment to improve the shooting effect, thereby obtaining clear and natural portraits.
[0004] However, in the current solution, since the flash is often forgotten to be turned on when taking images, or the obtained images are taken without turning on the flash, these images will have low quality due to lack of lighting effect. Summary of the invention
[0005] The embodiments of the present disclosure provide an image processing method, apparatus, electronic device, computer-readable storage medium, and computer program product to solve the problem in the related art that when images are taken without turning on the flash, the images have low quality due to lack of lighting effect.
[0006] In a first aspect, an embodiment of the present disclosure provides an image processing method, the method comprising:
[0007] Acquire an image to be processed, wherein the image to be processed contains a target object;
[0008] Determine the face area of the target object in the image to be processed;
[0009] Generate a lighting grayscale image having the same size as the image to be processed according to a preset first two-dimensional Gaussian function, the center position of the face area and the width of the face area; wherein the first two-dimensional Gaussian function is used to generate a lighting grayscale image including a lighting special effect, the center position of the face area is used to determine the position of the area where the lighting special effect is located, and the width of the face area is used to determine the size of the area where the lighting special effect is located;
[0010] The lighting grayscale image is superimposed on the image to be processed to obtain a target image with the lighting special effect added thereto.
[0011] In an optional implementation, superimposing the lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added includes:
[0012] Acquire a lighting intensity value, and determine a first ratio between the lighting intensity value and a maximum pixel value of the lighting grayscale image; the lighting intensity value is used to determine the intensity of the lighting special effect;
[0013] Multiplying the pixel value in the lighting grayscale image by the first ratio to obtain a target lighting grayscale image;
[0014] Superimposing the target lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added;
[0015] Among them, the pixel value of the area where the lighting effects are located in the target lighting grayscale map is greater than the pixel value of the area other than the area where the lighting effects are located in the target lighting grayscale map, and the value range of the pixel value of the target lighting grayscale map is constrained within the range formed by the lighting upper limit value and the lighting lower limit value, and the lighting upper limit value and the lighting lower limit value are determined by a preset first coefficient and the average grayscale value of the image to be processed.
[0016] In an optional implementation, superimposing the target lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added includes:
[0017] Adjusting the range of pixel values of the image to be processed to be the same as the range of the target lighting grayscale image;
[0018] Input the pixel values of the image to be processed and the pixel values of the target lighting grayscale image into a preset superposition function to obtain the pixel values output by the superposition function; the superposition function is used to determine the bright area and the dark area of the target lighting grayscale image, and increase the pixel value of the area corresponding to the bright area in the image to be processed, and decrease the pixel value of the area corresponding to the dark area; the bright area is an area with a pixel value greater than a preset brightness value, and the dark area is an area with a pixel value less than or equal to the preset brightness value;
[0019] The value range of the image constructed according to the pixel values output by the superposition function is adjusted to be the same as the value range of the image to be processed, so as to obtain the target image.
[0020] In an optional implementation, the method further includes:
[0021] When the average grayscale value of the face area in the target image is greater than the preset grayscale value, the lighting intensity value is reduced, and the step of obtaining the lighting intensity value and determining the first ratio between the lighting intensity value and the maximum pixel value of the lighting grayscale image is re-entered until the average grayscale value of the face area in the new target image is less than or equal to the preset grayscale value.
[0022] In an optional implementation, before generating a lighting grayscale image having the same size as the image to be processed according to the preset first two-dimensional Gaussian function, the center position of the face area, and the width of the face area, the method further includes:
[0023] Generate a fill light grayscale image having the same size as the image to be processed according to a preset second two-dimensional Gaussian function, the center position of the face area and the width of the face area; the second two-dimensional Gaussian function is used to generate a fill light grayscale image including a fill light special effect, the center position of the face area is used to determine the position of the fill light special effect area, and the width of the face area is used to determine the size of the fill light special effect area;
[0024] Superimposing the fill light grayscale image on the image to be processed to obtain the image to be processed with the fill light special effect added;
[0025] The value range of the pixel value of the fill light grayscale image is constrained within a range formed by a fill light upper limit value and a fill light lower limit value, and the fill light upper limit value and the fill light lower limit value are determined by a preset second coefficient and an average grayscale value of the image to be processed.
[0026] In an optional implementation manner, superimposing the fill light grayscale image onto the image to be processed to obtain the image to be processed with the fill light special effect added includes:
[0027] Adjusting the value range of the fill light grayscale image to be the same as the value range of the image to be processed;
[0028] The pixel value of the first pixel in the fill light grayscale image is added to the pixel value of the second pixel corresponding to the first pixel in the image to be processed, so as to obtain the image to be processed with the fill light special effect added thereto.
[0029] In an optional implementation, before generating a lighting grayscale image having the same size as the image to be processed according to the preset first two-dimensional Gaussian function, the center position of the face area, and the width of the face area, the method further includes:
[0030] A darkened grayscale image having the same size as the image to be processed is generated according to a preset regular image generation function, the center position of the image to be processed, and the width and height of the image to be processed; the regular image generation function is used to generate a darkened grayscale image including a darkening effect, the darkened grayscale image includes a regular shape area with unchanged pixel values, the area where the darkening effect is located is an area outside the regular shape area, the center position of the image to be processed is used to determine the position of the regular shape area, and the width and height of the image to be processed are used to determine the size of the regular shape area; the pixel value of the area where the darkening effect is located is smaller than the pixel value of the regular shape area;
[0031] The darkening grayscale image is superimposed on the image to be processed to obtain the image to be processed with the darkening special effect added to the four corners.
[0032] In an optional implementation, superimposing the darkened grayscale image onto the image to be processed to obtain the image to be processed with the darkened special effect added to the four corners includes:
[0033] After blurring the darkened grayscale image, multiplying the pixel value of the third pixel in the darkened grayscale image by the pixel value of the fourth pixel in the image to be processed corresponding to the third pixel, to obtain the image to be processed with the darkening special effect added;
[0034] The value range of the pixel value of the darkened grayscale image after the blurring process is constrained within the range formed by the preset third coefficient and the fourth coefficient.
[0035] In an optional implementation, the method further includes:
[0036] The target image is post-processed by a smooth step function to reduce the brightness of a dark area in the target image, where the dark area is an area where the pixel value is less than or equal to a preset brightness value.
[0037] In an optional implementation, the post-processing the target image by using a smooth step function to reduce the brightness of a dark area in the target image includes:
[0038] Converting the target image into a first grayscale image, and normalizing the first grayscale image;
[0039] The pixel values of the dark areas in the first grayscale image are reduced, and the pixel values of the bright areas are increased, to obtain a second grayscale image; the bright areas are areas where the pixel values are greater than a preset brightness value, and the dark areas are areas where the pixel values are less than or equal to the preset brightness value;
[0040] Calculating the ratio of the pixel value in the second grayscale image to the pixel value in the first grayscale image, and constructing a third grayscale image using the ratio as the pixel value; the value range of the third grayscale image is constrained within a preset value range;
[0041] The pixel value of the fifth pixel in the third grayscale image is multiplied by the pixel value of the sixth pixel corresponding to the fifth pixel in the target image to obtain a target image with reduced brightness of the dark area.
[0042] In a second aspect, an embodiment of the present disclosure further provides an image processing device, the device comprising:
[0043] An acquisition module is configured to acquire an image to be processed, wherein the image to be processed contains a target object;
[0044] A recognition module, configured to determine a face region of a target object in the image to be processed;
[0045] A lighting module is configured to generate a lighting grayscale image having the same size as the image to be processed according to a preset first two-dimensional Gaussian function, the center position of the face area and the width of the face area; wherein the first two-dimensional Gaussian function is used to generate a lighting grayscale image including a lighting special effect, the center position of the face area is used to determine the position of the area where the lighting special effect is located, and the width of the face area is used to determine the size of the area where the lighting special effect is located;
[0046] The first superposition module is configured to superimpose the lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added thereto.
[0047] In an optional implementation, the first superposition module includes:
[0048] An acquisition submodule is configured to acquire a lighting intensity value and determine a first ratio between the lighting intensity value and a maximum pixel value of the lighting grayscale image; the lighting intensity value is used to determine the intensity of the lighting special effect;
[0049] an intensity setting submodule, configured to multiply the pixel value in the lighting grayscale image by the first ratio to obtain a target lighting grayscale image;
[0050] A first superposition submodule is configured to superimpose the target lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added thereto;
[0051] Among them, the pixel value of the area where the lighting effects are located in the target lighting grayscale map is greater than the pixel value of the area other than the area where the lighting effects are located in the target lighting grayscale map, and the value range of the pixel value of the target lighting grayscale map is constrained within the range formed by the lighting upper limit value and the lighting lower limit value, and the lighting upper limit value and the lighting lower limit value are determined by a preset first coefficient and the average grayscale value of the image to be processed.
[0052] In an optional implementation, the first superposition submodule includes:
[0053] An adjustment unit, configured to adjust the value range of the pixel values of the image to be processed to be the same as the value range of the target lighting grayscale image;
[0054] The superposition function unit is configured to input the pixel values of the image to be processed and the pixel values of the target lighting grayscale image into a preset superposition function to obtain the pixel values output by the superposition function; the superposition function is used to determine the bright area and the dark area of the target lighting grayscale image, and increase the pixel value of the area corresponding to the bright area in the image to be processed, and decrease the pixel value of the area corresponding to the dark area; the bright area is an area with a pixel value greater than a preset brightness value, and the dark area is an area with a pixel value less than or equal to the preset brightness value;
[0055] The constraint unit is configured to adjust the value range of the image constructed according to the pixel values output by the superposition function to be the same as the value range of the image to be processed, so as to obtain the target image.
[0056] In an optional embodiment, the first superposition module includes:
[0057] The overexposure processing submodule is configured to reduce the lighting intensity value when the average grayscale value of the face area in the target image is greater than a preset grayscale value, re-enter the step of obtaining the lighting intensity value, and determine a first ratio between the lighting intensity value and the maximum pixel value of the lighting grayscale image, until the average grayscale value of the face area in the new target image is obtained, which is less than or equal to the preset grayscale value.
[0058] In an optional embodiment, the device further comprises:
[0059] A fill light module is configured to generate a fill light grayscale image having the same size as the image to be processed according to a preset second two-dimensional Gaussian function, the center position of the face area and the width of the face area; the second two-dimensional Gaussian function is used to generate a fill light grayscale image including a fill light special effect, the center position of the face area is used to determine the position of the fill light special effect area, and the width of the face area is used to determine the size of the fill light special effect area;
[0060] A second superposition module is configured to superimpose the fill light grayscale image onto the image to be processed to obtain the image to be processed with the fill light special effect added thereto;
[0061] The value range of the pixel value of the fill light grayscale image is constrained within a range formed by a fill light upper limit value and a fill light lower limit value, and the fill light upper limit value and the fill light lower limit value are determined by a preset second coefficient and an average grayscale value of the image to be processed.
[0062] In an optional implementation, the second superposition module includes:
[0063] A first adjustment submodule is configured to adjust the value range of the fill light grayscale image to be the same as the value range of the image to be processed;
[0064] The adding submodule is configured to add the pixel value of the first pixel point in the fill light grayscale image and the pixel value of the second pixel point corresponding to the first pixel point in the image to be processed to obtain the image to be processed with the fill light special effect added.
[0065] In an optional embodiment, the device further comprises:
[0066] A darkening special effect module is configured to generate a darkening grayscale image of the same size as the image to be processed according to a preset regular image generation function, the center position of the image to be processed, and the width and height of the image to be processed; the regular image generation function is used to generate a darkening grayscale image including a darkening special effect, the darkening grayscale image includes a regular shape area with unchanged pixel values, the area where the darkening special effect is located is an area outside the regular shape area, the center position of the image to be processed is used to determine the position of the regular shape area, and the width and height of the image to be processed are used to determine the size of the regular shape area; the pixel value of the area where the darkening special effect is located is smaller than the pixel value of the regular shape area;
[0067] The third superposition module is configured to superimpose the darkened grayscale image onto the image to be processed to obtain the image to be processed with the darkening special effect added to the four corners.
[0068] In an optional implementation, the third superposition module includes:
[0069] a blur processing submodule configured to, after blurring the darkened grayscale image, multiply the pixel value of a third pixel in the darkened grayscale image by the pixel value of a fourth pixel in the image to be processed corresponding to the third pixel, to obtain the image to be processed with the darkening special effect added thereto;
[0070] The value range of the pixel value of the darkened grayscale image after the blurring process is constrained within the range formed by the preset third coefficient and the fourth coefficient.
[0071] In an optional embodiment, the device further comprises:
[0072] The smoothing processing module is configured to post-process the target image through a smoothing step function to reduce the brightness of a dark area in the target image, where the dark area is an area where the pixel value is less than or equal to a preset brightness value.
[0073] In an optional implementation, the smoothing processing module includes:
[0074] A conversion submodule, configured to convert the target image into a first grayscale image and normalize the first grayscale image;
[0075] A first processing submodule is configured to reduce the pixel value of the dark area in the first grayscale image and increase the pixel value of the bright area to obtain a second grayscale image; the bright area is an area where the pixel value is greater than a preset brightness value, and the dark area is an area where the pixel value is less than or equal to the preset brightness value;
[0076] The second processing submodule is configured to calculate the ratio of the pixel value in the second grayscale image to the pixel value in the first grayscale image, and construct a third grayscale image using the ratio as the pixel value; the value range of the third grayscale image is constrained within a preset value range;
[0077] The multiplication submodule is configured to multiply the pixel value of the fifth pixel point in the third grayscale image by the pixel value of the sixth pixel point corresponding to the fifth pixel point in the target image to obtain a target image with reduced brightness of the dark area.
[0078] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the image processing.
[0079] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, which, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the image processing.
[0080] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, including a computer program, which implements the image processing when executed by a processor.
[0081] In an embodiment of the present disclosure, it includes: obtaining an image to be processed, wherein the image to be processed includes a target object; determining the face area of the target object in the image to be processed; generating a lighting grayscale image of the same size as the image to be processed according to a preset first two-dimensional Gaussian function, the center position of the face area, and the width of the face area; and superimposing the lighting grayscale image on the image to be processed to obtain a target image with a lighting effect added. The present disclosure can use a two-dimensional Gaussian function to generate a lighting grayscale image including a lighting effect. For an image to be processed that needs to add a lighting effect to enhance the image quality, the lighting grayscale image can be superimposed on the image to be processed to obtain a target image with a lighting effect added, so that the effect presented by the target image is to highlight the brightness of the face area and reduce the brightness of other areas, thereby simulating the lighting effect of a flash.
[0082] The above description is only an overview of the technical solution of the present disclosure. In order to more clearly understand the technical means of the present disclosure, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present disclosure more obvious and easy to understand, the specific implementation methods of the present disclosure are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present disclosure. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0084] Figure 1 is a flowchart of the steps of an image processing method provided by an embodiment of the present disclosure;
[0085] Figure 2 A schematic diagram of a light-dark process provided by an embodiment of the present disclosure;
[0086] Figure 3 A flowchart of specific steps of an image processing method provided by an embodiment of the present disclosure;
[0087] Figure 4 A schematic diagram of a light-darkness filling process provided by an embodiment of the present disclosure;
[0088] Figure 5 A schematic diagram of a darkening process provided by an embodiment of the present disclosure;
[0089] Figure 6 A schematic diagram of image overexposure provided by an embodiment of the present disclosure;
[0090] Figure 7 A schematic diagram of image smoothing processing provided by an embodiment of the present disclosure;
[0091] Figure 8A block diagram of an image processing device provided by an embodiment of the present disclosure;
[0092] Fig. 9 A logical block diagram of an electronic device according to an embodiment of the present disclosure;
[0093] Fig.10 A logical block diagram of an electronic device according to another embodiment of the present disclosure. DETAILED DESCRIPTION
[0094] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0095] Figure 1 is a flowchart of the steps of an image processing method provided by an embodiment of the present disclosure, such as Figure 1 As shown, the method may include:
[0096] Step 101: Acquire an image to be processed, wherein the image to be processed contains a target object.
[0097] In the embodiments of the present disclosure, the image to be processed may be an image including a target object, and the target object may be an object such as a person, an animal, or an object to which a special lighting effect needs to be added, and the special lighting effect is a special effect that simulates the effect of a flash photography. Specifically, the embodiments of the present disclosure may be described below with the target object being a person object. When the target object is a person object, the image to be processed may further capture the face area of the person object.
[0098] Furthermore, in actual scenarios, the image to be processed may be an image that requires the addition of lighting effects, such as an image taken by a user in a dark environment without turning on the flash; an image obtained by a user that was taken in a dark environment without turning on the flash; or an image to which the user needs to add lighting effects to enhance the beauty of the picture based on actual needs.
[0099] Step 102: Determine the face region of the target object in the image to be processed.
[0100] In this step, face recognition technology can be used to determine the face area of the target object in the image to be processed. The face area is the area where the face of the target object is located, and specifically can be the area selected by the face recognition frame. After the face area is determined, the center point position of the face area and the size (width and height) of the face area can be obtained to add subsequent lighting effects.
[0101] Step 103: Generate a lighting grayscale image with the same size as the image to be processed according to a preset first two-dimensional Gaussian function, the center position of the face area, and the width of the face area.
[0102] Among them, the first two-dimensional Gaussian function is used to generate a lighting grayscale map including lighting effects, the center position of the face area is used to determine the position of the area where the lighting effects are located, and the width of the face area is used to determine the size of the area where the lighting effects are located.
[0103] In the disclosed embodiment, a lighting effect is added to the target object of the image to be processed, which can be specifically characterized as increasing the overall brightness of the image to be processed, and at the same time relatively concentrating the increased brightness on the face area of the target object, so that the brightness of the face area is greater than that of other areas, presenting an effect of simulating flash lighting in the face area.
[0104] Specifically, the embodiments of the present disclosure can achieve the purpose of increasing the overall brightness of the image to be processed by superimposing a lighting grayscale map on the image to be processed, while relatively concentrating the increased brightness on the face area of the target object, wherein the lighting grayscale map can be generated by a first two-dimensional Gaussian function, which is also called a normal distribution function. Since the function image of the Gaussian function is similar to the grayscale histogram distribution of the image, the Gaussian function can be used to simulate the grayscale distribution of the image in actual processing.
[0105] In the embodiment of the present disclosure, the first two-dimensional Gaussian function is a two-dimensional Gaussian function, which takes the center position of the face area and the width of the face area as input, and takes a lighting grayscale image including the lighting effect as output. The center position of the face area can be used to determine the position of the area where the lighting effect is located, specifically to control the position of the pixel with the maximum brightness in the lighting effect, and the width of the face area can be used as the covariance of the Gaussian function to determine the size of the area where the lighting effect is located; wherein, the covariance can construct a covariance symmetric matrix in the Gaussian distribution (the area where the lighting effect is located), which determines the shape of the Gaussian distribution. The larger the covariance, the smoother the descent of the distribution, making the area where the lighting effect is located larger; the smaller the covariance, the less smooth the descent of the distribution, making the area where the lighting effect is located smaller.
[0106] Through a priori analysis of various sample face regions, it is found that the widths of different faces are generally similar, while the heights of different faces vary greatly. Therefore, the width of the face region is selected as the covariance to generate the lighting grayscale map, which can make the size of the lighting effects more consistent with the characteristics of different faces and reduce the problems caused by the differences. In addition, since the size of the image generated by the first two-dimensional Gaussian function can be controlled, the embodiment of the present disclosure can set the size of the image output by the first two-dimensional Gaussian function to be the same as the size of the image to be processed, so as to facilitate the subsequent superposition of lighting effects.
[0107] Reference Figure 2 , Figure 2 It is a schematic diagram of a lighting process provided by an embodiment of the present disclosure, including an image to be processed 10, a lighting grayscale image 20 and a target image 30 with a lighting special effect added.
[0108] For the image 10 to be processed, the embodiment of the present disclosure can determine the face area 11 in the image 10 to be processed, as well as the center position and width of the face area 11, through face recognition technology, and then generate a lighting grayscale image 20 using the first two-dimensional Gaussian function, the center position and width of the face area, and the lighting grayscale image 20 having an area 21 where the lighting special effects are located. It can be seen that due to the existence of the covariance symmetric matrix obtained by taking the width of the face area 11 as the covariance, the impact of the lighting grayscale image 20 in the covariance symmetric matrix is to generate a lighting special effects area 21 with a brightness greater than that of other areas, and the lighting special effects area 21 corresponds to the face area 11 of the image 10 to be processed.
[0109] It should be noted that the probability distribution based on the covariance symmetric matrix has a distribution characteristic of being dense inside and sparse outside, so that the part close to the edge of the area 21 where the lighting effect is located presents a blurred liquefied effect. Therefore, when the lighting effect is added later, since the embodiment of the present disclosure superimposes the entire lighting grayscale image 20 onto the entire image to be processed 10, the lighting is performed on the entire image, and the brightness of the edge of the face area 31 with the lighting effect added can present a slowly gradient effect, making the connection between the face area 31 with the lighting effect added and other areas more natural and soft. However, in the related technology, only the face area is illuminated, which will cause the brightness connection between the face area and other areas to be unnatural and the lighting effect to be stiff. Therefore, the embodiment of the present disclosure further improves the beauty of the lighting effect.
[0110] Step 104: superimpose the lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added thereto.
[0111] In the disclosed embodiment, the lighting grayscale image is superimposed on the image to be processed by using a superposition function set for lighting special effects, and the pixel values of the lighting grayscale image and the pixel values of the image to be processed are calculated to generate new pixel values, and the target image is constructed based on the new pixel values. The purpose of the superposition function is to determine the bright and dark areas of the lighting grayscale image, and increase the pixel values of the areas corresponding to the bright areas in the image to be processed, and decrease the pixel values of the areas corresponding to the dark areas, so that the effect presented by the target image is to highlight the brightness of the face area and reduce the brightness of other areas, thereby simulating the lighting effect of a flash.
[0112] Reference Figure 2, a target image 30 can be obtained by superimposing the lighting grayscale image 20 onto the image to be processed 10. During the superimposition process, the brightness of the face area 11 of the image to be processed 10 is enhanced through the lighting effect area 21, presenting an effect of simulating flash lighting, thereby obtaining a target image 30 with a lighting effect added. The face area 31 of the target image 30 is brighter than the original image, and the other areas of the target image 30 except the face area 31 are darker than the original image.
[0113] In summary, an image processing method provided by an embodiment of the present disclosure includes: obtaining an image to be processed, wherein the image to be processed includes a target object; determining the face area of the target object in the image to be processed; generating a lighting grayscale image of the same size as the image to be processed according to a preset first two-dimensional Gaussian function, the center position of the face area, and the width of the face area; and superimposing the lighting grayscale image on the image to be processed to obtain a target image with a lighting effect added. The present disclosure can use a two-dimensional Gaussian function to generate a lighting grayscale image including a lighting effect. For an image to be processed that needs to add a lighting effect to enhance the image quality, the lighting grayscale image can be superimposed on the image to be processed to obtain a target image with a lighting effect added, so that the effect presented by the target image is to highlight the brightness of the face area and reduce the brightness of other areas, thereby simulating the lighting effect of a flash.
[0114] Figure 3 is a flowchart of another image processing method provided by an embodiment of the present disclosure. Figure 3 As shown, the method may include:
[0115] Step 201: Acquire an image to be processed, wherein the image to be processed contains a target object.
[0116] This step may specifically refer to the above step 101, which will not be described in detail here.
[0117] Step 202: Determine the face region of the target object in the image to be processed.
[0118] This step may specifically refer to the above step 102, which will not be described in detail here.
[0119] Optionally, after step 202, the following steps may also be included:
[0120] Step 203: Generate a fill light grayscale image with the same size as the image to be processed according to a preset second two-dimensional Gaussian function, the center position of the face area, and the width of the face area.
[0121] Among them, the second two-dimensional Gaussian function is used to generate a fill light grayscale image including a fill light effect, the center position of the face area is used to determine the position of the fill light effect area, and the width of the face area is used to determine the size of the fill light effect area.
[0122] The value range of the pixel value of the fill light grayscale image is constrained within a range formed by a fill light upper limit value and a fill light lower limit value, and the fill light upper limit value and the fill light lower limit value are determined by a preset second coefficient and an average grayscale value of the image to be processed.
[0123] In the disclosed embodiment, before adding lighting effects to the processed image, fill light may be applied to the face area of the processed image to slightly increase the brightness of the face area, thereby increasing the lighting effect when subsequent lighting operations are performed based on the processed image after fill light.
[0124] Specifically, the embodiment of the present disclosure can slightly improve the brightness of the face area by superimposing a fill light grayscale image on the image to be processed. The second two-dimensional Gaussian function is a two-dimensional Gaussian function, which takes the center position of the face area and the width of the face area as input, and takes the fill light grayscale image including the lighting effect as output. The center position of the face area can be used to determine the position of the fill light effect area, specifically to control the position of the pixel with the maximum brightness in the fill light effect, and the width of the face area can be used as the covariance of the Gaussian function to determine the size of the fill light effect area; the covariance determines the shape of the Gaussian distribution. The larger the covariance, the smoother the distribution declines, making the fill light effect area larger; the smaller the covariance, the less smooth the distribution declines, making the fill light effect area smaller. Since the size of the image generated by the second two-dimensional Gaussian function can be controlled, the embodiment of the present disclosure can set the size of the image output by the second two-dimensional Gaussian function to be the same as the size of the image to be processed, so as to facilitate the subsequent superimposition of the fill light effect.
[0125] Reference Figure 4 , Figure 4 It is a schematic diagram of a fill light process provided by an embodiment of the present disclosure, including an image to be processed 40, a fill light grayscale image 50 and an image to be processed 60 with a fill light special effect added thereto.
[0126] For the image 40 to be processed, the embodiment of the present disclosure can determine the face area 41 in the image 40 to be processed, as well as the center position and width of the face area 41, through face recognition technology, and then generate a fill light grayscale image 50 using a second two-dimensional Gaussian function, the center position and width of the face area, wherein the fill light grayscale image 50 has an area 51 where the fill light special effect is located. It can be seen that due to the existence of the covariance symmetric matrix obtained by taking the width of the face area 41 as the covariance, the impact of the fill light grayscale image 50 in the covariance symmetric matrix is to generate an area 51 where the fill light special effect is located, whose brightness is greater than that of other areas, and the area 51 where the fill light special effect is located corresponds to the face area 41 of the image 40 to be processed.
[0127] Furthermore, the disclosed embodiment needs to constrain the value range of the pixel value of the fill light grayscale image so that its value range is within the range formed by the fill light upper limit value and the fill light lower limit value, thereby avoiding the fill light intensity being too strong or too weak. The fill light upper limit value and the fill light lower limit value can be specifically determined by a preset second coefficient and the average grayscale value of the image to be processed, so that the fill light intensity constraint range can be more closely matched to the image to be processed.
[0128] In one implementation, since the maximum value of the pixel value of the grayscale image is 1 and the minimum value is 0, after obtaining the image to be processed, the average grayscale value ambiance of the image to be processed can be calculated, and according to actual needs, the second coefficient 0.15 and the second coefficient 0.2 are preset, the upper limit value of the fill light is 0.2, and the lower limit value of the fill light is 0.15-ambiance, thereby constituting the fill light intensity constraint range (0.15-ambiance, 0.2), which means that pixel values greater than 0.2 in the fill light grayscale image output by the second two-dimensional Gaussian function will be adjusted to 0.2, and pixel values less than 0.15-ambiance will be adjusted to 0.15-ambiance.
[0129] Step 204: superimpose the fill light grayscale image onto the image to be processed to obtain the image to be processed with the fill light special effect added thereto.
[0130] In this step, the fill light grayscale image is superimposed on the image to be processed by adding the pixel values of the fill light grayscale image with the pixel values of the image to be processed to generate new pixel values, and constructing the image to be processed with the fill light effect added based on the new pixel values.
[0131] Reference Figure 4 By superimposing the fill light grayscale image 50 onto the image to be processed 40, a process to obtain an image to be processed 60 with a fill light effect added thereto can be obtained. During the superimposition process, the brightness of the face area 41 of the image to be processed 40 is enhanced through the area 51 where the fill light effect is located, thereby presenting a fill light effect for the face area 41.
[0132] The probability distribution based on the covariance symmetric matrix has a distribution characteristic of being dense inside and sparse outside, so that the part close to the edge of the area 51 where the fill light effect is located presents a blurred liquefied effect. Therefore, when the fill light effect is added later, the brightness of the edge part of the face area 61 with the fill light effect added can present a slowly gradient effect, making the connection between the face area 61 with the fill light effect added and other areas more natural and soft.
[0133] Optionally, step 204 may specifically include:
[0134] Sub-step 2041: adjusting the value range of the fill light grayscale image to be the same as the value range of the image to be processed.
[0135] Sub-step 2042: adding the pixel value of the first pixel in the fill light grayscale image to the pixel value of the second pixel corresponding to the first pixel in the image to be processed, to obtain the image to be processed with the fill light special effect added.
[0136] In the embodiment of the present disclosure, since the fill light process is to simply increase the brightness of the original image, the pixel values of the fill light grayscale image can be summed with the pixel values of the image to be processed to generate new pixel values, and the image to be processed with the fill light effect added can be constructed based on the new pixel values.
[0137] It should be noted that, since the range of the grayscale image is (0, 1) and the range of the image to be processed is (0, 255), before superposition, the range of the fill light grayscale image needs to be adjusted to be consistent with the range of the image to be processed, and the specific method is to multiply all pixel values in the fill light grayscale image by 255. After the range of the fill light grayscale image is adjusted to be consistent with the range of the image to be processed, the pixel value of the first pixel in the fill light grayscale image is added to the pixel value of the second pixel corresponding to the first pixel in the image to be processed, so as to obtain the image to be processed with the fill light special effect added.
[0138] Step 205 : Generate a darkened grayscale image with the same size as the image to be processed according to a preset regular image generation function, the center position of the image to be processed, and the width and height of the image to be processed.
[0139] Among them, the regular image generation function is used to generate a darkened grayscale image including a darkening effect, the darkened grayscale image includes a regular shape area with unchanged pixel values, the area where the darkening effect is located is an area outside the regular shape area, the center position of the image to be processed is used to determine the position of the regular shape area, and the width and height of the image to be processed are used to determine the size of the regular shape area; the pixel value of the area where the darkening effect is located is smaller than the pixel value of the regular shape area.
[0140] In the disclosed embodiment, before adding lighting effects to the image to be processed, the brightness of the four corners of the image to be processed may be dimmed, thereby slightly reducing the brightness of the four corners of the image to be processed, so as to more accurately simulate the lighting effect of a natural flash (when a real flash is used, the four corners of the picture will present a darker effect).
[0141] Specifically, the embodiment of the present disclosure can slightly reduce the brightness of the four corner positions of the image to be processed by superimposing a darkening grayscale map on the image to be processed. The embodiment of the present disclosure can generate a darkening grayscale map through a regular map generation function, which takes the center position of the entire image to be processed and the width and height of the image to be processed as input, and outputs a darkening grayscale map including a darkening effect, wherein the function of the regular map generation function is to generate a rectangular darkening grayscale map, and there is a regular shape area with unchanged pixel value in the darkening grayscale map, the center position of the regular shape area is determined by the center position of the image to be processed, the size of the regular shape area is determined by the width and height of the image to be processed, and the pixel value of the area where the darkening effect is located is smaller than the pixel value of the regular shape area.
[0142] Preferably, the regular graph generation function may specifically be a pie chart generation function, and the regular shape area included in the darkened grayscale graph generated by the function may be an elliptical area, the horizontal axis length of the elliptical area is half the width of the image to be processed, and the vertical and horizontal axis lengths of the elliptical area are half the height of the image to be processed. The area outside the regular shape area in the darkened grayscale graph is the area where the darkening effect is located, and the brightness of the area where the darkening effect is located is lower than the brightness of the regular shape area. Therefore, after the size and position of the elliptical area are determined according to the size and position of the entire image to be processed, the size and position of the area where the darkening effect is located are determined, so that after the darkening grayscale graph is subsequently superimposed on the image to be processed, the brightness of the four corners of the image to be processed can be reduced.
[0143] Since the size of the image generated by the regular graph generation function can be controlled, the embodiment of the present disclosure can set the size of the image output by the regular graph generation function to be the same as the size of the image to be processed, so as to facilitate subsequent overlay darkening effects.
[0144] Reference Figure 5 , Figure 5 It is a schematic diagram of a darkening process provided by an embodiment of the present disclosure, including an image to be processed 70, a darkening grayscale image 80, and an image to be processed 90 with a darkening special effect added thereto.
[0145] After determining the center position, width and height of the image to be processed 70, a darkening grayscale image 80 can be generated using a regular image generation function. The darkening grayscale image 80 contains a regular shape area 81 determined by the center position, width and height of the image to be processed 70. The area outside the regular shape area 81 is the area where the darkening effect is located.
[0146] Step 206: superimpose the darkened grayscale image onto the image to be processed to obtain the image to be processed with the darkened special effect added to the four corners.
[0147] In this step, the darkened grayscale image is superimposed on the image to be processed by multiplying the pixel values of the darkened grayscale image with the pixel values of the image to be processed to generate new pixel values, and constructing the image to be processed with the darkening effect added based on the new pixel values.
[0148] Reference Figure 5 By superimposing the darkened grayscale image 80 onto the image to be processed 70, a processed image 90 with a darkening effect added thereto can be obtained. During the superimposition process, the brightness of the four corners of the image to be processed 90 is reduced by the area where the darkening effect is located, so as to more accurately simulate the natural flash lighting effect.
[0149] Optionally, step 206 may specifically include:
[0150] Sub-step 2061, after blurring the darkened grayscale image, multiply the pixel value of the third pixel in the darkened grayscale image by the pixel value of the fourth pixel in the image to be processed corresponding to the third pixel, to obtain the image to be processed with the darkening effect added.
[0151] The value range of the pixel value of the darkened grayscale image after the blurring process is constrained within the range formed by the preset third coefficient and the fourth coefficient.
[0152] In practical applications, the brightness of the area where the darkening effect is located in the darkened grayscale image generated by the regular image generation function is still too high. Therefore, the darkened grayscale image can be blurred to obtain a darkened grayscale image with lower brightness in the area where the darkening effect is located. Since the pixel values of the regular shape areas in the darkened grayscale image remain unchanged, the blurring operation will not affect the regular shape areas. Afterwards, the pixel value of the third pixel point in the darkened grayscale image can be multiplied by the pixel value of the fourth pixel point corresponding to the third pixel point in the image to be processed to obtain the image to be processed with the darkening effect added.
[0153] In addition, the disclosed embodiment needs to constrain the value range of the pixel value of the darkened grayscale image so that its value range is within the range formed by the darkening upper limit value and the darkening lower limit value, thereby avoiding the darkening intensity being too strong or too weak. The darkening upper limit value and the darkening lower limit value can be specifically determined by a preset third coefficient and a fourth coefficient. In one implementation, the third coefficient is preset to 0.95 and the fourth coefficient is 1, thereby forming a darkening intensity constraint range of (0.95, 1), which means that pixel values greater than 1 in the darkened grayscale image will be adjusted to 1, and pixel values less than 0.95 will be adjusted to 0.95.
[0154] It should be noted that before step 207, steps 201-206 can be executed in sequence in the above order, or after executing step 202, steps 205-206 can be executed in sequence first, and after executing step 206, steps 203-204 can be executed in sequence, and step 207 can be executed after step 204.
[0155] Step 207: Generate a lighting grayscale image with the same size as the image to be processed according to a preset first two-dimensional Gaussian function, the center position of the face area, and the width of the face area.
[0156] Among them, the first two-dimensional Gaussian function is used to generate a lighting grayscale map including lighting effects, the center position of the face area is used to determine the position of the area where the lighting effects are located, and the width of the face area is used to determine the size of the area where the lighting effects are located.
[0157] This step may specifically refer to the above step 103, which will not be described in detail here.
[0158] Step 208: superimpose the lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added thereto.
[0159] This step may specifically refer to the above step 104, which will not be described in detail here.
[0160] Optionally, step 208 may specifically include:
[0161] Sub-step 2081, obtain the lighting intensity value, and determine the first ratio between the lighting intensity value and the maximum pixel value of the lighting grayscale image; the lighting intensity value is used to determine the intensity of the lighting special effect.
[0162] In the embodiment of the present disclosure, in order to facilitate the user to adjust the lighting intensity value during the lighting process according to actual needs, a function of allowing the user to select the lighting intensity value by themselves can be provided. The range of the lighting intensity value can be (0, 1). After obtaining the lighting intensity value, the first ratio between the lighting intensity value and the maximum pixel value of the lighting grayscale image can be determined. The first ratio is the ratio that needs to be transformed for the pixel value of the original lighting grayscale image after the lighting intensity is introduced.
[0163] Sub-step 2082: multiply the pixel value in the lighting grayscale image by the first ratio to obtain a target lighting grayscale image.
[0164] In this step, the pixel values of all pixels in the lighting grayscale map can be multiplied by the first ratio to obtain a target lighting grayscale map to which the lighting intensity value is applied. The larger the lighting intensity value, the larger the average grayscale value of the target lighting grayscale map, and the stronger the lighting effect; the smaller the lighting intensity value, the smaller the average grayscale value of the target lighting grayscale map, and the weaker the lighting effect.
[0165] Sub-step 2083: superimpose the target lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added.
[0166] Among them, the pixel value of the area where the lighting effects are located in the target lighting grayscale map is greater than the pixel value of the area other than the area where the lighting effects are located in the target lighting grayscale map, and the value range of the pixel value of the target lighting grayscale map is constrained within the range formed by the lighting upper limit value and the lighting lower limit value, and the lighting upper limit value and the lighting lower limit value are determined by a preset first coefficient and the average grayscale value of the image to be processed.
[0167] In the disclosed embodiment, it is necessary to constrain the value range of the pixel value of the target lighting grayscale image so that its value range is within the range formed by the lighting upper limit value and the lighting lower limit value, thereby avoiding the lighting intensity being too strong or too weak. The lighting upper limit value and the lighting lower limit value can be specifically determined by a preset first coefficient and the average grayscale value of the image to be processed, so that the lighting intensity constraint range can be more closely matched to the image to be processed.
[0168] In one implementation, since the maximum value of the pixel value of the grayscale image is 1 and the minimum value is 0, after obtaining the image to be processed, the average grayscale value ambiance of the image to be processed can be calculated, and according to actual needs, the first coefficient 0.75 and the first coefficient 1 are preset, the upper limit value of the lighting is 1, and the lower limit value of the lighting is 0.75-ambiance, thereby forming a lighting intensity constraint range (0.75-ambiance, 0.1), which means that pixel values greater than 0.1 in the target lighting grayscale image will be adjusted to 0.1, and pixel values less than 0.75-ambiance will be adjusted to 0.75-ambiance.
[0169] Optionally, sub-step 2083 may specifically include:
[0170] Sub-step A1: adjusting the value range of the pixel values of the image to be processed to be the same as the value range of the target lighting grayscale image.
[0171] In the embodiment of the present disclosure, since the value range of the grayscale image is (0, 1) and the value range of the image to be processed is (0, 255), before superposition, the value range of the image to be processed needs to be adjusted to be consistent with the value range of the lighting grayscale image. The specific method is to divide all pixel values in the image to be processed by 255.
[0172] Sub-step A2, input the pixel values of the image to be processed and the pixel values of the target lighting grayscale image into a preset superposition function to obtain the pixel values output by the superposition function; the superposition function is used to determine the bright area and the dark area of the target lighting grayscale image, and increase the pixel value of the area corresponding to the bright area in the image to be processed, and decrease the pixel value of the area corresponding to the dark area; the bright area is an area where the pixel value is greater than a preset brightness value, and the dark area is an area where the pixel value is less than or equal to the preset brightness value.
[0173] In this step, after adjusting the value range of the image to be processed to be consistent with the value range of the fill light grayscale image, the pixel values of the image to be processed and the pixel values of the target lighting grayscale image can be input into the overlay function for calculation to obtain the pixel values output by the overlay function.
[0174] Specifically, in one implementation, the superposition function may include: (Target>0.5)×(1-(1-2×(Target-0.5)×(1-Blend))+(Target<=0.5)×((2×Target)×Blend). Target represents the pixel value of the image to be processed, and Blend represents the pixel value of the target lighting grayscale image. The entire formula represents determining the bright area and dark area of the target lighting grayscale image, and increasing the pixel value of the area corresponding to the bright area in the image to be processed, and decreasing the pixel value of the area corresponding to the dark area, thereby simulating the actual situation in which the brightness of the flash area in the flash light special effect is greater than that of other areas.
[0175] Sub-step A3: adjusting the range of the image constructed according to the pixel values output by the overlay function to be the same as the range of the image to be processed, so as to obtain the target image.
[0176] In the embodiment of the present disclosure, since the value range of the pixel values output by the overlay function is (0, 1), in order to construct a target image with a value range of (0, 255), the pixel values output by the overlay function need to be multiplied by 255 and adjusted to the same value range as the image to be processed. After that, the target image can be constructed based on the pixel values with the adjusted value range.
[0177] Optionally, step 208 may also include:
[0178] Sub-step 2084: When the average grayscale value of the face area in the target image is greater than the preset grayscale value, reduce the lighting intensity value, re-enter sub-step 2081, and stop when the average grayscale value of the face area in the new target image is less than or equal to the preset grayscale value.
[0179] In some cases, the set lighting intensity value may be relatively large, causing the average grayscale value of the face area in the target image to be greater than the preset grayscale value, resulting in overexposure of the image. Figure 6 As shown, Figure 6 is a schematic diagram of image overexposure provided by an embodiment of the present disclosure, including an image to be processed 91 and an overexposed target image 92 after processing. It can be seen that the overexposed target image 92 simulates the overexposed flash effect, causing the image to be too bright, affecting the display effect of the character. It should be noted that the embodiment of the present disclosure can use a mask of the face area to circle the face area in the target image and only calculate the average grayscale value of the face area.
[0180] Therefore, when it is determined that the target image is overexposed, the overexposed target image can be discarded, the previous lighting intensity value can be reduced, and the step loop of sub-steps 2081-2083 can be re-entered until the average grayscale value of the face area in the constructed new target image is less than or equal to the preset grayscale value.
[0181] Optionally, after step 208, the method may further include:
[0182] Step 209 : post-processing the target image by a smooth step function to reduce the brightness of a dark area in the target image, where the dark area is an area where the pixel value is less than or equal to a preset brightness value.
[0183] In the disclosed embodiment, after obtaining the target image with the lighting effect added, in order to further improve the picture quality, a smooth step function can be called to smooth the target image to reduce the brightness of the dark area in the target image, thereby simulating a more accurate flash lighting effect (when a real flash is used, a dark dark area in the finished film is darker than before the lighting).
[0184] For example, refer to Figure 7 As shown, Figure 7 It is a schematic diagram of image smoothing processing provided by an embodiment of the present disclosure, which includes an original target image 93 and a target image 94 after smoothing processing. It can be seen that compared with the original target image 93, in the target image 94 after smoothing processing, the dark clothes and hair parts have become darker and more natural.
[0185] Optionally, step 209 may specifically include:
[0186] Sub-step 2091: convert the target image into a first grayscale image, and normalize the first grayscale image.
[0187] Sub-step 2092, reduce the pixel value of the dark area in the first grayscale image, and increase the pixel value of the bright area to obtain a second grayscale image; the bright area is an area where the pixel value is greater than the preset brightness value, and the dark area is an area where the pixel value is less than or equal to the preset brightness value.
[0188] Sub-step 2093, calculate the ratio of the pixel value in the second grayscale image to the pixel value in the first grayscale image, and use the ratio as the pixel value to construct a third grayscale image; the value range of the third grayscale image is constrained within a preset value range.
[0189] Sub-step 2094: multiply the pixel value of the fifth pixel in the third grayscale image by the pixel value of the sixth pixel in the target image corresponding to the fifth pixel, to obtain a target image with reduced brightness of the dark area.
[0190] For the above sub-steps 2091-2094, the post-processing of the target image by the smooth step function is to first convert the target image into a first grayscale image, and then normalize the first grayscale image so that the value range of the first grayscale image is normalized to the range of [0, 1]. Then, the formula is used: result = (gray 2 )×(3-2×gray) to generate the second grayscale image. The purpose of this formula is to reduce the pixel values of the dark area in the first grayscale image gray and increase the pixel values of the bright area to obtain the second grayscale image result.
[0191] After that, the third grayscale image scale can be generated by the formula: scale = clip (result / gray, 0.95, 1), and the value range of the third grayscale image scale can be truncated to [0.95, 1]. The purpose of this formula is to determine the ratio of the pixel value in the second grayscale image to the pixel value in the first grayscale image, and use the ratio as the pixel value to construct the third grayscale image; the value range of the third grayscale image is constrained within the preset value range [0.95, 1].
[0192] Finally, the pixel value of the fifth pixel in the third grayscale image is multiplied by the pixel value of the sixth pixel corresponding to the fifth pixel in the target image to obtain a target image with reduced brightness of the dark area, thereby completing the smoothing of the target image.
[0193] In summary, an image processing method provided by an embodiment of the present disclosure includes: obtaining an image to be processed, wherein the image to be processed includes a target object; determining the face area of the target object in the image to be processed; generating a lighting grayscale image of the same size as the image to be processed according to a preset first two-dimensional Gaussian function, the center position of the face area, and the width of the face area; and superimposing the lighting grayscale image on the image to be processed to obtain a target image with a lighting effect added. The present disclosure can use a two-dimensional Gaussian function to generate a lighting grayscale image including a lighting effect. For an image to be processed that needs to add a lighting effect to enhance the image quality, the lighting grayscale image can be superimposed on the image to be processed to obtain a target image with a lighting effect added, so that the effect presented by the target image is to highlight the brightness of the face area and reduce the brightness of other areas, thereby simulating the lighting effect of a flash.
[0194] Figure 8 is a block diagram of an image processing device provided by an embodiment of the present disclosure, such as Figure 8 As shown, it includes: an acquisition module 301, a recognition module 302, a lighting module 303, and a first superposition module 304.
[0195] An acquisition module 301 is configured to acquire an image to be processed, wherein the image to be processed contains a target object;
[0196] The recognition module 302 is configured to determine the face area of the target object in the image to be processed;
[0197] The lighting module 303 is configured to generate a lighting grayscale image having the same size as the image to be processed according to a preset first two-dimensional Gaussian function, the center position of the face area, and the width of the face area; wherein the first two-dimensional Gaussian function is used to generate a lighting grayscale image including a lighting special effect, the center position of the face area is used to determine the position of the area where the lighting special effect is located, and the width of the face area is used to determine the size of the area where the lighting special effect is located;
[0198] The first superposition module 304 is configured to superimpose the lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added thereto.
[0199] In an optional implementation, the first superposition module includes:
[0200] An acquisition submodule is configured to acquire a lighting intensity value and determine a first ratio between the lighting intensity value and a maximum pixel value of the lighting grayscale image; the lighting intensity value is used to determine the intensity of the lighting special effect;
[0201] an intensity setting submodule, configured to multiply the pixel value in the lighting grayscale image by the first ratio to obtain a target lighting grayscale image;
[0202] A first superposition submodule is configured to superimpose the target lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added thereto;
[0203] Among them, the pixel value of the area where the lighting effects are located in the target lighting grayscale map is greater than the pixel value of the area other than the area where the lighting effects are located in the target lighting grayscale map, and the value range of the pixel value of the target lighting grayscale map is constrained within the range formed by the lighting upper limit value and the lighting lower limit value, and the lighting upper limit value and the lighting lower limit value are determined by a preset first coefficient and the average grayscale value of the image to be processed.
[0204] In an optional implementation, the first superposition submodule includes:
[0205] An adjustment unit, configured to adjust the value range of the pixel values of the image to be processed to be the same as the value range of the target lighting grayscale image;
[0206] The superposition function unit is configured to input the pixel values of the image to be processed and the pixel values of the target lighting grayscale image into a preset superposition function to obtain the pixel values output by the superposition function; the superposition function is used to determine the bright area and the dark area of the target lighting grayscale image, and increase the pixel value of the area corresponding to the bright area in the image to be processed, and decrease the pixel value of the area corresponding to the dark area; the bright area is an area with a pixel value greater than a preset brightness value, and the dark area is an area with a pixel value less than or equal to the preset brightness value;
[0207] The constraint unit is configured to adjust the value range of the image constructed according to the pixel values output by the superposition function to be the same as the value range of the image to be processed, so as to obtain the target image.
[0208] In an optional embodiment, the first superposition module includes:
[0209] The overexposure processing submodule is configured to reduce the lighting intensity value when the average grayscale value of the face area in the target image is greater than a preset grayscale value, re-enter the step of obtaining the lighting intensity value, and determine a first ratio between the lighting intensity value and the maximum pixel value of the lighting grayscale image, until the average grayscale value of the face area in the new target image is obtained, which is less than or equal to the preset grayscale value.
[0210] In an optional embodiment, the device further comprises:
[0211] A fill light module is configured to generate a fill light grayscale image having the same size as the image to be processed according to a preset second two-dimensional Gaussian function, the center position of the face area and the width of the face area; the second two-dimensional Gaussian function is used to generate a fill light grayscale image including a fill light special effect, the center position of the face area is used to determine the position of the fill light special effect area, and the width of the face area is used to determine the size of the fill light special effect area;
[0212] A second superposition module is configured to superimpose the fill light grayscale image onto the image to be processed to obtain the image to be processed with the fill light special effect added thereto;
[0213] The value range of the pixel value of the fill light grayscale image is constrained within a range formed by a fill light upper limit value and a fill light lower limit value, and the fill light upper limit value and the fill light lower limit value are determined by a preset second coefficient and an average grayscale value of the image to be processed.
[0214] In an optional implementation, the second superposition module includes:
[0215] A first adjustment submodule is configured to adjust the value range of the fill light grayscale image to be the same as the value range of the image to be processed;
[0216] The adding submodule is configured to add the pixel value of the first pixel point in the fill light grayscale image and the pixel value of the second pixel point corresponding to the first pixel point in the image to be processed to obtain the image to be processed with the fill light special effect added.
[0217] In an optional embodiment, the device further comprises:
[0218] A darkening special effect module is configured to generate a darkening grayscale image of the same size as the image to be processed according to a preset regular image generation function, the center position of the image to be processed, and the width and height of the image to be processed; the regular image generation function is used to generate a darkening grayscale image including a darkening special effect, the darkening grayscale image includes a regular shape area with unchanged pixel values, the area where the darkening special effect is located is an area outside the regular shape area, the center position of the image to be processed is used to determine the position of the regular shape area, the width of the image to be processed is used to determine the horizontal axis length of the regular shape area; the height of the image to be processed is used to determine the vertical axis length of the regular shape area; the pixel value of the area where the darkening special effect is located is smaller than the pixel value of the regular shape area;
[0219] The third superposition module is configured to superimpose the darkened grayscale image onto the image to be processed to obtain the image to be processed with the darkening special effect added to the four corners.
[0220] In an optional implementation, the third superposition module includes:
[0221] a blur processing submodule configured to, after blurring the darkened grayscale image, multiply the pixel value of a third pixel in the darkened grayscale image by the pixel value of a fourth pixel in the image to be processed corresponding to the third pixel, to obtain the image to be processed with the darkening special effect added thereto;
[0222] The value range of the pixel value of the darkened grayscale image after the blurring process is constrained within the range formed by the preset third coefficient and the fourth coefficient.
[0223] In an optional embodiment, the device further comprises:
[0224] The smoothing processing module is configured to post-process the target image through a smoothing step function to reduce the brightness of a dark area in the target image, where the dark area is an area where the pixel value is less than or equal to a preset brightness value.
[0225] In an optional implementation, the smoothing processing module includes:
[0226] A conversion submodule, configured to convert the target image into a first grayscale image and normalize the first grayscale image;
[0227] A first processing submodule is configured to reduce the pixel value of the dark area in the first grayscale image and increase the pixel value of the bright area to obtain a second grayscale image; the bright area is an area where the pixel value is greater than a preset brightness value, and the dark area is an area where the pixel value is less than or equal to the preset brightness value;
[0228] The second processing submodule is configured to calculate the ratio of the pixel value in the second grayscale image to the pixel value in the first grayscale image, and construct a third grayscale image using the ratio as the pixel value; the value range of the third grayscale image is constrained within a preset value range;
[0229] The multiplication submodule is configured to multiply the pixel value of the fifth pixel point in the third grayscale image by the pixel value of the sixth pixel point corresponding to the fifth pixel point in the target image to obtain a target image with reduced brightness of the dark area.
[0230] In summary, an image processing device provided by an embodiment of the present disclosure includes: obtaining an image to be processed, wherein the image to be processed includes a target object; determining a face region of the target object in the image to be processed; generating a lighting grayscale map of the same size as the image to be processed according to a preset first two-dimensional Gaussian function, the center position of the face region, and the width of the face region; and superimposing the lighting grayscale map on the image to be processed to obtain a target image with a lighting effect added. The present disclosure can use a two-dimensional Gaussian function to generate a lighting grayscale map including a lighting effect. For an image to be processed that needs to add a lighting effect to enhance the image quality, the lighting grayscale map can be superimposed on the image to be processed to obtain a target image with a lighting effect added, so that the effect presented by the target image is to highlight the brightness of the face region and reduce the brightness of other regions, thereby simulating the lighting effect of a flash.
[0231] Fig. 9 is a block diagram of an electronic device 600 according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0232] Reference Fig. 9 , the electronic device 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , a multimedia component 608 , an audio component 610 , an input / output (I / O) interface 612 , a sensor component 614 , and a communication component 616 .
[0233] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.
[0234] The memory 604 is used to store various types of data to support the operation of the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, multimedia, etc. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0235] The power supply component 606 provides power to the various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 600.
[0236] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a multimedia mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0237] The audio component 610 is used to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the electronic device 600 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is used to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting audio signals.
[0238] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0239] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the electronic device 600. For example, the sensor assembly 614 can detect the open / closed state of the electronic device 600, the relative positioning of the components, such as the display and keypad of the electronic device 600, and the sensor assembly 614 can also detect the position change of the electronic device 600 or a component of the electronic device 600, the presence or absence of contact between the user and the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0240] The communication component 616 is used to facilitate wired or wireless communication between the electronic device 600 and other devices. The electronic device 600 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0241] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to implement an image processing method provided in an embodiment of the present disclosure.
[0242] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the instructions can be executed by a processor 620 of an electronic device 600 to perform the above method. For example, the non-transitory storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0243] Fig.10 is a block diagram of an electronic device 700 according to an exemplary embodiment. For example, the electronic device 700 may be provided as a server. Fig.10 The electronic device 700 includes a processing component 722, which further includes one or more processors, and a memory resource represented by a memory 732 for storing instructions executable by the processing component 722, such as an application. The application stored in the memory 732 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 722 is configured to execute instructions to perform an image processing method provided by an embodiment of the present disclosure.
[0244] The electronic device 700 may also include a power supply component 726 configured to perform power management of the electronic device 700, a wired or wireless network interface 750 configured to connect the electronic device 700 to a network, and an input / output (I / O) interface 758. The electronic device 700 may operate based on an operating system stored in the memory 732, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™ or the like.
[0245] The embodiment of the present disclosure also provides a computer program product, including a computer program, and when the computer program is executed by a processor, the image processing method is implemented.
[0246] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the disclosure disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0247] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. An image processing method, characterized in that: The method comprises: Acquire an image to be processed, wherein the image to be processed contains a target object; Determine the face area of the target object in the image to be processed; Generate a lighting grayscale image having the same size as the image to be processed according to a preset first two-dimensional Gaussian function, the center position of the face area and the width of the face area; wherein the first two-dimensional Gaussian function is used to generate a lighting grayscale image including a lighting special effect, the center position of the face area is used to determine the position of the area where the lighting special effect is located, and the width of the face area is used to determine the size of the area where the lighting special effect is located; Superimposing the lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added; The step of superimposing the lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added includes: Acquire a lighting intensity value, and determine a first ratio between the lighting intensity value and a maximum pixel value of the lighting grayscale image; the lighting intensity value is used to determine the intensity of the lighting special effect; Multiplying the pixel values in the lighting grayscale map by the first ratio to obtain a target lighting grayscale map; the pixel values in the target lighting grayscale map where the lighting special effects are located are greater than the pixel values in the target lighting grayscale map except for the area where the lighting special effects are located, and the value range of the pixel values in the target lighting grayscale map is constrained within a range formed by a lighting upper limit value and a lighting lower limit value, and the lighting upper limit value and the lighting lower limit value are determined by a preset first coefficient and an average grayscale value of the image to be processed; The target lighting grayscale image is superimposed on the image to be processed to obtain a target image with the lighting special effect added.
2. The method according to claim 1, characterized in that The step of superimposing the target lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added includes: Adjusting the range of pixel values of the image to be processed to be the same as the range of the target lighting grayscale image; Input the pixel values of the image to be processed and the pixel values of the target lighting grayscale image into a preset superposition function to obtain the pixel values output by the superposition function; the superposition function is used to determine the bright area and the dark area of the target lighting grayscale image, and increase the pixel value of the area corresponding to the bright area in the image to be processed, and decrease the pixel value of the area corresponding to the dark area; the bright area is an area with a pixel value greater than a preset brightness value, and the dark area is an area with a pixel value less than or equal to the preset brightness value; The value range of the image constructed according to the pixel values output by the superposition function is adjusted to be the same as the value range of the image to be processed, so as to obtain the target image.
3. The method according to claim 1, characterized in that The method further comprises: When the average grayscale value of the face area in the target image is greater than the preset grayscale value, the lighting intensity value is reduced, and the step of obtaining the lighting intensity value and determining the first ratio between the lighting intensity value and the maximum pixel value of the lighting grayscale image is re-entered until the average grayscale value of the face area in the new target image is less than or equal to the preset grayscale value.
4. The method according to claim 1, characterized in that: Before generating a lighting grayscale image having the same size as the image to be processed according to the preset first two-dimensional Gaussian function, the center position of the face area, and the width of the face area, the method further includes: Generate a fill light grayscale image having the same size as the image to be processed according to a preset second two-dimensional Gaussian function, the center position of the face area and the width of the face area; the second two-dimensional Gaussian function is used to generate a fill light grayscale image including a fill light special effect, the center position of the face area is used to determine the position of the fill light special effect area, and the width of the face area is used to determine the size of the fill light special effect area; Superimposing the fill light grayscale image on the image to be processed to obtain the image to be processed with the fill light special effect added; The value range of the pixel value of the fill light grayscale image is constrained within a range formed by a fill light upper limit value and a fill light lower limit value, and the fill light upper limit value and the fill light lower limit value are determined by a preset second coefficient and an average grayscale value of the image to be processed.
5. The method according to claim 4, characterized in that The step of superimposing the fill light grayscale image onto the image to be processed to obtain the image to be processed with the fill light special effect added thereto includes: Adjusting the value range of the fill light grayscale image to be the same as the value range of the image to be processed; The pixel value of the first pixel in the fill light grayscale image is added to the pixel value of the second pixel corresponding to the first pixel in the image to be processed, so as to obtain the image to be processed with the fill light special effect added thereto.
6. The method according to claim 1, characterized in that Before generating a lighting grayscale image having the same size as the image to be processed according to the preset first two-dimensional Gaussian function, the center position of the face area, and the width of the face area, the method further includes: A darkened grayscale image having the same size as the image to be processed is generated according to a preset regular image generation function, the center position of the image to be processed, and the width and height of the image to be processed; the regular image generation function is used to generate a darkened grayscale image including a darkening effect, the darkened grayscale image includes a regular shape area with unchanged pixel values, the area where the darkening effect is located is an area outside the regular shape area, the center position of the image to be processed is used to determine the position of the regular shape area, and the width and height of the image to be processed are used to determine the size of the regular shape area; the pixel value of the area where the darkening effect is located is smaller than the pixel value of the regular shape area; The darkening grayscale image is superimposed on the image to be processed to obtain the image to be processed with the darkening special effect added to the four corners.
7. The method according to claim 6, characterized in that The step of superimposing the darkened grayscale image onto the image to be processed to obtain the image to be processed with the darkened special effect added to the four corners of the image, comprises: After blurring the darkened grayscale image, multiplying the pixel value of a third pixel in the darkened grayscale image by the pixel value of a fourth pixel in the image to be processed corresponding to the third pixel, to obtain the image to be processed with the darkening special effect added thereto; The value range of the pixel value of the darkened grayscale image after the blurring process is constrained within the range formed by the preset third coefficient and the fourth coefficient.
8. The method according to claim 1, characterized in that The method further comprises: The target image is post-processed by a smooth step function to reduce the brightness of a dark area in the target image, where the dark area is an area where the pixel value is less than or equal to a preset brightness value.
9. The method according to claim 8, characterized in that The post-processing of the target image by a smooth step function to reduce the brightness of a dark area in the target image includes: Converting the target image into a first grayscale image, and normalizing the first grayscale image; The pixel values of the dark areas in the first grayscale image are reduced, and the pixel values of the bright areas are increased, to obtain a second grayscale image; the bright areas are areas where the pixel values are greater than a preset brightness value, and the dark areas are areas where the pixel values are less than or equal to the preset brightness value; Calculating the ratio of the pixel value in the second grayscale image to the pixel value in the first grayscale image, and constructing a third grayscale image using the ratio as the pixel value; the value range of the third grayscale image is constrained within a preset value range; The pixel value of the fifth pixel in the third grayscale image is multiplied by the pixel value of the sixth pixel corresponding to the fifth pixel in the target image to obtain a target image with reduced brightness of the dark area.
10. An image processing device, characterized in that: The device comprises: An acquisition module is configured to acquire an image to be processed, wherein the image to be processed contains a target object; A recognition module, configured to determine a face region of a target object in the image to be processed; A lighting module is configured to generate a lighting grayscale image having the same size as the image to be processed according to a preset first two-dimensional Gaussian function, the center position of the face area and the width of the face area; wherein the first two-dimensional Gaussian function is used to generate a lighting grayscale image including a lighting special effect, the center position of the face area is used to determine the position of the area where the lighting special effect is located, and the width of the face area is used to determine the size of the area where the lighting special effect is located; A first superposition module is configured to superimpose the lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added thereto; Wherein, the first superposition module comprises: An acquisition submodule is configured to acquire a lighting intensity value and determine a first ratio between the lighting intensity value and a maximum pixel value of the lighting grayscale image; the lighting intensity value is used to determine the intensity of the lighting special effect; The intensity setting submodule is configured to multiply the pixel value in the lighting grayscale map by the first ratio to obtain a target lighting grayscale map; the pixel value of the lighting effect area in the target lighting grayscale map is greater than the pixel value of the target lighting grayscale map except the area where the lighting effect is located, and the value range of the pixel value of the target lighting grayscale map is constrained within a range formed by a lighting upper limit value and a lighting lower limit value, and the lighting upper limit value and the lighting lower limit value are determined by a preset first coefficient and an average grayscale value of the image to be processed. The first superposition submodule is configured to superimpose the target lighting grayscale image onto the image to be processed to obtain a target image with the lighting special effect added thereto.
11. The device according to claim 10, characterized in that The first superposition submodule comprises: An adjustment unit, configured to adjust the value range of the pixel values of the image to be processed to be the same as the value range of the target lighting grayscale image; The superposition function unit is configured to input the pixel values of the image to be processed and the pixel values of the target lighting grayscale image into a preset superposition function to obtain the pixel values output by the superposition function; the superposition function is used to determine the bright area and the dark area of the target lighting grayscale image, and increase the pixel value of the area corresponding to the bright area in the image to be processed, and decrease the pixel value of the area corresponding to the dark area; the bright area is an area with a pixel value greater than a preset brightness value, and the dark area is an area with a pixel value less than or equal to the preset brightness value; The constraint unit is configured to adjust the value range of the image constructed according to the pixel values output by the superposition function to be the same as the value range of the image to be processed, so as to obtain the target image.
12. The device according to claim 10, characterized in that The first superposition module comprises: The overexposure processing submodule is configured to reduce the lighting intensity value when the average grayscale value of the face area in the target image is greater than a preset grayscale value, re-enter the step of obtaining the lighting intensity value, and determine a first ratio between the lighting intensity value and the maximum pixel value of the lighting grayscale image, until the average grayscale value of the face area in the new target image is obtained, which is less than or equal to the preset grayscale value.
13. The device according to claim 10, characterized in that The device also includes: A fill light module is configured to generate a fill light grayscale image having the same size as the image to be processed according to a preset second two-dimensional Gaussian function, the center position of the face area and the width of the face area; the second two-dimensional Gaussian function is used to generate a fill light grayscale image including a fill light special effect, the center position of the face area is used to determine the position of the fill light special effect area, and the width of the face area is used to determine the size of the fill light special effect area; A second superposition module is configured to superimpose the fill light grayscale image onto the image to be processed to obtain the image to be processed with the fill light special effect added thereto; The value range of the pixel value of the fill light grayscale image is constrained within a range formed by a fill light upper limit value and a fill light lower limit value, and the fill light upper limit value and the fill light lower limit value are determined by a preset second coefficient and an average grayscale value of the image to be processed.
14. The device according to claim 13, characterized in that The second superposition module comprises: A first adjustment submodule is configured to adjust the value range of the fill light grayscale image to be the same as the value range of the image to be processed; The adding submodule is configured to add the pixel value of the first pixel point in the fill light grayscale image and the pixel value of the second pixel point corresponding to the first pixel point in the image to be processed to obtain the image to be processed with the fill light special effect added.
15. The device according to claim 10, characterized in that The device also includes: A darkening special effect module is configured to generate a darkening grayscale image of the same size as the image to be processed according to a preset regular image generation function, the center position of the image to be processed, and the width and height of the image to be processed; the regular image generation function is used to generate a darkening grayscale image including a darkening special effect, the darkening grayscale image includes a regular shape area with unchanged pixel values, the area where the darkening special effect is located is an area outside the regular shape area, the center position of the image to be processed is used to determine the position of the regular shape area, and the width and height of the image to be processed are used to determine the size of the regular shape area; the pixel value of the area where the darkening special effect is located is smaller than the pixel value of the regular shape area; The third superposition module is configured to superimpose the darkened grayscale image onto the image to be processed to obtain the image to be processed with the darkening special effect added to the four corners.
16. The device according to claim 15, characterized in that The third superposition module comprises: a blur processing submodule configured to, after blurring the darkened grayscale image, multiply the pixel value of a third pixel in the darkened grayscale image by the pixel value of a fourth pixel in the image to be processed corresponding to the third pixel, to obtain the image to be processed with the darkening special effect added thereto; The value range of the pixel value of the darkened grayscale image after the blurring process is constrained within the range formed by the preset third coefficient and the fourth coefficient.
17. The device according to claim 10, characterized in that The device also includes: The smoothing processing module is configured to post-process the target image through a smoothing step function to reduce the brightness of a dark area in the target image, where the dark area is an area where the pixel value is less than or equal to a preset brightness value.
18. The device according to claim 17, characterized in that The smoothing processing module comprises: A conversion submodule, configured to convert the target image into a first grayscale image and normalize the first grayscale image; A first processing submodule is configured to reduce the pixel value of the dark area in the first grayscale image and increase the pixel value of the bright area to obtain a second grayscale image; the bright area is an area where the pixel value is greater than a preset brightness value, and the dark area is an area where the pixel value is less than or equal to the preset brightness value; The second processing submodule is configured to calculate the ratio of the pixel value in the second grayscale image to the pixel value in the first grayscale image, and construct a third grayscale image using the ratio as the pixel value; the value range of the third grayscale image is constrained within a preset value range; The multiplication submodule is configured to multiply the pixel value of the fifth pixel point in the third grayscale image by the pixel value of the sixth pixel point corresponding to the fifth pixel point in the target image to obtain a target image with reduced brightness of the dark area.
19. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method as claimed in any one of claims 1 to 9.
20. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method as claimed in any one of claims 1 to 9.
21. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Image processing method and device, electronic device, and computer readable storage medium
CN108537155A
Image processing method and device, electronic device and computer readable memory medium
CN108632512A
Image processing method, apparatus, electronic device, and computer-readable storage medium
CN109242794A