Method, apparatus, electronic device, and medium for processing an image
By performing horizontal and vertical blur processing and image fusion on the original image, the target image after accurate beautification is solved, and the processing efficiency and effect are improved.
Patent Information
- Application Number
- CN202111474283.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2020-12-03
- Filing Date
- 2021-12-03
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2041-12-03
AI Technical Summary
In the prior art, it takes a lot of time for ordinary users to use image processing tools to perform image beautification processing.
By performing horizontal and vertical blurring on the original image, combining mean blur and image fusion technology, an accurately beautified target image is generated.
It reduces the time for users to process images and improves the efficiency and accuracy of image beautification.
Smart Images

Figure CN114596215B_ABST
Abstract
Description
[0001] This application claims the priority of a Chinese patent application titled "Method, Apparatus, Electronic Device, and Medium for Processing Images" with an application number of 202011396215.1 and filed with the Chinese Patent Office on December 3, 2020. The entire content of which is incorporated herein by reference. Technical Field
[0002] The present application relates to the technology of image processing, in particular to a method, apparatus, electronic device, and medium for processing images. Background Art
[0003] Due to the rise of the communication era and society, intelligent devices have been continuously developing with the increasing use of more and more users.
[0004] Furthermore, since intelligent devices generally have an image capture function, the beautification processing technology of face images has attracted more and more attention. Among them, the main purpose of image beautification processing is to beautify the details while relatively completely retaining the face part. In the related art, users can use image processing tools to process images.
[0005] However, in the way that users use image processing tools to process images, it is a very cumbersome and boring task for an ordinary user who has no idea how to use the software at all, and it takes a lot of time of the user. Summary of the Invention
[0006] Embodiments of the present application provide a method, apparatus, electronic device, and medium for processing images. The embodiments of the present application are used to solve the problem in the related art that users need to spend a lot of time processing images.
[0007] Among them, according to one aspect of the embodiments of the present application, a method for processing images is provided, which is characterized by including: [[ID=Z6]]
[0008] Obtain an original image including a face region;
[0009] Perform at least one first blurring process on the original image to obtain a first blurred image. The first blurring process includes a horizontal blurring process and a vertical blurring process;
[0010] Perform mean blurring on the first blurred image to obtain a second blurred image;
[0011] Perform image fusion on the first blurred image and the original image to obtain a first image to be processed;
[0012] Perform image fusion on the original image, the first image to be processed, and the second blurred image to obtain a target processed image.
[0013] Optionally, in another embodiment of the method based on the above application, the at least one first blurring process on the original image includes:
[0014] For each pixel in the original image, determine the first adjacent pixels adjacent to the pixel horizontally, and change the pixel value of the pixel based on the pixel values of the first adjacent pixels;
[0015] For each pixel in the original image, determine the second adjacent pixels adjacent to the pixel vertically, and change the pixel value of the pixel based on the pixel values of the second adjacent pixels;
[0016] Wherein, the number of pixels of the first adjacent pixels is the same as that of the second adjacent pixels.
[0017] Optionally, in another embodiment of the method based on the above application, changing the pixel value of the pixel based on the pixel value of the first adjacent pixel includes: changing the pixel value of the pixel to the weighted average of the pixel values of the first adjacent pixels;
[0018] Changing the pixel value of the pixel based on the pixel value of the second adjacent pixel includes: changing the pixel value of the pixel to the weighted average of the pixel values of the second adjacent pixels.
[0019] Optionally, in another embodiment of the method based on the above application, before the at least one first blurring process on the original image, it further includes:
[0020] Scaling the original image by a first ratio.
[0021] Optionally, in another embodiment of the method based on the above application, the image fusion of the first blurred image and the original image to obtain the first image to be processed includes:
[0022] Performing contrast processing on the first blurred image;
[0023] Performing edge extraction on the first blurred image after contrast processing to obtain a second image to be processed;
[0024] Performing at least one second blurring process on the second image to be processed to obtain a third blurred image, and the second blurring process includes horizontal blurring processing and vertical blurring processing;
[0025] Performing image fusion on the first blurred image, the third blurred image and the original image to obtain the first image to be processed.
[0026] Optionally, in another embodiment based on the above method of the present application, the step of performing image fusion on the first blurred image, the third blurred image, and the original image to obtain the first image to be processed includes:
[0027] Performing image fusion on the first blurred image, the third blurred image, and the original image to obtain a first fused image;
[0028] Determining, in the first fused image, a first image region with a brightness value greater than a preset parameter and a second image region with a brightness value not greater than the preset parameter;
[0029] Combining the first image region composed of the original image and the second image region composed of the first fused image as the first image to be processed.
[0030] Optionally, in another embodiment based on the above method of the present application, the step of performing mean blur on the first blurred image to obtain a second blurred image includes:
[0031] Scaling the first blurred image by a second ratio;
[0032] Performing mean blur on the scaled first blurred image to obtain the second blurred image.
[0033] Optionally, in another embodiment based on the above method of the present application, the step of performing mean blur on the first blurred image to obtain a second blurred image includes:
[0034] For each pixel in the first blurred image, determining third adjacent pixels adjacent to the pixel;
[0035] Changing the pixel value of the pixel to the weighted mean of the pixel values of the third adjacent pixels to obtain the second blurred image.
[0036] Optionally, in another embodiment based on the above method of the present application, the step of performing image fusion on the original image, the first image to be processed, and the second blurred image to obtain a target processed image includes:
[0037] Performing image fusion on the original image, the first image to be processed, and the second blurred image to obtain a second fused image;
[0038] Obtaining a sharpness parameter and using the sharpness parameter to adjust the sharpness of the second fused image to obtain the target processed image.
[0039] Optionally, in another embodiment based on the above method of the present application, the step of obtaining the sharpness parameter includes:
[0040] Determine the sharpness parameter based on the luminance value of the pixels in the second fused image; or,
[0041] Receive the sharpness parameter set by the user.
[0042] Optionally, in another embodiment of the method based on the present application, after fusing the original image, the first image to be processed, and the second blurred image to obtain a target processed image, the method further includes:
[0043] Fuse the target processed image and the original image with a first preset ratio to obtain a third fused image and display it to the user;
[0044] If it is determined that a modification instruction generated by the user for the third fused image is received, based on the modification instruction, determine a second preset ratio, where the second preset ratio is used to represent the processed image desired by the user;
[0045] Fuse the target processed image and the original image with the second preset ratio to obtain a fourth fused image;
[0046] Display the fourth fused image to the user.
[0047] Optionally, in another embodiment of the method based on the present application, the performing at least one first blurring process on the original image to obtain a first blurred image includes:
[0048] Use a preset image recognition neural network to detect the feature parameters of the face region, and determine the user attributes reflected by the face region based on the feature parameters, where the user attributes are used to represent at least one of the gender, age, and skin color status of the person;
[0049] Determine the number of times for blurring processing according to the user attributes;
[0050] Perform the first blurring process on the original image for the determined number of times.
[0051] Optionally, in another embodiment of the method based on the present application, the performing at least one first blurring process on the original image to obtain a first blurred image includes:
[0052] Determine the number of face regions included in the original image;
[0053] If it is determined that the number of face regions is at least two, select different numbers of first blurring processes for each face region included in the original image.
[0054] Among them, according to one aspect of the embodiments of the present application, a device for processing images is provided, which is characterized by including:
[0055] An acquisition module, configured to acquire an original image including a face region;
[0056] A processing module, configured to perform at least one first blurring process on the original image to obtain a first blurred image, where the first blurring process includes a horizontal blurring process and a vertical blurring process;
[0057] The processing module is configured to perform mean blurring on the first blurred image to obtain a second blurred image;
[0058] A fusion module, configured to perform image fusion on the first blurred image and the original image to obtain a first image to be processed;
[0059] A generation module, configured to perform image fusion on the original image, the first image to be processed, and the second blurred image to obtain a target processed image.
[0060] According to another aspect of the embodiments of the present application, an electronic device is provided, including:
[0061] A memory, used to store executable instructions; and
[0062] A display, configured to display with the memory to execute the executable instructions so as to complete the operations of any of the above methods for processing images.
[0063] According to still another aspect of the embodiments of the present application, a computer-readable storage medium is provided, used to store computer-readable instructions, and when the instructions are executed, the operations of any of the above methods for processing images are performed.
[0064] In the present application, an original image including a face region is acquired, and at least one first blurring process including a horizontal blurring process and a vertical blurring process is performed on the original image. Then, the first blurred image and the original image are subjected to image fusion to obtain a first image to be processed. After that, the original image, the first image to be processed, and the second blurred image are subjected to image fusion to obtain a target processed image, where the second blurred image is an image obtained by performing mean blurring on the first blurred image. By applying the technical solution of the present application, the original image can be blurred through a blurred image obtained by including horizontal blurring and vertical blurring, and then multiple different degrees of fusion are performed on the original image and the blurred image, so as to obtain a precisely beautified target image. Furthermore, the problem of long processing time caused by only being able to use the mean blurring method to process images for users in the related art is avoided.
[0065] The technical solution of the present application will be further described in detail below with reference to the drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] The drawings forming a part of the specification depict embodiments of the present application and, together with the description, are used to explain the principles of the present application.
[0067] With reference to the drawings, the present application can be more clearly understood from the following detailed description, where:[[]]END]]
[0068] Figure 1 is a schematic diagram of the system architecture for processing images proposed in the present application;
[0069] <E Figure 2 is a schematic diagram of a method for obtaining image parameters proposed in the present application;
[0070] Figures 3a - 3b is a schematic diagram of the effect of processing images proposed in the present application;
[0071] Figures 4a - 4d is a schematic diagram of the effect of processing images proposed in the present application;
[0072] Figures 5a - 5b is a schematic diagram of the effect of processing images proposed in the present application;
[0073] Figure 6 is a schematic diagram of the method flow for processing images proposed in the present application;
[0074] Figure 7 is a schematic diagram of the structure of an electronic device for processing images proposed in the present application;
[0075] Figure 8 is a schematic diagram showing the structure of an electronic device according to the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0076] Various exemplary embodiments of the present application will now be described in detail with reference to the drawings. It should be noted that: unless otherwise specifically stated, the relative arrangements, numerical expressions, and numerical values of the components and steps set forth in these embodiments do not limit the scope of the present application.
[0077] At the same time, it should be understood that, for the sake of convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0078] The following description of at least one exemplary embodiment is merely illustrative in nature and is not intended as any limitation on the present application or its application or use.
[0079] Technologies, methods, and devices known to those of ordinary skill in the relevant art may not be discussed in detail, but where appropriate, such technologies, methods, and devices should be regarded as part of the specification.
[0080] It should be noted that like reference numerals and letters denote like items in the following figures, and thus, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0081] In addition, the technical solutions between various embodiments of the present application can be combined with each other, but it must be based on the fact that those skilled in the art can implement it. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present application.
[0082] It should be noted that all directional indications (such as up, down, left, right, front, back...) in the embodiments of the present application are only used to explain the relative positional relationship and movement conditions between components in a certain specific posture (as shown in the figures). If the specific posture changes, the directional indications will also change accordingly.
[0083] Next, in combination with Figures 1 - 6 to describe a method for processing images according to an exemplary embodiment of the present application. It should be noted that the following application scenarios are only shown for the convenience of understanding the spirit and principle of the present application, and the embodiments of the present application are not limited in this regard. On the contrary, the embodiments of the present application can be applied to any applicable scenario.
[0084] Figure 1 The schematic diagram of an exemplary system architecture 100 to which the method for processing images according to the embodiments of the present application can be applied is shown.
[0085] As Figure 1 shown, the system architecture 100 may include one or more of the terminal devices 101, 102, 103, the network 104, and the server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0086] It should be understood that Figure 1 the numbers of terminal devices, networks, and servers in
[0087] are merely illustrative. According to the implementation requirements, there can be any number of terminal devices, networks, and servers. For example, the server 105 can be a server cluster composed of multiple servers, etc.
[0088] The terminal devices 101, 102, and 103 in this application can be terminal devices capable of sending, receiving, and processing images. For example, a user obtains an original image containing a face region through the terminal device 103 (which can also be the terminal device 101 or 102); performs at least one first blurring process on the original image, where the first blurring process includes a horizontal blurring process and a vertical blurring process, to obtain a first blurred image; performs image fusion on the first blurred image and the original image to obtain a first image to be processed; performs image fusion on the original image, the first image to be processed, and a second blurred image to obtain a target processed image, where the second blurred image is an image obtained by performing mean blurring on the first blurred image.
[0089] It should be noted here that the method for processing images provided in the embodiments of this application can be executed by one or more of the terminal devices 101, 102, 103, and / or the server 105. Correspondingly, the device for processing images provided in the embodiments of this application is generally set in the corresponding terminal device and / or the server 105, but this application is not limited thereto.
[0090] This application also proposes a method, device, target terminal, and medium for processing images.
[0091] Figure 2 Schematically shows a flowchart of a method for processing images according to an embodiment of this application. As Figure 2 shown, the method includes:
[0092] S101, obtain an original image containing a face region.
[0093] First of all, it should be noted that this application does not specifically limit the device for obtaining the original image. For example, it can be a server. In one way, it can also be a mobile terminal device with a display function such as a smart phone, a tablet computer, an e-book reader, a portable computer, etc. that has the function of processing images.
[0094] Furthermore, the solution of this application does not specifically limit the original image. It can be an image containing a face region, or multiple images containing a face region. Similarly, in the implementation scheme of this application, the original image can contain one face or multiple faces.
[0095] Optionally, the original image is an image that needs to be beautified. The original image can be collected by a mobile terminal. For example, a camera for shooting is installed on the mobile terminal. The user can initiate a photo-taking instruction through the mobile terminal. After the mobile terminal detects the photo-taking instruction, it collects a photo through the camera. The mobile terminal will store the collected image to form an image set.
[0096] It is understandable that the original image can also be obtained through other means, which is not limited here. For example, the original image can also be downloaded from a web page or imported from an external storage device, etc. Specifically, after the mobile terminal obtains the original image, it can perform beautification processing locally on the mobile terminal, or send the original image to the server for beautification processing.
[0097] S102: Perform at least one first blurring process on the original image to obtain a first blurred image.
[0098] First, this application does not specifically limit the number of times of the first blurring process. For example, it can be once or multiple times. Additionally, in one way, the number of times of the first blurring process can be determined according to the number of face regions included in the image or the user attributes reflected by the face regions.
[0099] For example, when the user attribute reflected by the face region is female, multiple blurring processes can be performed, and when the user attribute reflected by the face region is male, one blurring process can be performed. Or, when the user attribute reflected by the face region is young, multiple blurring processes can be performed, and when the user attribute reflected by the face region is old, one blurring process can be performed. Also, when the number of users reflected by the face region is multiple, multiple blurring processes can be performed, and when the number of users reflected by the face region is one, one blurring process can be performed, etc.
[0100] Furthermore, for blurring the original image, it is a way of performing image filtering on the original image. Specifically, image blurring is an operation in image processing and computer vision. It is mainly to remove noise in the image.
[0101] Moreover, the first blurring process includes two processes: horizontal blurring and vertical blurring. However, this application does not specifically limit the order of the horizontal blurring and the vertical blurring. For example, the image can be first horizontally blurred and then the horizontally blurred image can be vertically blurred. Or, the image can be first vertically blurred and then the vertically blurred image can be horizontally blurred.
[0102] S103: Perform mean blurring on the first blurred image to obtain a second blurred image.
[0103] S104: Perform image fusion on the first blurred image and the original image to obtain a first image to be processed.
[0104] Furthermore, for image fusion, it refers to the process of synthesizing multiple images to generate a target image. In this application, after obtaining the first blurred image by performing at least one first blurring process on the original image, it is possible to utilize image processing and computer technology, etc., to extract the beneficial information in the first blurred image and the original image to the greatest extent, so as to comprehensively fuse them into a high-quality first image to be processed, improve the utilization rate of image information, improve the computer interpretation accuracy and reliability, and enhance the spatial resolution and spectral resolution of the original image.
[0105] S105, perform image fusion on the original image, the first image to be processed, and the second blurred image to obtain the target processed image.
[0106] In this application, an original image containing a face region is obtained, and the original image is subjected to at least one first blurring process including horizontal blurring and vertical blurring to obtain the first blurred image. Then, the first blurred image and the original image are subjected to image fusion to obtain the first image to be processed. After that, the original image, the first image to be processed, and the second blurred image obtained by performing mean blurring on the first blurred image are subjected to image fusion to obtain the target processed image. By applying the technical solution of this application, the original image can be blurred through horizontal blurring and vertical blurring, and then the blurred image is fused with the original image and the blurred image in multiple different degrees, so as to obtain the accurately beautified target image. Furthermore, it can avoid the problem of long processing time caused by only being able to use the mean blurring method to process images for users in the related art.
[0107] Optionally, in a possible implementation manner of this application, in S102 (performing at least one first blurring process on the face region), it can be implemented through the following steps:
[0108] For each pixel in the original image, determine the first adjacent pixel adjacent to the pixel horizontally, and change the pixel value of the pixel based on the pixel value of the first adjacent pixel;
[0109] For each pixel in the original image, determine the second adjacent pixel adjacent to the pixel vertically, and change the pixel value of the pixel based on the pixel value of the second adjacent pixel;
[0110] Wherein, the number of pixels of the first adjacent pixel and the second adjacent pixel is the same.
[0111] Optionally, the process of changing the pixel value of the pixel based on the pixel value of the first adjacent pixel can be to change the pixel value of the pixel to the weighted mean of the pixel values of the first adjacent pixels; and,
[0112] The process of changing the pixel value of the pixel based on the pixel values of the second adjacent pixels may be to change the pixel value of the pixel to the weighted mean of the pixel values of the second adjacent pixels.
[0113] It should be noted that in the process of performing horizontal blurring processing and vertical blurring processing on the original image in this application, the order of horizontal blurring processing and vertical blurring processing is not specifically limited. For example, the image can be first subjected to horizontal blurring processing, and then the image after horizontal blurring processing can be subjected to vertical blurring processing. It is also possible to first perform vertical blurring processing on the image, and then perform horizontal blurring processing on the image after vertical blurring processing.
[0114] Further, as Figures 3a - 3b shown, the following are the before and after effect diagrams of performing at least one first blurring process on the original image, where in the embodiments of this application, at least one horizontal blurring process and vertical blurring process can be performed on each pixel in the original image.
[0115] For example, taking the number of the first adjacent pixels and the second adjacent pixels as 3 as an example, as Figures 4a - 4b shown, when performing horizontal blurring processing on a pixel with a pixel value of 2, determine the 3 first adjacent pixels on the left and right that are horizontally adjacent to this pixel, that is, 1, 1, 1 respectively. And change the pixel value of this pixel to the weighted mean of the pixel values of its adjacent first adjacent pixels (that is, the pixel value 1).
[0116] Similarly, as Figures 4c - 4d shown, that is, when performing vertical blurring processing on a pixel with a pixel value of 2, determine the 3 second adjacent pixels above and below that are vertically adjacent to this pixel, that is, 1, 1, 1 respectively. And change the pixel value of this pixel to the weighted mean of the pixel values of its adjacent second adjacent pixels (that is, the pixel value 1).
[0117] Optionally, in a possible implementation manner of this application, before S102 (performing at least one first blurring process on the original image), it can be implemented through the following steps:
[0118] Scale the original image containing the face region by a first ratio.
[0119] The face in the image can be made clearer by scaling the original image by a certain ratio. This application does not specifically limit the first ratio. For example, it can be one-half, or one-third, etc.
[0120] Optionally, in a possible implementation manner of this application, in S104 (performing image fusion on the first blurred image and the original image to obtain the first image to be processed), it can be implemented through the following steps:
[0121] Perform contrast processing on the first blurred image;
[0122] Perform edge extraction on the first blurred image after contrast processing to obtain a second image to be processed;
[0123] Perform at least one second blurring process on the second image to be processed to obtain a third blurred image. The second blurring process includes horizontal blurring and vertical blurring.
[0124] Perform image fusion on the first blurred image, the third blurred image, and the original image to obtain a first image to be processed.
[0125] Further, after obtaining the first blurred image in this application, contrast processing can be performed on it. Among them, contrast processing is to obtain the pixel intensity of the inverted image, so that the foreground in the image becomes the background and the background becomes the foreground. In the embodiments of this application, the contrast processing of the first blurred image can be achieved by changing the pixel mapping of the first blurred image. For example, the pixel value 0 of the first blurred image can be changed to 255, 1 to 254... 254 to 1, and 255 to 0. Thus, the first blurred image after contrast processing is obtained.
[0126] Furthermore, in this application, edge extraction can be performed on the first blurred image after contrast processing to obtain a second image to be processed. Specifically, it can be obtained by using the following formula:
[0127] Dst = src - src1;
[0128] Where Dst is the second image to be processed, src is the first blurred image, and src1 is the first blurred image after contrast processing.
[0129] In addition, in order to eliminate the noise in the second image to be processed obtained by edge extraction, as Figures 5a - 5b shown, this application also needs to perform at least one second blurring process on the second image to be processed to obtain a third blurred image. The second blurring process also includes horizontal blurring and vertical blurring. And perform image fusion on the first blurred image, the third blurred image, and the original image to obtain a first image to be processed.
[0130] First, this application does not specifically limit the number of times of the second blurring process. For example, it can be once or multiple times. In addition, in one way, the number of times of the second blurring process can be determined according to the number of face regions included in the original image or the user attributes reflected by the face regions. It should be noted that the method of performing the second blurring process on the second image to be processed in this application is the same as the principle of the first blurring process in step 102 above, and will not be elaborated here.
[0131] Optionally, in the present application, the first blurred image, the third blurred image and the original image are subjected to image fusion to obtain a first image to be processed, which can be realized through the following steps:
[0132] Perform image fusion on the first blurred image, the third blurred image and the original image to obtain a first fused image;
[0133] Determine a first image region in the first fused image where the luminance value is greater than a preset parameter, and a second image region where the luminance value is not greater than the preset parameter;
[0134] Combine the first image region composed of the original image and the second image region composed of the first fused image as the first image to be processed.
[0135] Furthermore, since the original image usually includes a face region image and a non-face region image (for example, when the user takes a selfie with the back against the wall, the wall part behind the user is the non-face region image). And during the process of beautifying the user image, usually only the face region part needs to be processed, that is, there is no need to beautify the non-face part. Therefore, in the embodiments of the present application, after performing image fusion on the first blurred image, the third blurred image and the original image to obtain a first fused image, it is necessary to distinguish the face part and the non-face part in the fused image.
[0136] Furthermore, in the embodiments of the present application, the face part and the non-face part in the image can be determined according to the luminance values of the respective image regions where the first fused image is located. It can be understood that since the third blurred image is obtained by performing a second blurring process on the second image to be processed, and the second image to be processed is an image obtained by performing edge extraction on the first blurred image after contrast processing (that is, the luminance of the processed image in the user's face part is poor). Therefore, in the present application, it can be determined that in the first fused image, a first image region where the luminance value is greater than the preset parameter (i.e., the non-face part), and a second image region where the luminance value is not greater than the preset parameter (the face part). And the first image region composed of the original image (that is, the non-face part retains the original image), and the second image region composed of the first fused image are combined as the first image to be processed (that is, the face part retains the blurred image).
[0137] It should be noted that the present application does not specifically limit the preset parameter. For example, it can be 10 cd / m, or 100 cd / m, etc.
[0138] Optionally, in a possible implementation manner of the present application, in S103 (performing mean blurring on the first blurred image to obtain a second blurred image), it can be realized through the following steps:
[0139] Scale the first blurred image by a second ratio;
[0140] Perform mean blurring on the scaled first blurred image to obtain a second blurred image.
[0141] Herein, the present application does not specifically limit the second ratio. For example, it can be one-half, one-third, etc. Additionally, the second ratio can be the same as the first ratio, or the second ratio can be different from the first ratio.
[0142] Optionally, in S103 (performing mean blurring on the first blurred image to obtain a second blurred image) of the present application, it can also be implemented through the following steps:
[0143] For each pixel in the first blurred image, determine the third adjacent pixels adjacent to this pixel;
[0144] Change the pixel value of this pixel to the weighted mean of the pixel values of the third adjacent pixels to obtain a second blurred image.
[0145] In the embodiments of the present application, the pixel value of the pixel point to be processed can be processed as the average value of the values of all adjacent neighboring pixel points around it. Specifically, the present application needs to determine the sum of the pixel values of several adjacent pixels around the pixel point to be processed, so as to subsequently take the current pixel point as the center, read all the pixel points in a surrounding adjacent area and calculate the average value, and use the calculated average value result as the pixel value of this point.
[0146] It should be noted that the third adjacent pixels adjacent to the pixel point to be processed include not only the horizontally adjacent pixels and the vertically adjacent pixels, but also the diagonally adjacent pixels.
[0147] Furthermore, if the two implementations of S103 given above are combined, then the pixel point to be processed is the pixel point in the scaled first blurred image.
[0148] Optionally, in a possible implementation manner of the present application, in S105 (performing image fusion on the original image, the first image to be processed, and the second blurred image to obtain a target processed image), it can be implemented through the following steps:
[0149] Perform image fusion on the original image, the first image to be processed, and the second blurred image to obtain a second fused image;
[0150] Obtain a sharpness parameter, and use this sharpness parameter to perform sharpness adjustment on the second fused image to obtain a target processed image.
[0151] Furthermore, in the present application, after obtaining the second fused image, perform sharpness adjustment by obtaining an appropriate sharpness parameter, so as to achieve the purpose of improving the image recognition effect of the face area.
[0152] In an alternative embodiment, for the process of obtaining the sharpness parameter, the sharpness parameter can be determined based on the luminance values of the pixels in the second fused image. Specifically, the present application can determine the sharpness parameter according to the following formula:
[0153]
[0154] where M is the sharpness parameter, I max is the maximum luminance value of the image, and I min is the minimum luminance value of the image.
[0155] In one way, the sharpness parameter can be the difference between the maximum luminance value and the minimum luminance value of the image divided by their sum. For example, in an image, when Imax = 255 and Imin = 10, then the sharpness parameter M = 0.9245.
[0156] In another alternative embodiment, for the process of obtaining the sharpness parameter, it can also be obtained by receiving the sharpness parameter set by the user.
[0157] Furthermore, in the process of adjusting the sharpness of the second fused image, the present application can also adaptively adjust the image size of the second fused image, so as to achieve the purpose of improving the object recognition effect while ensuring that the objects in the depth image are clear as much as possible.
[0158] Optionally, after the present application fuses the original image, the first image to be processed, and the second blurred image to obtain the target processed image, it further includes:
[0159] Fusing the target processed image and the original image with a first preset ratio to obtain a third fused image and display it to the user;
[0160] If it is determined that a modification instruction generated by the user for the third fused image is received, based on the modification instruction, determine a second preset ratio, and the second preset ratio is used to represent the processed image expected by the user;
[0161] Fusing the target processed image and the original image with a second preset ratio to obtain a fourth fused image;
[0162] Display the fourth fused image to the user.
[0163] Optionally, after the sharpness of the second fused image is adjusted to obtain the target processed image in this application, in order to meet the requirements of different users for the processed picture effect. In the embodiments of this application, it may not directly display the target processed image. Instead, it is selected to be displayed in a way of a certain weight ratio. For example, taking the first preset ratio of 50% as an example, after obtaining the target processed image in this application, the target processed image and the original image can be fused with each occupying half of the ratio, so as to obtain the third fused image. In other words, the third fused image is that each pixel displays 50% of the original image and each pixel displays 50% of the target processed image.
[0164] Furthermore, when the third fused image is displayed to the user, if the user is not satisfied with the third fused image, a modification instruction for changing the preset ratio can be generated. It can be understood that this modification instruction is used to represent the processed image expected by the user. For example, when the user believes that the beautification degree of the third fused image is insufficient, a second preset ratio can be generated. Taking the second preset ratio of 80% as an example, in the embodiments of this application, the target processed image and the original image can be fused at an 80% ratio to obtain the fourth fused image (that is, each pixel displays 20% of the original image and each pixel displays 80% of the target processed image).
[0165] It should be noted that this application does not specifically limit the first preset ratio and the second preset ratio. In one way, it is only necessary that the first preset ratio and the second preset ratio are different.
[0166] Optionally, in a possible implementation manner of this application, in S102 (performing at least one first blurring process on the original image to obtain the first blurred image), the following two implementations may also be included:
[0167] The first implementation:
[0168] Using a preset image recognition neural network, detecting the feature parameters of the face area, and determining the user attributes reflected by the face area based on the feature parameters, where the user attributes are used to represent at least one of the person's gender, age, and skin color status;
[0169] Determining the number of times of blurring processing according to the user attributes;
[0170] Performing the first blurring process on the face area in the original image for this number of times.
[0171] Further, for example, when the user attribute reflected by the face region is female, the number of blurring processes can be set to multiple times, while when the user attribute reflected by the face region is male, the number of blurring processes can be set to one time. Or, when the user attribute reflected by the face region is young, the number of blurring processes can be set to multiple times, while when the user attribute reflected by the face region is old, the number of blurring processes can be set to one time. Or, when the skin color state of the person reflected by the face region is darker, the number of blurring processes can be set to multiple times, while when the skin color state of the person reflected by the face region is lighter, the number of blurring processes can be set to one time, and so on.
[0172] Among them, the present application does not specifically limit the image recognition neural network. For example, it can be a Convolutional Neural Networks (CNN). A convolutional neural network is a type of feedforward neural network that contains convolutional calculations and has a deep structure, and is one of the representative algorithms of deep learning. The convolutional neural network has the ability of representation learning and can perform translation-invariant classification on the input information according to its hierarchical structure. Thanks to the powerful feature representation ability of the CNN (convolutional neural network) for images, remarkable results have been achieved in the fields of image classification, object detection, semantic segmentation, etc.
[0173] Further, the present application can use the CNN neural network model to detect the feature parameters of the face region in the original image, and then perform feature recognition on the face region to determine the user attribute reflected by the face region. Among them, it is necessary to input the face region image into a preset convolutional neural network model, and use the output of the last fully connected layer (FC, fully connected layer) of the convolutional neural network model as the recognition result of the feature data corresponding to the face region image.
[0174] The second implementation:
[0175] Determine the number of face regions included in the original image;
[0176] If it is determined that the number of face regions is at least two, select different numbers of first blurring processes for each face region included in the original image.
[0177] Further, for example, when the number of users reflected by the face region is multiple, different numbers of blurring processes can be selected for each part of the face region.
[0178] Such as Figure 6As shown in the figure, it is a flowchart of a method for processing images proposed in this application. First, it is necessary to obtain an original image containing a face region, and use a preset image recognition neural network to detect the feature parameters of the face region. Based on the feature parameters, the user attributes reflected by the face region are determined. The user attributes are used to represent at least one of the person's gender, age, and skin color status. Then, according to the user attributes, the number of times of blur processing is determined, so as to perform the horizontal blur processing and vertical blur processing of the original image for this number of times to obtain a first blurred image. That is to say, for each pixel point in the original image, the horizontal blur processing and vertical blur processing of this number of times are performed.
[0179] Alternatively, after obtaining the original image containing the face region, the number of face regions in the original image can be determined. If it is determined that the number of face regions is at least two, different numbers of first blur processes are performed on each face region in the original image.
[0180] Furthermore, this application can also scale the original image containing the face region by a first ratio, and then perform at least one first blur process on the scaled original image to obtain a first blurred image.
[0181] Still further, after this application performs a contrast process on the first blurred image and extracts the edges of the first blurred image after the contrast process to obtain a second image to be processed, at least one second blur process can be performed on the second image to be processed to obtain a third blurred image, where the second blur process includes horizontal blur processing and vertical blur processing. Even further, the first blurred image, the third blurred image, and the original image can be fused to obtain a first fused image. The first image region with a brightness value greater than a preset parameter and the second image region with a brightness value not greater than the preset parameter in the first fused image are determined. The first image region composed of the original image and the second image region composed of the first fused image are combined as the first image to be processed.
[0182] Finally, for each pixel point to be processed on the first blurred image, the third adjacent pixels adjacent to the pixel point to be processed are determined, and the pixel value of the pixel point to be processed is changed to the weighted average of the pixel values of the third adjacent pixels to obtain a second blurred image. Then, the original image, the first image to be processed, and the second blurred image are fused to obtain a second fused image. The sharpness parameter is obtained, and the second fused image is sharpness-adjusted using the sharpness parameter to obtain the target processed image.
[0183] By applying the technical solution of the present application, after obtaining a blurred image by including horizontal blur and vertical blur to the original image, the original image and the blurred image can be fused multiple times with different degrees, so as to obtain a precisely beautified target image. Furthermore, it can avoid the problem of long processing time caused by only using the mean blur method to process images for users in the related art.
[0184] In another embodiment of the present application, as Figure 7 shown, the present application also provides an image processing device. Among them, the device includes an acquisition module 201, a processing module 202, a fusion module 203, and a generation module 204, where
[0185] The acquisition module 201 is configured to acquire an original image including a face region;
[0186] The processing module 202 is configured to perform at least one first blurring process on the original image to obtain a first blurred image, and the first blurring process includes a horizontal blurring process and a vertical blurring process;
[0187] The processing module 202 is configured to perform mean blur on the first blurred image to obtain a second blurred image;
[0188] The fusion module 203 is configured to perform image fusion on the first blurred image and the original image to obtain a first image to be processed;
[0189] The generation module 204 is configured to perform image fusion on the original image, the first image to be processed, and the second blurred image to obtain a target processed image.
[0190] In the present application, an original image including a face region is acquired, and at least one first blurring process including a horizontal blurring process and a vertical blurring process is performed on the face region in the original image. Then, the first blurred image is fused with the original image to obtain a first image to be processed. After that, the original image, the first image to be processed, and the second blurred image obtained by performing mean blur on the first blurred image are fused to obtain a target processed image. By applying the technical solution of the present application, after obtaining a blurred image by including horizontal blur and vertical blur to the original image, the original image and the blurred image can be fused multiple times with different degrees, so as to obtain a precisely beautified target image. Furthermore, it can avoid the problem of long processing time caused by only using the mean blur method to process images for users in the related art.
[0191] Optionally, in another embodiment of the present application, the processing module 202 is specifically configured to, for each pixel in the original image, determine a first adjacent pixel adjacent to the pixel horizontally, and change the pixel value of the pixel based on the pixel value of the first adjacent pixel; for each pixel in the original image, determine a second adjacent pixel adjacent to the pixel vertically, and change the pixel value of the pixel based on the pixel value of the second adjacent pixel; wherein, the number of pixels of the first adjacent pixel is the same as that of the second adjacent pixel.
[0192] Optionally, in another embodiment of the present application, the processing module 202 is specifically configured to change the pixel value of the pixel to the weighted mean of the pixel values of the first adjacent pixels; and change the pixel value of the pixel to the weighted mean of the pixel values of the second adjacent pixels.
[0193] Optionally, in another embodiment of the present application, the device further includes ( Figure 7 not shown):
[0194] an image scaling module, configured to scale the original image including the face region by a first ratio.
[0195] Optionally, in another embodiment of the present application, the fusion module 203 is specifically configured to perform contrast processing on the first blurred image; perform edge extraction on the contrast-processed first blurred image to obtain a second image to be processed; perform at least one second blur processing on the second image to be processed to obtain a third blurred image, where the second blur processing includes the horizontal blur processing and the vertical blur processing; perform image fusion on the first blurred image, the third blurred image and the original image to obtain the first image to be processed.
[0196] Optionally, in another embodiment of the present application, the fusion module 203 is further specifically configured to perform image fusion on the first blurred image, the third blurred image and the original image to obtain a first fused image; determine a first image region in the first fused image where the brightness value is greater than a preset parameter, and a second image region where the brightness value is not greater than the preset parameter; combine the first image region composed of the original image and the second image region composed of the first fused image as the first image to be processed.
[0197] Optionally, in another embodiment of the present application, the processing module 202 is further specifically configured to scale the first blurred image by a second ratio; perform mean blur on the scaled first blurred image to obtain the second blurred image.
[0198] Optionally, in another embodiment of the present application, the processing module 202 is further specifically configured to, for each pixel in the first blurred image, determine third adjacent pixels adjacent to the pixel; change the pixel value of the pixel to a weighted average of the pixel values of the third adjacent pixels to obtain the second blurred image.
[0199] Optionally, in another embodiment of the present application, the generating module 204 is specifically configured to perform image fusion on the original image, the first image to be processed, and the second blurred image to obtain a second fused image; obtain a sharpness parameter, and use the sharpness parameter to perform sharpness adjustment on the second fused image to obtain the target processed image.
[0200] Optionally, in another embodiment of the present application, the generating module 204 is specifically configured to determine a sharpness parameter based on the luminance value of the pixels in the second fused image; or receive a sharpness parameter set by the user.
[0201] Optionally, in another embodiment of the present application, the device further includes ( Figure 7 not shown in the figure):
[0202] A display module, configured to perform image fusion on the target processed image and the original image at a first preset ratio to obtain a third fused image and display it to the user; if it is determined that a modification instruction generated by the user for the third fused image is received, based on the modification instruction, determine a second preset ratio, where the second preset ratio is used to represent the processed image expected by the user; perform image fusion on the target processed image and the original image at the second preset ratio to obtain a fourth fused image; display the fourth fused image to the user.
[0203] Optionally, in another embodiment of the present application, the processing module 202 is specifically configured to use a preset image recognition neural network to detect the feature parameters of the face region, and determine the user attributes reflected by the face region based on the feature parameters, where the user attributes are used to represent at least one of the gender, age, and skin color status of the person; according to the user attributes, determine the number of times of blurring processing; perform the first blurring processing on the original image for the number of times.
[0204] Optionally, in another embodiment of the present application, the processing module 202 is further specifically configured to determine the number of face regions included in the original image; if the number of face regions is at least two, select different numbers of times of the first blurring processing for each face region included in the original image.
[0205] Figure 8It is a block diagram of the logic structure of an electronic device shown according to an exemplary embodiment. For example, the electronic device 300 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.
[0206] Referring to Figure 8 , the electronic device 300 may include one or more of the following components: a processor 301 and a memory 302.
[0207] The processor 301 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 301 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 301 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the wake state, also known as the CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 301 may be integrated with a GPU (Graphics Processing Unit), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 301 may further include an AI (Artificial Intelligence) processor, and the AI processor is used to process computational operations related to machine learning.
[0208] The memory 302 may include one or more computer-readable storage media, and the computer-readable storage media may be non-transitory. The memory 302 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 302 is used to store at least one instruction, and the at least one instruction is used to be executed by the processor 301 to implement the interactive special effect calibration method provided in the method embodiments of the present application.
[0209] In some embodiments, the electronic device 300 may further optionally include: a peripheral device interface 303 and at least one peripheral device. The processor 301, the memory 302, and the peripheral device interface 303 may be connected through a bus or signal lines. Each peripheral device may be connected to the peripheral device interface 303 through a bus, signal lines, or a circuit board. Specifically, the peripheral device includes at least one of a radio frequency circuit 304, a touch display screen 305, a camera 306, an audio circuit 307, a positioning component 308, and a power supply 309.
[0210] The peripheral device interface 303 can be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 301 and the memory 302. In some embodiments, the processor 301, the memory 302, and the peripheral device interface 303 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 301, the memory 302, and the peripheral device interface 303 can be implemented on a separate chip or circuit board, and this embodiment does not limit this.
[0211] The radio frequency circuit 304 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 304 communicates with a communication network and other communication devices through electromagnetic signals. The radio frequency circuit 304 converts an electrical signal into an electromagnetic signal for transmission, or converts a received electromagnetic signal into an electrical signal. Optionally, the radio frequency circuit 304 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and so on. The radio frequency circuit 304 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: a metropolitan area network, each generation of mobile communication networks (2G, 3G, 4G, and 5G), a wireless local area network, and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 304 may further include a circuit related to NFC (Near Field Communication), and this application does not limit this.
[0212] The display screen 305 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 305 is a touch display screen, the display screen 305 also has the ability to collect touch signals on or above the surface of the display screen 305. The touch signals can be input as control signals to the processor 301 for processing. At this time, the display screen 305 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there can be one display screen 305, which is provided on the front panel of the electronic device 300; in other embodiments, there can be at least two display screens 305, which are respectively provided on different surfaces of the electronic device 300 or are in a foldable design; in still other embodiments, the display screen 305 can be a flexible display screen, which is provided on a curved surface or a foldable surface of the electronic device 300. Even further, the display screen 305 can be set to an irregular non-rectangular shape, that is, a special-shaped screen. The display screen 305 can be prepared using materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0213] The camera module 306 is used to capture images or videos. Optionally, the camera module 306 includes a front camera and a rear camera. Generally, the front camera is provided on the front panel of the terminal, and the rear camera is provided on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth camera, a wide-angle camera, and a telephoto camera respectively, to implement functions such as the combination of the main camera and the depth camera to achieve the background blurring function, the combination of the main camera and the wide-angle camera to achieve panoramic shooting and VR (Virtual Reality) shooting functions or other combined shooting functions. In some embodiments, the camera module 306 can also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to the combination of a warm light flash and a cold light flash, which can be used for light compensation under different color temperatures.
[0214] The audio circuit 307 may include a microphone and a speaker. The microphone is used to collect sound waves of the user and the environment, and convert the sound waves into electrical signals for input to the processor 301 for processing, or input to the radio frequency circuit 304 to implement voice communication. For the purpose of stereo collection or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the electronic device 300. The microphone may also be an array microphone or an omnidirectional collection microphone. The speaker is used to convert the electrical signal from the processor 301 or the radio frequency circuit 304 into sound waves. The speaker may be a traditional thin film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for uses such as ranging. In some embodiments, the audio circuit 307 may further include a headphone jack.
[0215] The positioning component 308 is used to locate the current geographical location of the electronic device 300 to implement navigation or LBS (Location Based Service). The positioning component 308 may be a positioning component based on the GPS (Global Positioning System) of the United States, the Beidou system of China, the GLONASS system of Russia, or the Galileo system of the European Union.
[0216] The power supply 309 is used to supply power to each component in the electronic device 300. The power supply 309 may be alternating current, direct current, a disposable battery, or a rechargeable battery. When the power supply 309 includes a rechargeable battery, the rechargeable battery may support wired charging or wireless charging. The rechargeable battery may also be used to support fast charging technology.
[0217] In some embodiments, the electronic device 300 further includes one or more sensors 310. The one or more sensors 310 include, but are not limited to: an acceleration sensor 311, a gyroscope sensor 312, a pressure sensor 313, a fingerprint sensor 314, an optical sensor 315, and a proximity sensor 316.
[0218] The acceleration sensor 311 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established with the electronic device 300. For example, the acceleration sensor 311 can be used to detect the components of the gravitational acceleration on the three coordinate axes. The processor 301 can control the touch display screen 305 to display the user interface in a landscape view or a portrait view according to the gravitational acceleration signal collected by the acceleration sensor 311. The acceleration sensor 311 can also be used for collecting game or user's motion data.
[0219] The gyroscope sensor 312 can detect the body direction and rotation angle of the electronic device 300. The gyroscope sensor 312 can cooperate with the acceleration sensor 311 to collect the 3D actions of the user on the electronic device 300. Based on the data collected by the gyroscope sensor 312, the processor 301 can implement the following functions: motion sensing (such as changing the UI according to the user's tilting operation), image stabilization during shooting, game control, and inertial navigation.
[0220] The pressure sensor 313 can be disposed on the side frame of the electronic device 300 and / or the lower layer of the touch display screen 305. When the pressure sensor 313 is disposed on the side frame of the electronic device 300, it can detect the holding signal of the user on the electronic device 300, and the processor 301 can perform left / right hand recognition or shortcut operations according to the holding signal collected by the pressure sensor 313. When the pressure sensor 313 is disposed on the lower layer of the touch display screen 305, the processor 301 can control the operable controls on the UI interface according to the pressure operation of the user on the touch display screen 305. The operable controls include at least one of a button control, a scroll bar control, an icon control, and a menu control.
[0221] The fingerprint sensor 314 is used to collect the fingerprints of the user. The processor 301 can identify the user's identity according to the fingerprints collected by the fingerprint sensor 314, or the fingerprint sensor 314 can identify the user's identity according to the collected fingerprints. When the identity of the user is identified as a trusted identity, the processor 301 authorizes the user to perform relevant sensitive operations, and the sensitive operations include unlocking the screen, viewing encrypted information, downloading software, making payments, and changing settings, etc. The fingerprint sensor 314 can be disposed on the front, back, or side of the electronic device 300. When there are physical buttons or manufacturer logos on the electronic device 300, the fingerprint sensor 314 can be integrated with the physical buttons or manufacturer logos.
[0222] The optical sensor 315 is used to collect the ambient light intensity. In one embodiment, the processor 301 can control the display brightness of the touch display screen 305 according to the ambient light intensity collected by the optical sensor 315. Specifically, when the ambient light intensity is high, the display brightness of the touch display screen 305 is increased; when the ambient light intensity is low, the display brightness of the touch display screen 305 is decreased. In another embodiment, the processor 301 can also dynamically adjust the shooting parameters of the camera module 306 according to the ambient light intensity collected by the optical sensor 315.
[0223] The proximity sensor 316, also known as the distance sensor, is typically disposed on the front panel of the electronic device 300. The proximity sensor 316 is used to collect the distance between the user and the front of the electronic device 300. In one embodiment, when the proximity sensor 316 detects that the distance between the user and the front of the electronic device 300 is gradually decreasing, the touch display screen 305 is controlled by the processor 301 to switch from the lit screen state to the off-screen state; when the proximity sensor 316 detects that the distance between the user and the front of the electronic device 300 is gradually increasing, the touch display screen 305 is controlled by the processor 301 to switch from the off-screen state to the lit screen state.
[0224] Those skilled in the art can understand that Figure 8 the structure shown in does not constitute a limitation on the electronic device 300, and it may include more or fewer components than shown, or combine certain components, or adopt a different component arrangement.
[0225] In an exemplary embodiment, there is also provided a non-transitory computer-readable storage medium including instructions, such as the memory 304 including instructions, and the above instructions can be executed by the processor 320 of the electronic device 300 to complete the above method for processing images. The method includes: obtaining a raw image including a human face region; performing a first blurring process including at least one of horizontal blurring and vertical blurring on the raw image to obtain a first blurred image; performing mean blurring on the first blurred image to obtain a second blurred image; performing image fusion on the first blurred image and the raw image to obtain a first image to be processed; performing image fusion on the raw image, the first image to be processed, and the second blurred image to obtain a target processed image. Optionally, the above instructions can also be executed by the processor 320 of the electronic device 300 to complete other steps involved in the above exemplary embodiment. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.
[0226] In an exemplary embodiment, an application / computer program product is further provided, including one or more instructions, which can be executed by the processor 320 of the electronic device 300 to complete the above method for processing images. The method includes: obtaining an original image including a face region; performing a first blurring process including at least one of horizontal blurring and vertical blurring on the original image to obtain a first blurred image; performing mean blurring on the first blurred image to obtain a second blurred image; performing image fusion on the first blurred image and the original image to obtain a first image to be processed; performing image fusion on the original image, the first image to be processed, and the second blurred image to obtain a target processed image. Optionally, the above instructions can also be executed by the processor 320 of the electronic device 300 to complete other steps involved in the above exemplary embodiment.
[0227] Those skilled in the art will readily conceive of other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include known common knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and embodiments are only to be regarded as exemplary, and the true scope and spirit of the present application are pointed out by the following claims.
[0228] It should be understood that the present application is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.
Claims
1. A method for processing an image, characterized in that, Including: Obtain an original image containing a face region; Perform at least one first blurring process on the original image to obtain a first blurred image, where the first blurring process includes horizontal blurring and vertical blurring; Perform mean blurring on the first blurred image to obtain a second blurred image; Perform image fusion on the first blurred image and the original image to obtain a first image to be processed, where the image fusion is a process of synthesizing each image to generate one image; Perform image fusion on the original image, the first image to be processed, and the second blurred image to obtain a target processed image.
2. The method according to claim 1, characterized in that, The performing at least one first blurring process on the original image includes: For each pixel in the original image, determine a first adjacent pixel horizontally adjacent to the pixel, and change the pixel value of the pixel based on the pixel value of the first adjacent pixel; For each pixel in the original image, determine a second adjacent pixel vertically adjacent to the pixel, and change the pixel value of the pixel based on the pixel value of the second adjacent pixel; Wherein, the number of pixels of the first adjacent pixel and the second adjacent pixel is the same.
3. The method according to claim 2, characterized in that, The changing the pixel value of the pixel based on the pixel value of the first adjacent pixel includes: changing the pixel value of the pixel to the weighted mean of the pixel values of the first adjacent pixels; The changing the pixel value of the pixel based on the pixel value of the second adjacent pixel includes: changing the pixel value of the pixel to the weighted mean of the pixel values of the second adjacent pixels.
4. The method according to claim 1, characterized in that, Before performing at least one first blurring process on the face region in the original image, it further includes: Scale the original image by a first ratio.
5. The method according to claim 1, wherein The performing image fusion on the first blurred image and the original image to obtain a first image to be processed includes: Perform contrast processing on the first blurred image; Perform edge extraction on the first blurred image after contrast processing to obtain a second image to be processed; Perform at least one second blurring process on the second image to be processed to obtain a third blurred image, where the second blurring process includes horizontal blurring and vertical blurring; Perform image fusion on the first blurred image, the third blurred image, and the original image to obtain the first image to be processed.
6. The method according to claim 5, characterized in that, The performing image fusion on the first blurred image, the third blurred image, and the original image to obtain the first image to be processed includes: Perform image fusion on the first blurred image, the third blurred image, and the original image to obtain a first fused image; Determine a first image region in the first fused image where the brightness value is greater than a preset parameter, and a second image region where the brightness value is not greater than the preset parameter; Merge the first image region composed of the original image and the second image region composed of the first fused image as the first image to be processed.
7. The method according to claim 1, wherein The performing mean blurring on the first blurred image to obtain a second blurred image includes: Scale the first blurred image by a second ratio; Perform mean blurring on the scaled first blurred image to obtain the second blurred image.
8. The method according to claim 1, wherein Performing mean blurring on the first blurred image to obtain a second blurred image includes: For each pixel in the first blurred image, determining third adjacent pixels adjacent to the pixel; Changing the pixel value of the pixel to the weighted mean of the pixel values of the third adjacent pixels to obtain the second blurred image.
9. The method according to claim 1, wherein Performing image fusion on the original image, the first image to be processed, and the second blurred image to obtain a target processed image includes: Performing image fusion on the original image, the first image to be processed, and the second blurred image to obtain a second fused image; Obtaining a sharpness parameter and using the sharpness parameter to adjust the sharpness of the second fused image to obtain the target processed image.
10. The method according to claim 9, characterized in that, The obtaining of the sharpness parameter includes: Determining a sharpness parameter based on the luminance values of the pixels in the second fused image; or, Receiving a sharpness parameter set by the user.
11. The method according to claim 1, wherein After performing image fusion on the original image, the first image to be processed, and the second blurred image to obtain a target processed image, it further includes: Performing image fusion on the target processed image and the original image at a first preset ratio to obtain a third fused image and presenting it to the user; If it is determined that a modification instruction generated by the user for the third fused image is received, determining a second preset ratio based on the modification instruction, where the second preset ratio is used to represent the processed image desired by the user; Performing image fusion on the target processed image and the original image at the second preset ratio to obtain a fourth fused image; Presenting the fourth fused image to the user.
12. The method according to claim 1, characterized in that Performing at least one first blurring process on the original image to obtain a first blurred image includes: Using a preset image recognition neural network to detect feature parameters of the face region and determining user attributes reflected by the face region based on the feature parameters, where the user attributes are used to represent at least one of the gender, age, and skin color state of the person; Determining the number of times of blurring processing according to the user attributes; Performing the first blurring process on the original image for the number of times.
13. The method according to claim 1, wherein Performing at least one first blurring process on the original image to obtain a first blurred image includes: Determining the number of face regions included in the original image; When the number of face regions is at least two, selecting different numbers of first blurring processes for each face region included in the original image.
14. An apparatus for processing an image, characterized in that, It includes: An acquisition module configured to acquire an original image containing a face region; A processing module configured to perform at least one first blurring process on the original image to obtain a first blurred image, where the first blurring process includes horizontal blurring and vertical blurring; The processing module is configured to perform mean blurring on the first blurred image to obtain a second blurred image; A fusion module configured to perform image fusion on the first blurred image and the original image to obtain a first image to be processed, where the image fusion is a process of synthesizing each image to generate one image; A generation module, configured to perform image fusion on the original image, the first image to be processed, and the second blurred image to obtain a target processed image.
15. An electronic device, characterized in that, Comprising: A memory for storing executable instructions; And A processor, configured to cooperate with the memory to execute the executable instructions so as to complete the operations of the method for processing an image according to any one of claims 1-13.
16. A computer-readable storage medium for storing computer-readable instructions, characterized in that, When the instructions are executed, the operations of the method for processing an image according to any one of claims 1-13 are performed.