Image processing method, device, electronic device and storage medium
By dividing the light and dark areas of the image and adjusting the brightness, the problem of distortion in the microdermabrasion process in the existing technology is solved, and a more realistic and natural microdermabrasion effect is achieved.
Patent Information
- Application Number
- CN202011484150.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-15
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-12-15
AI Technical Summary
In the prior art, the image after microdermabrasion is prone to distortion or the microdermabrasion effect is unsatisfactory, leading to problems such as unclean microdermabrasion or excessive microdermabrasion.
By dividing the light and dark areas of the image to be processed, the brightness type of each image area is determined, and the target pixels are adjusted to match the brightness based on the brightness type to ensure that the skin resurfacing process is more controllable without losing facial texture details. sex.
The dermabrasion effect is more realistic and natural, the precision and controllability of the dermabrasion process are improved, and the image quality after dermabrasion is ensured.
Smart Images

Figure CN112581395B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and specifically relates to an image processing method, device, electronic device and storage medium. Background Art
[0002] At present, the terminal generally performs skin smoothing and beautification processing on images containing human faces by blurring the entire image to be processed, repairing defects, etc., which often leads to distortion of the image after skin smoothing, or the skin smoothing is not clean or excessive.
[0003] Application Contents
[0004] The purpose of the embodiments of the present application is to provide an image processing method, device, electronic device and storage medium, which can solve the problem of distortion or unsatisfactory skin smoothing effect on images after skin smoothing in the prior art.
[0005] In order to solve the above technical problems, this application is implemented as follows:
[0006] In a first aspect, an embodiment of the present application provides an image processing method, the method comprising:
[0007] Divide the image to be processed into image regions to obtain multiple image regions;
[0008] Determine a brightness type of each image area, wherein the brightness type of the image area includes a bright area and a dark area; wherein an average brightness value of all pixels included in the bright area is greater than an average brightness value of all pixels included in the dark area;
[0009] Based on the brightness type of each image area, a matching brightness adjustment is performed on a target pixel point in each image area, wherein the target pixel point is determined based on the brightness of all pixels included in the image area.
[0010] In a second aspect, an embodiment of the present application provides an image processing device, including:
[0011] An image region division module is used to divide the image to be processed into image regions to obtain multiple image regions;
[0012] A brightness type determination module, used to determine the brightness type of each image area, wherein the brightness type of the image area includes a bright area and a dark area; wherein the average brightness of all pixels included in the bright area is greater than the average brightness of all pixels included in the dark area;
[0013] The brightness adjustment module is used to perform matching brightness adjustment on target pixels in each image area based on the brightness type of each image area, wherein the target pixels are determined based on the brightness of all pixels included in the image area.
[0014] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.
[0015] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0016] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the steps of the method described in the first aspect.
[0017] In an embodiment of the present application, the image to be processed is divided into image regions to obtain multiple image regions; the brightness type of each image region is determined, and the brightness type includes a bright region and a dark region; wherein the average brightness of all pixels included in the bright region is greater than the average brightness of all pixels included in the dark region; based on the brightness type of each image region, the target pixel in each image region is adjusted to match the brightness, and the target pixel is determined based on the brightness of all pixels included in the image region. The embodiment of the present application divides the image to be processed into bright and dark regions to adjust the brightness in different regions respectively, thereby increasing the controllability of the skin resurfacing process without losing facial texture details, and ensuring that the skin resurfacing effect is more realistic and natural. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 is a flowchart of an image processing method provided in an embodiment of the present application;
[0019] Figure 2 is a structural schematic diagram of an image processing device provided in an embodiment of the present application;
[0020] Figure 3 One of the structural schematic diagrams of the electronic device provided in the embodiment of the present application;
[0021] Figure 4 The second structural schematic diagram of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0022] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0023] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here. In addition, the "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally represents that the objects associated with each other are in an "or" relationship.
[0024] The image processing method provided in the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.
[0025] Figure 1 is a flowchart of an image processing method provided by an embodiment of the present application, such as Figure 1 As shown, the method mainly includes but is not limited to the following steps:
[0026] Step 11: Divide the image to be processed into image regions to obtain multiple image regions.
[0027] The image to be processed may be pre-stored in the terminal, or may be obtained by real-time shooting with a camera on the terminal. The image processing method provided in the embodiment of the present application can automatically process the face image contained in the image each time the user shoots through the terminal and obtains the image to be processed; or when the user wants to perform beauty processing on the image to be processed, especially to perform skin resurfacing processing, manually click the corresponding program icon on the current interface of the terminal to process the target image based on the image processing method provided in the embodiment of the present application, and the embodiment of the present application does not specifically limit this.
[0028] Since the images captured by the terminal camera are generally color images, and the color relationship between black and white is easier to highlight the uniformity of light and dark contrast than the color relationship between color, as an optional embodiment, before processing the image to be processed based on the image processing method provided in the embodiment of the present application, the image to be processed can be first grayscaled to convert the color image to be processed into a black and white image.
[0029] Furthermore, the face image can be first identified in the image to be processed (since the object of the skin resurfacing treatment is mainly this area), and the brightness of each pixel in the face image can be determined respectively, and then the image area to be processed can be divided according to the brightness distribution of each pixel to obtain multiple different image areas.
[0030] For example, if an image that has not been subjected to skin resurfacing is used as the image to be processed (the image has been subjected to grayscale processing first), first, a face image in the image to be processed is identified; then, the brightness value of each pixel in the face image is analyzed.
[0031] Furthermore, the image regions can be divided according to the difference in the average brightness of all pixels between two adjacent image regions. Since there is a significant difference between the average brightness of all pixels in the nose wing surrounding area (set as the area where image region A is located) and the average brightness of all pixels in the cheek area (set as the area where image region B is located), it is equivalent to generating a dividing line between image region A and image region B by the brightness difference, and image region A and image region B can be divided into different regions by this dividing line.
[0032] By dividing the entire face image into regions according to the above division method for the image region A and the image region B, multiple image regions can be obtained.
[0033] Step 12: Determine the brightness type of each image area.
[0034] The brightness type of the image area includes a bright area and a dark area; wherein the average brightness value of all pixels included in the bright area is greater than the average brightness value of all pixels included in the dark area.
[0035] After dividing the image to be processed into regions in step 11, a plurality of different image regions can be obtained, and then it can be determined whether the image region belongs to a bright region or a dark region according to the brightness of all pixels in each image region.
[0036] As an option, the brightness values of all pixels in the image area A and the image area B may be determined respectively, and then the average brightness values of all pixels in the image area A and the image area B may be calculated respectively, which are recorded as a and b respectively. Since the image area A and the image area B are two adjacent areas, and a is smaller than b, it can be determined that the image area A corresponding to a is a dark area, and correspondingly, the image area B corresponding to b is a bright area.
[0037] As an option, a brightness threshold may also be set. If the average brightness of all pixels included in an image area is greater than the brightness threshold, the brightness type of the image area is determined as a bright area; if the average brightness of all pixels included in an image area is not greater than the brightness threshold, the brightness type of the image area is determined as a dark area.
[0038] Step 13: Based on the brightness type of each image area, the target pixel points in each image area are adjusted to match the brightness.
[0039] The target pixel is determined based on the brightness of all pixels in the image area.
[0040] The purpose of determining the brightness type of each image region in step 12 is to perform differentiated processing on abnormal pixels (ie, target pixels) existing in different image regions.
[0041] The method for determining the target pixel points in each image area may be to set the pixel points whose brightness is obviously different from the brightness of other pixel points as the target pixel points. Specifically, when the image area is a bright area, the pixel points whose brightness value in the image area is less than a preset brightness value may be set as the target pixel points; when the image area is a dark area, the pixel points whose brightness value in the image area is greater than a preset brightness value may be set as the target pixel points.
[0042] Taking the image area B divided in the above embodiment as an example, in step 12, it has been determined that it is a bright image area. Since there are some defect points (such as acne marks) in the image area B, the brightness value of several pixels constituting this defect point is significantly lower than the brightness value of each pixel point in the surrounding area. Since one of the purposes of the skin resurfacing process is to reduce the defects, in the embodiment of the present application, the brightness values of the pixels corresponding to these defect points are increased to make them similar to the brightness values of the surrounding pixels, so as to achieve the purpose of reducing the acne marks.
[0043] Taking the image area A divided in the above embodiment as an example, in step 12, it has been determined that it is a dark image area. Since there are some defects (such as acne) in the image area A, the brightness values of several pixels constituting the acne are significantly greater than the brightness values of the pixels in the surrounding area. Since one of the purposes of the dermabrasion treatment is to reduce the acne, in the embodiment of the present application, the brightness values of the pixels corresponding to the acne are reduced to make them similar to the brightness values of the surrounding pixels, so as to achieve the purpose of reducing the acne.
[0044] The image processing method provided in the embodiment of the present application divides the image to be processed into light and dark areas to adjust the brightness in different areas respectively, especially for the processing of light and dark mixed pixels in the image area. It can increase the controllability of the skin refining process without losing the facial texture details, thereby ensuring that the skin refining effect is more realistic and natural.
[0045] Based on the content of the above embodiment, as an optional embodiment, the image region division of the image to be processed in step 11 to obtain multiple image regions may include but is not limited to:
[0046] Step 111: Obtain the brightness value of each pixel in the image to be processed;
[0047] Step 112: traverse all pixel points in the image to be processed, and when the brightness difference between two adjacent pixel points is greater than a first brightness difference threshold, divide the two adjacent pixel points into different areas;
[0048] Step 113: All pixels in the same area are grouped into an image area.
[0049] Among them, the calculation method for obtaining the brightness value of each pixel in the image to be processed described in step 111 can be executed using a corresponding program inside the terminal, and its calculation principle can be to first calculate the RGB component of each pixel, and then calculate the brightness value of the pixel based on the RGB component of the pixel. This application does not make any specific limitations on this.
[0050] The traversal of all pixels in the image to be processed in step 112, when the brightness difference between two adjacent pixels is greater than the first brightness difference threshold, divides the two adjacent pixels into different areas, specifically:
[0051] When processing the image to be processed, in the process of traversing all the pixels in the image to be processed, when traversing to two pixels adjacent to the boundary line between image area A and image area B, there will be a significant increase in the brightness difference between the brightness value of the pixel in image area A and the corresponding pixel in image area B. In the embodiment of the present application, a brightness difference threshold (referred to as the first brightness difference threshold in the embodiment of the present application) can be preset. When the brightness difference between two adjacent pixels is greater than the first brightness difference threshold, the two pixels are divided into different areas. All the pixels in the image to be processed are traversed in sequence, that is, the brightness difference between any pixel and its adjacent pixels is calculated, and the obtained brightness difference is compared with the first brightness difference threshold to determine whether the two adjacent pixels are divided into two different areas.
[0052] After processing in step 112, the division relationship between the pixels and the different division areas formed by the pixels can be obtained. Therefore, in step 113, all the pixels in the same area are combined to form a plurality of different image areas.
[0053] Optionally, the first brightness difference threshold can be set by the user according to actual needs. For example, when the user needs to perform beauty processing on the image to be processed, the corresponding image processing interface is called up by triggering the corresponding icon; then, the parameter setting icon in the image processing interface is clicked to enter the parameter setting interface; after clicking the brightness difference threshold setting function button in the parameter setting interface, the corresponding parameter value is entered to complete the setting of the first brightness difference threshold. Optionally, the first brightness difference threshold can also be configured by the terminal system, which is not specifically limited in the embodiments of the present application.
[0054] When the first brightness difference threshold is set according to the user's usage requirements, if you want a weaker skin smoothing effect, you can increase the first brightness difference threshold accordingly; conversely, if you want a stronger skin smoothing effect, you can lower the first brightness difference threshold accordingly.
[0055] The image processing method provided in the embodiment of the present application divides the image area by pixel traversal comparison combined with a preset brightness difference threshold, which provides a basis for the subsequent adjustment of pixel brightness in different image areas, effectively improves the accuracy of the skin refining process, and makes the image effect after skin refining more realistic and natural.
[0056] Based on the content of the above embodiment, as an optional embodiment, the determination of the brightness type of each image area in step 12 mainly includes but is not limited to:
[0057] Step 121: Obtain the average brightness of all pixels in each image area;
[0058] Step 122: when it is determined that the average brightness of all pixels in an image area is greater than the average brightness of all pixels in the image to be processed, the image area is determined to be a bright area;
[0059] Step 123: when it is determined that the average brightness value of all pixels in an image area is not greater than the average brightness value of all pixels in the image to be processed, the image area is determined to be a dark area.
[0060] After obtaining the brightness values of all pixels in each image area, the embodiment of the present application calculates the average brightness of all pixels, and uses the average brightness as a benchmark to compare the average brightness of each pixel in each image area with the average brightness of all pixels in the entire image to be processed, and divides the light and dark areas according to the comparison results.
[0061] Specifically, when the average brightness of all pixels in the image area is greater than the average brightness of all pixels in the image to be processed, the brightness type of the image area can be set to a bright area; when the average brightness of all pixels in the image area is not greater than the average brightness of all pixels in the image to be processed, the brightness type of the image area can be set to a dark area.
[0062] Optionally, the average brightness of all pixels in the image area can be compared with a preset brightness threshold according to the user's personal preference to achieve the division of light and dark areas. For example, the preset brightness threshold can be set slightly larger than the average brightness of all pixels in the image to be processed, so that the divided bright area will be relatively reduced, and the result of the subsequent adjustment of the image area brightness will focus on the adjustment of defects in the dark area. Correspondingly, the preset brightness threshold can be set slightly smaller than the average brightness of all pixels in the image to be processed, so that the divided dark area will be relatively reduced, and the result of the subsequent adjustment of the image area brightness will focus on the adjustment of defects in the bright area.
[0063] The image processing method provided in the embodiment of the present application divides each image area into light and dark according to the brightness average value of all pixels in each image area, providing a basis for later differentiated brightness adjustment according to different brightness types of different image areas, and can effectively improve the accuracy of skin resurfacing and optimize the effect of skin resurfacing.
[0064] Based on the content of the above embodiment, as an optional embodiment, the target pixel point described in step 13 is determined based on the brightness of all pixels included in the image area, which can be specifically:
[0065] When it is determined that the brightness type of the image area is a dark area, a pixel point in the image area whose brightness value is greater than the average brightness value of all the pixels included in the image area is determined as the first target pixel point; when it is determined that the brightness type of the image area is a bright area, a pixel point in the image area whose brightness value is less than the average brightness value of all the pixels included in the image area is determined as the second target pixel point.
[0066] Specifically, an embodiment of the present application provides a method for determining target pixels in each image area.
[0067] First, the brightness type of each image area is obtained. When the brightness type of the image area is a dark area, the pixel point in the image area whose brightness value is greater than the average brightness value of all the pixel points included in the image area is taken as the target pixel point, referred to as the first target pixel point for short. When the brightness type of the image area is a bright area, the pixel point in the image area whose brightness value is less than the average brightness value of all the pixel points included in the image area is taken as the target pixel point, which is collectively referred to as the second target pixel point in the embodiments of the present application.
[0068] Assuming that there is a pimple in the image area A (assuming it is only one pixel), its brightness value is significantly greater than the average brightness of all pixels in the entire image area A, so it is set as a first target pixel. If the pimple is composed of multiple pixels, all of the multiple pixels are set as the first target pixel.
[0069] Correspondingly, assuming that there is an acne mark in the image area B (assuming it is only one pixel), its brightness value is significantly lower than the average brightness of all pixels in the entire image area B, so it is set as a second target pixel. If the acne mark is composed of multiple pixels, then all of the above multiple pixels are set as the second target pixel.
[0070] The image processing method provided in the embodiment of the present application formulates different target pixel determination rules according to the brightness types of different image areas, so as to determine the mixed light and dark pixels in each image area as target pixels and perform corresponding brightness adjustments, thereby effectively improving the effect of the skin smoothing processing and making the image after the skin smoothing processing more realistic.
[0071] Based on the content of the above embodiment, as an optional embodiment, the matching brightness adjustment of the target pixel points in each image area in step 13 includes:
[0072] The brightness value of the first target pixel and the second target pixel are both set to the average brightness value of all pixels of the image to be processed.
[0073] The embodiment of the present application provides a method for adjusting the brightness of a determined target pixel point, that is, adjusting the brightness of all target pixel points to the average brightness of all pixel points of the image to be processed, so as to dilute the target pixel points.
[0074] As an option, the user may set a preset brightness value according to personal preference, or the system may recommend a preset brightness value according to the actual style of the image to be processed, and adjust the brightness of the target pixel points to the preset brightness value. The embodiments of the present application do not make any specific limitations on this.
[0075] Furthermore, the matching brightness adjustment of the target pixel points in each image area may also be:
[0076] Obtaining an average brightness value of all pixels within a first preset area centered on the first target pixel;
[0077] Lowering the brightness value of the first target pixel to an average brightness value of all pixels in the first preset area;
[0078] Obtaining an average brightness value of all pixels within a second preset area centered on the second target pixel;
[0079] The brightness value of the second target pixel is adjusted up to the average brightness value of all pixels in the second preset area.
[0080] The embodiment of the present application provides another method for adjusting the brightness of each target pixel point. Specifically, different processing is performed according to the brightness type of the image area where each target pixel point is located.
[0081] When the brightness type of the image area is a dark area, the first target pixel point (bright spot) therein needs to be dimmed. The adjustment standard may be: firstly calculate the average brightness value of all pixels in the first preset area where each first target pixel point is located, and the average brightness value is obviously smaller than the brightness of the first target pixel point; then, reduce the brightness value of the first target pixel point to the average brightness value to achieve the purpose of diluting the first target pixel point.
[0082] The first preset area can be determined by taking the first target pixel as the center and drawing a circle with a preset radius (such as 5 pixels) to determine the area. The first preset area can be determined manually or by system settings according to the needs of image processing.
[0083] Accordingly, when the brightness type of the image area is a bright area, the second target pixel point (dark point) therein needs to be dimmed. The adjustment standard can be: first calculate the average brightness value of all pixels in the second preset area where each second target pixel point is located, and the average brightness value is significantly greater than the brightness of the second target pixel point; then, increase the brightness value of the second target pixel point to the average brightness value to achieve the purpose of dimming the second target pixel point.
[0084] The second preset area can be determined by taking the second target pixel as the center and drawing a circle with a preset radius (such as 5 pixels) to determine the area. The second preset area can also be determined manually or by system settings according to the needs of image processing.
[0085] The embodiment of the present application provides a method for performing different brightness adjustments according to the brightness type of the image area where the target pixel is located, further improving the processing effect on target pixels with mixed light and dark, ensuring that the processed image is not distorted and the brightness of each area after optimization is more uniform.
[0086] Based on the content of the above embodiment, as an optional embodiment, after the target pixel points in each image area are adjusted to match the brightness in step 13, the following may also be included:
[0087] The brightness of the image to be processed is adjusted again after the brightness adjustment according to a second brightness difference threshold, where the second brightness difference threshold is greater than the first brightness difference threshold.
[0088] Since the brightness difference threshold is mainly used to realize image area division, and setting different brightness difference thresholds will result in different divided areas. Generally speaking, the smaller the brightness difference threshold is, the stronger the effect of image smoothing processing will be; the larger the brightness difference threshold is, the weaker the effect of image smoothing processing will be.
[0089] In the embodiment of the present application, a smaller first brightness difference threshold (such as 5) is first set, so that more image areas can be divided, thereby enhancing the effect of skin grinding and achieving the removal of small-scale unevenness, including the inclusion of light and dark areas (including spots, blemishes, acne marks, acne, etc.). After that, a larger second brightness difference threshold (such as 10) is set to divide a small number of image areas, and then the image processing method provided based on the present application is implemented, and the brightness of the image to be processed is adjusted again to optimize the light and shadow relationship of the whole face, thereby achieving the overall effect of skin grinding, and effectively overcoming the defect of unrealistic pictures caused by skin grinding in the prior art.
[0090] Based on the content of the above embodiment, as an optional embodiment, before dividing the image to be processed into image regions, it also includes: deleting the facial features region in the image to be processed.
[0091] Among them, the facial features area includes the eye area, two ear areas, nose area and mouth area. Since the main object of the skin resurfacing process is the image of the skin color area of the face, the image of the facial features area often does not need to be resurfaced. For example, if the eye area is used as the area for skin resurfacing, the processed image may be distorted. Therefore, in the image processing method provided in the embodiment of the present application, before performing image processing, the image to be processed is preprocessed, which mainly includes identifying and deleting irrelevant areas.
[0092] The image processing method provided in the embodiment of the present application can effectively improve the effect and realism of image optimization by deleting the facial features area and then acquiring the image area.
[0093] It should be noted that the image processing method provided in the embodiment of the present application can be executed by an image processing device, or by a control module in the image processing device for executing the method for loading image processing. In the embodiment of the present application, the image processing method provided in the embodiment of the present application is described by taking the method for loading image processing executed by an image processing device as an example.
[0094] Skin smoothing is one of the most basic beauty functions in the built-in cameras and beauty photo apps of current terminals (such as mobile phones). Skin smoothing is widely applicable. Men, women, young and old all need skin smoothing when taking selfies or photos taken by others. The effect of skin smoothing in terminals is not very ideal at present, and many people still choose to manually retouch the photos later. However, when implementing skin smoothing in terminals, most of them directly use methods such as blurring and repairing defects on the image to be processed, which makes the images after skin smoothing easy to appear fake, dirty, unclean, and over-smoothed.
[0095] In view of this, an embodiment of the present invention provides an image processing device, such as Figure 2 , which is a schematic diagram of the structure of the image processing device provided by the present application, the device mainly includes an image area division module 201, a brightness type determination module 202 and a brightness adjustment module 203, wherein:
[0096] The image region division module 201 is mainly used to divide the image to be processed into image regions to obtain multiple image regions;
[0097] The brightness type determination module 202 is mainly used to determine the brightness type of each image area, and the brightness type includes a bright area and a dark area; wherein the average brightness of all pixels included in the bright area is greater than the average brightness of all pixels included in the dark area;
[0098] The brightness adjustment module 203 is mainly used to perform matching brightness adjustment on target pixels in each image area based on the brightness type of each image area, and the target pixels are determined based on the brightness of all pixels included in the image area.
[0099] As an optional embodiment, after the terminal takes a photo to obtain the image to be processed, after the image to be processed is generated into a JPEG format, the face image can be recognized first, and then the image to be processed is changed to an observed state, that is, black and white, because the color relationship of black and white is more likely to highlight the uniformity of light and dark contrast. Furthermore, the image to be processed is subjected to face light and shadow detection by the image area division module 201 to identify the face image and determine the brightness value of all pixels in the face image. Then, the areas of the bright and dark regions are calculated respectively, and then the light and dark regions of the face image are divided by a preset brightness threshold. Among them, the preset brightness threshold can be the brightness average of all pixels of the image to be processed, or it can be a brightness threshold preset by humans or the system.
[0100] The image processing method provided in the embodiment of the present application divides the image to be processed into light and dark areas to adjust the brightness in different areas respectively. This increases the controllability of the skin refining process without losing facial texture details, thereby ensuring that the skin refining effect is more realistic and natural.
[0101] Furthermore, the brightness type determination module 202 is used to determine whether the divided image area belongs to a bright area or a dark area. Specifically, the brightness of all pixels in each image area can be used to determine whether the image area belongs to a bright area or a dark area.
[0102] Furthermore, the brightness adjustment module 203 is used to adjust the brightness of the target pixels within each image area according to the type of each image area determined by the brightness type determination module 202, so that the brightness of each target pixel is similar to that of the pixels in a certain area around it, so as to dilute the target pixel.
[0103] Furthermore, the image area division module 201 is specifically used to: obtain the brightness value of each pixel in the image to be processed; traverse all pixel points in the image to be processed, and when the brightness difference between two adjacent pixel points is greater than a first brightness difference threshold, divide the two adjacent pixel points into different areas; and group all pixel points located in the same area into an image area.
[0104] Furthermore, the brightness type determination module 202 is specifically used to: obtain the brightness average value of all pixels in each image area; when it is determined that the brightness average value of all pixels in an image area is greater than the brightness average value of all pixels in the image to be processed, determine that the image area is a bright area; when it is determined that the brightness average value of all pixels in an image area is not greater than the brightness average value of all pixels in the image to be processed, determine that the image area is a dark area.
[0105] Furthermore, the brightness adjustment module 203 is also used to determine the target pixel point, specifically for: when it is determined that the brightness type of the image area is a dark area, determining the pixel point in the image area whose brightness value is greater than the brightness average of all the pixel points included in the image area is the first target pixel point; when it is determined that the brightness type of the image area is a bright area, determining the pixel point in the image area whose brightness value is less than the brightness average of all the pixel points included in the image area is the second target pixel point.
[0106] Furthermore, the brightness adjustment module 203 may be specifically configured to: set the brightness value of the first pixel and the second target pixel to the average brightness value of all pixels of the image to be processed.
[0107] Furthermore, the brightness adjustment module 203 is also specifically used to: obtain the average brightness of all pixels in a first preset area centered on the first pixel; reduce the brightness value of the first pixel to the average brightness of all pixels in the first preset area; obtain the average brightness of all pixels in a second preset area centered on the second pixel; and increase the brightness value of the second pixel to the average brightness of all pixels in the second preset area.
[0108] Furthermore, the image area division module 201 is also used to divide the image area again on the image to be processed after the brightness adjustment is completed according to a second brightness difference threshold, and use the brightness type determination module and the brightness adjustment module to perform brightness adjustment on the image to be processed after the brightness adjustment is completed; the second brightness difference threshold is greater than the first brightness difference threshold.
[0109] Furthermore, the image processing device provided in the embodiment of the present application also includes an image preprocessing module; the image preprocessing module is used to delete the facial features area in the image to be processed before dividing the image to be processed into image areas.
[0110] Furthermore, within the debugged image area, the brightness of the area surrounding the target pixel may be feathered to make the transition more uniform, thereby obtaining a smoothed image without damaging skin details.
[0111] The image processing device in the embodiment of the present application can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. The non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0112] The image processing device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0113] The image processing device provided in the embodiment of the present application can achieve Figure 1 To avoid repetition, the various processes implemented by the image processing device in the method embodiment will not be described here.
[0114] The image processing device provided in the embodiment of the present application can, on the one hand, efficiently optimize or solve the blurring effect of unclear images, improve the imaging quality, and solve the technical demand of users that photos are easily unclear; on the other hand, it does not require a large number of machines to perform manual learning processes, and is relatively simple to implement and convenient for users to operate; moreover, the image processing device provided in the embodiment of the present application does not increase hardware costs, and is processed on the software side, which is relatively easy to promote on a large scale.
[0115] Optionally, the embodiment of the present application further provides an electronic device 300, such as Figure 3 As shown, it includes a processor 302, a memory 301, and a program or instruction stored in the memory 301 and executable on the processor 302. When the program or instruction is executed by the processor 302, each process of the above-mentioned image processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0116] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0117] Figure 4A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0118] The electronic device 400 includes but is not limited to components such as a radio frequency unit 401 , a network module 402 , an audio output unit 403 , an input unit 404 , a sensor 405 , a display unit 406 , a user input unit 407 , an interface unit 408 , a memory 409 , and a processor 410 .
[0119] Those skilled in the art will appreciate that the electronic device 400 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 410 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 4 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0120] It should be understood that in the embodiment of the present application, the input unit 404 may include a graphics processor (GPU) 441 and a microphone 442, and the graphics processor 441 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 406 may include a display panel 461, and the display panel 461 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 407 includes a touch panel 471 and other input devices 472. The touch panel 471 is also called a touch screen. The touch panel 471 may include two parts: a touch detection device and a touch controller. Other input devices 472 may include, but are not limited to, a physical keyboard, a function key (such as a volume control button, a switch button, etc.), a trackball, a mouse, and a joystick, which will not be repeated here. The memory 809 may be used to store software programs and various data, including but not limited to applications and operating systems. The processor 410 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and applications, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 410.
[0121] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned image processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0122] The processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0123] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned image processing method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0124] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0125] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0126] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0127] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. An image processing method, characterized in that: include: Divide the image to be processed into image regions to obtain multiple image regions; Determine a brightness type of each image area, wherein the brightness type of the image area includes a bright area and a dark area; wherein an average brightness value of all pixels included in the bright area is greater than an average brightness value of all pixels included in the dark area; Based on the brightness type of each image area, matching brightness adjustment is performed on target pixels in each image area, where the target pixels are determined based on the brightness of all pixels included in the image area; The method of adjusting the brightness of target pixels in each image area to match each other based on the brightness type of each image area, wherein the target pixel is determined based on the brightness of all pixels included in the image area, specifically includes: when it is determined that the brightness type of the image area is a dark area, determining a pixel in the image area whose brightness value is greater than the average brightness value of all pixels included in the image area as a first target pixel; In the case where it is determined that the brightness type of the image area is a bright area, a pixel point in the image area having a brightness value less than an average brightness value of all the pixels included in the image area is determined as a second target pixel point; Wherein, the brightness value of the first target pixel point and the brightness value of the second target pixel point are both set to the average brightness value of all pixels of the image to be processed; or, Obtaining an average brightness value of all pixels within a first preset area centered on the first target pixel, and reducing the brightness value of the first target pixel to an average brightness value of all pixels within the first preset area; The brightness average value of all pixels in a second preset area centered on the second target pixel is obtained, and the brightness value of the second target pixel is increased to the brightness average value of all pixels in the second preset area.
2. The image processing method according to claim 1, characterized in that: The image to be processed is divided into image regions to obtain multiple image regions, including: Obtaining the brightness value of each pixel in the image to be processed; Traversing all pixel points in the image to be processed, and dividing the two adjacent pixel points into different areas when the brightness difference between two adjacent pixel points is greater than a first brightness difference threshold; All pixels in the same area are grouped into an image area.
3. The image processing method according to claim 1 or 2, characterized in that: Determining the brightness type of each image area includes: Get the average brightness of all pixels in each image area; When it is determined that the average brightness of all pixels in an image area is greater than the average brightness of all pixels in the image to be processed, the image area is determined to be a bright area; When it is determined that the average brightness value of all pixels in an image area is not greater than the average brightness value of all pixels in the image to be processed, the image area is determined to be a dark area.
4. The image processing method according to claim 2, characterized in that: After adjusting the brightness of the target pixels in each image area to match the brightness type of each image area, the method further includes: The brightness of the image to be processed is adjusted again after the brightness adjustment according to a second brightness difference threshold, where the second brightness difference threshold is greater than the first brightness difference threshold.
5. The image processing method according to claim 1, characterized in that: Before dividing the image to be processed into image regions, the method further includes: deleting the facial features region in the image to be processed.
6. An image processing device, characterized in that: include: An image region division module is used to divide the image to be processed into image regions to obtain multiple image regions; A brightness type determination module, used to determine the brightness type of each image area, wherein the brightness type of the image area includes a bright area and a dark area; wherein the average brightness of all pixels included in the bright area is greater than the average brightness of all pixels included in the dark area; a brightness adjustment module, for determining, when determining that the brightness type of the image area is a dark area, a pixel point in the image area having a brightness value greater than an average brightness value of all pixels included in the image area as a first target pixel point; In the case where it is determined that the brightness type of the image area is a bright area, a pixel point in the image area having a brightness value less than an average brightness value of all the pixels included in the image area is determined as a second target pixel point; Wherein, the brightness value of the first target pixel point and the brightness value of the second target pixel point are both set to the average brightness value of all pixels of the image to be processed; or, Obtaining an average brightness value of all pixels within a first preset area centered on the first target pixel, and reducing the brightness value of the first target pixel to an average brightness value of all pixels within the first preset area; The brightness average value of all pixels in a second preset area centered on the second target pixel is obtained, and the brightness value of the second target pixel is increased to the brightness average value of all pixels in the second preset area.
7. An electronic device, characterized in that: The method comprises a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the image processing method according to any one of claims 1 to 5.
