Image Processing Method and Apparatus, Computer-Readable Medium, and Electronic Device
Through the brightness mapping technology based on preset brightness and segmentation functions, the problem of insufficient dynamic range and low contrast of the image is solved, and the dynamic range and contrast of the image is effectively adjusted, avoiding image details loss and distortion.
Patent Information
- Application Number
- CN202080105205.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-29
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2040-10-29
AI Technical Summary
The prior art is difficult to effectively adjust the dynamic range and contrast of images, resulting in insufficient dynamic range and low contrast in images in different scenarios, which in turn leads to problems such as overexposure and insufficient exposure, resulting in loss and distortion of image details.
By obtaining the original brightness data of the image to be processed, a segment mapping function is established based on the preset brightness and the preset segment function, the original brightness data is mapped to obtain the target brightness data. The method includes a brightness adjustment module, a brightness detection module and an image output module, and adjusts the parameters through cycles until the detection result satisfies the preset conditions.
Adjustments to insufficient dynamic range and low contrast of the image are achieved, avoiding problems such as overexposure and insufficient exposure, ensuring that the image details are complete and there is less distortion.
Smart Images

Figure CN116113976B_ABST
Abstract
Description
Background Art
[0002] In the era of rapid development of computers, relying on electronic devices such as mobile phones and digital cameras to record life has become an indispensable part of human life. Due to the variety of photographic environments in daily life, which are usually quite different from professional environments, the images captured in different scenarios are often affected by the acquisition environment, resulting in insufficient dynamic range, low contrast, etc. For example, when taking a portrait, the face area is often too dark and other areas are brighter. In such cases, image processing is often required to obtain an image with an appropriate dynamic range and contrast. Summary of the Invention
[0003] The purpose of the present disclosure is to provide an image processing method, an image processing device, a computer-readable medium, and an electronic device, so as to at least to a certain extent achieve the adjustment of insufficient image dynamic range and low contrast, and avoid problems such as loss of image details and image distortion caused by overexposure and underexposure in related technologies.
[0004] According to a first aspect of the present disclosure, there is provided an image processing method, including: obtaining the original brightness data of the image to be processed, and performing a brightness adjustment process on the original brightness data based on an adjustment parameter to obtain target brightness data; the adjustment parameter includes a preset brightness corresponding to the image to be processed; generating an intermediate image according to the image to be processed and the target brightness data, and performing brightness detection on the intermediate image; when the detection result of the brightness detection meets a preset condition, outputting the intermediate image as the target image; when the detection result does not meet the preset condition, correcting the adjustment parameter based on the detection result, and performing a brightness adjustment process on the original brightness data according to the corrected adjustment parameter until the detection result meets the preset condition;
[0005] Wherein, the brightness adjustment process includes: adjusting the coefficients of the linear function segment and the non-linear function segment in the preset piecewise function based on the preset brightness to determine a piecewise mapping function; mapping the original brightness data according to the piecewise mapping function to obtain target brightness data.
[0006] According to a second aspect of the present disclosure, there is provided an image processing device, including:
[0007] A brightness adjustment module, configured to obtain the original brightness data of the image to be processed, and perform a brightness adjustment process on the original brightness data based on an adjustment parameter to obtain target brightness data; the adjustment parameter includes a preset brightness corresponding to the image to be processed;
[0008] A brightness detection module, configured to generate an intermediate image according to the image to be processed and the target brightness data, and perform brightness detection on the intermediate image;
[0009] An image output module, configured to output the intermediate image as the target image when the detection result of the brightness detection meets the preset condition; and when the detection result does not meet the preset condition, correct the adjustment parameter based on the detection result, and control the brightness adjustment module to perform a brightness adjustment process on the original brightness data according to the corrected adjustment parameter until the detection result meets the preset condition;
[0010] Wherein, the brightness adjustment process includes:
[0011] Adjusting the coefficients of the linear function segment and the non - linear function segment in the preset piece - wise function based on the preset brightness to determine the piece - wise mapping function;
[0012] Mapping the original brightness data according to the piece - wise mapping function to obtain the target brightness data.
[0013] According to the third aspect of the present disclosure, there is provided a computer - readable medium having a computer program stored thereon, and when the computer program is executed by a processor, the above - mentioned method is implemented.
[0014] According to the fourth aspect of the present disclosure, there is provided an electronic device, characterized by comprising:
[0015] A processor; and
[0016] A memory for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the above - mentioned method.
[0017] An image processing method provided by an embodiment of the present disclosure obtains the original data of the image to be processed, and then maps the original brightness data based on the adjustment parameter to obtain the target brightness data. On the one hand, since the above - mentioned mapping process is based on the piece - wise mapping function established based on the preset brightness and the preset piece - wise function, different mappings can be performed for different ranges of the original brightness data. On the basis of realizing the adjustment of the dynamic range and contrast of the image to be processed, problems such as loss of image details caused by over - exposure, under - exposure, etc. can be avoided; on the other hand, since the above - mentioned mapping process processes the whole image to be processed and does not require the recognition of regions in the image to be processed, problems such as excessive unnaturalness and distortion of the image caused by inaccurate recognition can be avoided.
[0018] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. Description of the Drawings
[0019] The accompanying drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure. Obviously, the drawings in the following description are only some embodiments of the present disclosure, and those of ordinary skill in the art can obtain other drawings based on these drawings without creative efforts. In the drawings:
[0020] Figure 1 A schematic diagram showing an exemplary system architecture to which the embodiments of the present disclosure can be applied;
[0021] Figure 2 A schematic diagram showing an electronic device to which the embodiments of the present disclosure can be applied;
[0022] Figure 3 Showing an exemplary portrait image;
[0023] Figure 4 Showing another exemplary portrait image;
[0024] Figure 5 Showing yet another exemplary portrait image;
[0025] Figure 6 Schematically showing a flowchart of an image processing method in an exemplary embodiment of the present disclosure;
[0026] Figure 7 Schematically showing a function image of a preset piecewise function in an exemplary embodiment of the present disclosure;
[0027] Figure 8 Schematically showing a flowchart of another image processing method in an exemplary embodiment of the present disclosure;
[0028] Figure 9 Schematically showing an image histogram corresponding to a target image in an exemplary embodiment of the present disclosure;
[0029] Figure 10 Schematically showing an image histogram corresponding to an image to be processed in an exemplary embodiment of the present disclosure;
[0030] Figure 11 Schematically showing a schematic diagram of filtering out peaks in an image histogram in an exemplary embodiment of the present disclosure;
[0031] Figure 12 Showing yet another exemplary portrait image;
[0032] Figure 13 Schematically showing a schematic diagram of the composition of an image processing apparatus in an exemplary embodiment of the present disclosure. Detailed implementation manners
[0033] Example embodiments will now be described more fully with reference to the accompanying drawings. However, the example embodiments can be implemented in various forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art. The features, structures, or characteristics described may be combined in any suitable manner in one or more embodiments.
[0034] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus repeated descriptions thereof will be omitted. Some of the block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0035] Figure 1 A schematic diagram of a system architecture of an exemplary application environment in which an image processing method and apparatus according to an embodiment of the present disclosure can be applied is shown.
[0036] As Figure 1 shown, the system architecture 100 may include one or more of the terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing a communication link 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. The terminal devices 101, 102, 103 may be various electronic devices having image processing capabilities, including but not limited to desktop computers, portable computers, smart phones, and tablet computers, etc. It should be understood that Figure 1 the number of terminal devices, networks, and servers in
[0037] The image processing method provided by the embodiments of the present disclosure is generally executed by the terminal devices 101, 102, and 103. Correspondingly, the image processing apparatus is generally disposed in the terminal devices 101, 102, and 103. However, those skilled in the art can easily understand that the image processing method provided by the embodiments of the present disclosure can also be executed by the server 105. Correspondingly, the image processing apparatus can also be disposed in the server 105. No special limitation is made in this exemplary embodiment. For example, in an exemplary embodiment, the user can collect the image to be processed through the cameras included in the terminal devices 101, 102, and 103, and then send the image to be processed to the server 105. After the server obtains the output target image through the image processing method provided by the embodiments of the present disclosure, the target image is returned to the terminal devices 101, 102, and 103, etc.
[0038] An exemplary embodiment of the present disclosure provides an electronic device for implementing an image processing method, which may be Figure 1 the terminal devices 101, 102, 103 or the server 105 among them. The electronic device at least includes a processor and a memory. The memory is used to store the executable instructions of the processor, and the processor is configured to execute the image processing method by executing the executable instructions.
[0039] Next, taking Figure 2 the mobile terminal 200 among them as an example, the structure of the electronic device will be described exemplarily. Those skilled in the art should understand that, except for the components specifically for mobile purposes, Figure 2 the structure among them can also be applied to fixed-type devices. In some other embodiments, the mobile terminal 200 may include more or fewer components than shown, or combine certain components, or split certain components, or have different component arrangements. The components shown can be implemented in hardware, software, or a combination of software and hardware. The interface connection relationships between the components are only shown schematically and do not constitute a limitation on the structure of the mobile terminal 200. In some other embodiments, the mobile terminal 200 may also adopt an interface connection method different from Figure 2 that shown, or a combination of multiple interface connection methods.
[0040] Such as Figure 2As shown, the mobile terminal 200 may specifically include: a processor 210, an internal memory 221, an external memory interface 222, a Universal Serial Bus (USB) interface 230, a charging management module 240, a power management module 241, a battery 242, an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 271, a receiver 272, a microphone 273, a headphone interface 274, a sensor module 280, a display screen 290, a camera module 291, an indicator 292, a motor 293, a button 294, and a subscriber identification module (SIM) card interface 295, etc. The sensor module 280 may include a depth sensor 2801, a pressure sensor 2802, a gyroscope sensor 2803, etc.
[0041] The processor 210 may include one or more processing units. For example, the processor 210 may include an Application Processor (AP), a modem processor, a Graphics Processing Unit (GPU), an Image Signal Processor (ISP), a controller, a video codec, a Digital Signal Processor (DSP), a baseband processor, and / or a Neural-Network Processing Unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.
[0042] The NPU is a Neural-Network (NN) computing processor. By referring to the biological neural network structure, such as referring to the transmission mode between human brain neurons, it can quickly process the input information and can also continuously self-learn. In some embodiments, the NPU can be used to train a parameter adjustment model, and then correct the adjustment parameters in the brightness adjustment process based on the trained parameter adjustment model.
[0043] A memory is provided in the processor 210. The memory can store instructions for implementing six modular functions: detection instructions, connection instructions, information management instructions, analysis instructions, data transmission instructions, and notification instructions, and is controlled by the processor 210 to execute.
[0044] The wireless communication function of the mobile terminal 200 can be implemented by antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modulation and demodulation processor, baseband processor, etc. In some embodiments, the mobile terminal 200 can receive the to-be-processed image sent by other terminals through the wireless communication function, and return the target image after processing.
[0045] The mobile terminal 200 can implement the shooting function through ISP, camera module 291, video codec, GPU, display screen 290, application processor, etc. Among them, the ISP is used to process the data fed back by the camera module 291; the camera module 291 is used to capture static images or videos; the digital signal processor is used to process digital signals, and in addition to processing digital image signals, it can also process other digital signals; the video codec is used to compress or decompress digital videos, and the mobile terminal 200 can also support one or more video codecs. In some embodiments, the ISP and the processor 210 can be directly combined to execute the image processing method of the present disclosure on the to-be-processed image collected by the camera module 291, and directly display the target image on the display screen 290 after obtaining it.
[0046] In addition, other devices providing auxiliary functions may also be included in the mobile terminal 200. For example, the key 294 includes a power-on key, volume keys, etc., and the user can generate key signal inputs related to the user settings, function control, and image processing of the mobile terminal 200 through key inputs. Another example is the indicator 292, the motor 293, the SIM card interface 295, etc.
[0047] In the related art, in order to obtain an image with an appropriate dynamic range and suitable contrast, the following two methods are often used to process images with insufficient dynamic range and low contrast: one is to directly adjust the exposure of the image and uniformly adjust the whole image; the other is to detect the over-dark or over-bright areas and adjust the local exposure of the over-dark or over-bright areas to brighten or darken the over-dark or over-bright areas.
[0048] Among them, using the first method is very likely to cause overexposure in the originally brighter areas and lose image details. For example, for the portrait image with a dark face area as shown in Figure 3 , after processing the above first method, the image as shown in Figure 4 can be obtained. In Figure 4 , although the face area is significantly brightened, the originally brighter areas around it are significantly overexposed, and at the same time, the image details in this area are also lost (such as the circled part in Figure 4 ).
[0049] However, using the second method may result in unnatural or even distorted transitions. For example, still aiming at Figure 3Process the portrait image with a too-dark face area. After processing using the second method described above, an image as shown in Figure 5 can be obtained. In Figure 5 , the brightening of the face area is more obvious. However, due to inaccurate skin color recognition, some skin color areas are not brightened (such as the circled part in Figure 5 ), resulting in facial distortion and unnatural transitions between skin colors.
[0050] Next, the image processing method and image processing apparatus of the exemplary embodiments of the present disclosure will be specifically described.
[0051] Figure 6 FIG. shows the flow of an image processing method in this exemplary embodiment, including the following steps S610 to S640:
[0052] In step S610, obtain the original brightness data of the image to be processed, and perform a brightness adjustment process on the original brightness data based on the adjustment parameters to obtain the target brightness data.
[0053] In an exemplary embodiment, the image to be processed may include a portrait, a landscape image, etc. After obtaining the image to be processed, since the color data corresponding to some images to be processed is represented in a non-linear color space of a display device such as a monitor, for ease of processing, the image to be processed can be first converted into a first linear color space. The first linear color space may be various linear color spaces that are convenient for processing, including the RGB linear color space, etc. The present disclosure does not make special limitations on this.
[0054] In an exemplary embodiment, since the Y value in the XYZ color space can be used to represent brightness, after obtaining the image to be processed in the linear color space, the image to be processed can be converted to the XYZ color space, and then the Y value corresponding to each pixel point in the image to be processed is extracted as the original brightness data for subsequent processing. It should be noted that the original brightness data may be in the form of a matrix that can represent which pixel point brightness value in the image to be processed the Y value is, or in other forms. The present disclosure also does not limit this.
[0055] After obtaining the original luminance data, it is necessary to determine the adjustment parameters required for the luminance adjustment process before performing the luminance adjustment process. Among them, the adjustment parameters may include a preset luminance set according to the type of the image to be processed. For example, in a portrait, when adjusting the luminance of the face area, the facial skin of yellow people usually only requires a moderate luminance, while white people require a relatively low preset luminance, and black people may require a higher preset luminance. In addition, in other types of images, there are similar scenarios. Therefore, before performing the luminance adjustment process, different preset luminances can be set according to the different areas to be adjusted in the image to be processed.
[0056] In an exemplary embodiment, when there are problems of insufficient dynamic range and low contrast in the image to be processed, different degrees of adjustment are required for regions with different luminances. Therefore, the above adjustment process can refer to Figure 6 shown in, and includes the following steps S611 and S612:
[0057] In step S611, based on the preset luminance, the coefficients of the linear function segment and the non-linear function segment in the preset piecewise function are adjusted to determine the piecewise mapping function.
[0058] In an exemplary embodiment, when adjusting the original luminance data, if it is necessary to brighten the overly dark regions in the image to be processed, generally, more brightening is required for regions with lower luminance in the image to be processed, while only less brightening is required for regions with relatively higher luminance. Therefore, a piecewise function can be used to adjust different luminances. On the contrary, when darkening the overly bright regions in the image to be processed, since generally more darkening is required for regions with higher luminance in the image to be processed, while only less brightening is required for regions with relatively higher luminance, the above method of using a piecewise mapping function can also be used to perform different mappings on different luminance regions.
[0059] Among them, the preset piecewise function includes at least one linear function segment and at least one non-linear function segment. The types of the above linear function and non-linear function, as well as the independent variable segments corresponding to the linear function and non-linear function, can be set differently according to different adjustment requirements. For example, when brightening the overly dark regions in the image to be processed, a proportional function can be used as the function segment with a smaller independent variable, and a non-linear function with a decreasing reciprocal can be used as the function segment with a larger independent variable to establish a preset piecewise function, as Figure 7 shown. Figure 7 In, L is the independent variable (i.e., the input original luminance data), L m is the dependent variable (i.e., the target luminance data obtained after mapping), n is the segmentation point of the preset piecewise function, and m is the preset luminance.
[0060] It should be noted that in each segment function of the preset piecewise function, at least one adjustable coefficient should be included so that when adjusting this coefficient, the break points of the preset piecewise function can be adjusted according to the change of this coefficient. For example, when the preset piecewise function is a piecewise function composed of a proportional function y = ax and a non-linear function y = x / (x + b), b can be set to 1 and a can be used as the adjustable coefficient. By adjusting a, the break points of the preset function can be adjusted. In addition, multiple adjustable coefficients can also be set, and the present disclosure does not make special limitations on this.
[0061] In an exemplary embodiment, when determining the piecewise mapping function, at least one adjustable coefficient in the preset piecewise function can be adjusted, and when a certain or a certain group of specific values are taken for at least one adjustable coefficient and the function value corresponding to the break point of the preset piecewise function is equal to the preset brightness, the preset piecewise function determined by the above certain or certain group of specific values is determined as the piecewise mapping function.
[0062] In step S612, the original brightness data is mapped according to the piecewise mapping function to obtain the target brightness data.
[0063] In an exemplary embodiment, after determining the piecewise mapping function, the brightness value corresponding to each pixel in the original brightness data can be used as the independent variable and input into the piecewise mapping function, and the obtained dependent variable is determined as the brightness value corresponding to the pixel in the target brightness data. By using the piecewise mapping function for brightness mapping, different mappings can be performed on brightness values in different brightness ranges, thereby effectively improving the problems of insufficient dynamic range and low contrast in the image to be processed.
[0064] In an exemplary embodiment, during the adjustment process, before mapping the original brightness data according to the piecewise mapping function to obtain the target brightness data, the original brightness data can also be scaled first, and then the scaled original brightness data is mapped to obtain the target data. It should be noted that when the brightness adjustment process includes the above scaling process, the adjustment parameters in the corresponding brightness adjustment process can also include preset scaling parameters. By scaling the original brightness data, the difference between the maximum brightness and the minimum brightness in the image to be processed can be reduced to a certain extent, making the brightness of the image to be processed more concentrated, and thus facilitating the adjustment of over-bright or over-dark regions.
[0065] In an exemplary embodiment, when scaling the original brightness data, the average brightness value of the original brightness data can be calculated first, and then the original brightness data is scaled based on the average brightness value and the preset scaling parameter. For example, when scaling the original brightness data, the following formula (1) can be used for scaling:
[0066]
[0067] Among them, L(x, y) represents the luminance value corresponding to the pixel (x, y) after scaling; k represents a preset scaling parameter; represents the average luminance value; L ω (x, y) represents the luminance value corresponding to the pixel (x, y) in the image to be processed.
[0068] Among them, the average luminance value in formula (1) is the average luminance value in a broad sense and can be calculated using a variety of pre-designed calculation formulas. For example, the above pre-designed calculation formula can be a calculation formula for calculating the log average value, as shown in formula (2):
[0069]
[0070] Among them, represents the average luminance value; L ω (x, y) represents the luminance value corresponding to the pixel (x, y) in the image to be processed; N represents the total number of pixels in the image to be processed; δ is used to avoid singularities when there are black pixels in the image. In addition, other average value algorithms can also be used to calculate the average luminance value. For example, the arithmetic mean or weighted mean of the original luminance data can be calculated, and the present disclosure does not make special limitations on this.
[0071] In step S620, an intermediate image is generated based on the image to be processed and the target luminance data, and the luminance of the intermediate image is detected.
[0072] In an exemplary embodiment, after obtaining the target luminance data, the original luminance data in the image to be processed can be replaced with the target luminance data to obtain the image to be processed with adjusted luminance. Then, in order to facilitate the luminance detection of the image to be processed with adjusted luminance, the image to be processed with adjusted luminance can be converted to a second linear color space to generate an intermediate image. Among them, the second linear color space can be various linear color spaces that are convenient for processing, including the RGB linear color space, etc., and the present disclosure does not make special limitations on this.
[0073] It should be noted that converting the image to be processed to the above first linear color space or converting the image to be processed with adjusted luminance to the second linear color space here is for the convenience of subsequent processing. Therefore, as long as the first linear color space or the second linear color space can facilitate subsequent processing, the first linear color space and the second linear color space can be the same or different, and the present disclosure does not limit this either.
[0074] In addition, in some exemplary embodiments, since the target image needs to be displayed on some displays, before performing brightness detection, gamma correction can be first performed on the intermediate image, and then brightness detection can be performed, so that the finally obtained intermediate image will not have insufficient dynamic range or low contrast even when displayed on the display.
[0075] In step S630, when the detection result of the brightness detection meets the preset condition, the intermediate image is output as the target image.
[0076] In an exemplary embodiment, when the methods used for brightness detection are different, corresponding different preset conditions can be set. Among them, the preset conditions can include conditions for determining whether there is a relatively small brightness or a relatively large brightness in the target image, etc., which may cause problems such as overexposure or underexposure in the target image. For example, when the detection result of the brightness detection is the maximum brightness value and the minimum brightness value in the target image, the preset condition can be set as whether the maximum brightness value and the minimum brightness value in the target image are within the preset range.
[0077] In an exemplary embodiment, the above brightness detection can be achieved by detecting the image histogram of the intermediate image. Specifically, the above intermediate image can be converted into a corresponding image histogram, and the peak value of the image histogram can be extracted, and then the gray level value corresponding to the peak value is determined as the result of the brightness detection. The horizontal axis of the image histogram is the gray level value, and the vertical axis is the number of pixels in the intermediate image at this gray level value. By using the peak value as the detection result of the brightness detection, the gray level value with the largest number in the intermediate image can be retained, and then it can be determined whether the brightness of the intermediate image meets the preset condition according to the gray level value with the largest number.
[0078] In another exemplary embodiment, there may be some peak values in the image histogram. Although they are peak values, their numerical values are still relatively small and have little effect on the uneven brightness of the intermediate image. Therefore, the peak values in the image histogram can be filtered first, and the filtered peak values are used as the detection result of the brightness detection. By presetting filtering parameters to filter the peak values in the histogram to obtain the target peak values, the gray level values with relatively small numbers in the intermediate image can be filtered out, and only the gray level values with relatively large numbers are retained as the detection result of the brightness detection. After filtering, since there are fewer peak values in the detection result, it is easier to meet the preset condition. While ensuring image processing, the number of executions of the brightness adjustment process can also be reduced to a certain extent, saving computing resources.
[0079] Specifically, in an exemplary embodiment, a filtering threshold may be determined based on a preset filtering parameter and the maximum peak in the image histogram to measure the degree of influence of the peak on the brightness non-uniformity of the intermediate image. When determining the filtering threshold, the filtering threshold may be determined by the ratio of the maximum peak to the preset filtering parameter. For example, the preset filtering parameter may be set to 3, and when the maximum peak in the image histogram of the intermediate image is 120, the filtering threshold may be determined to be 120 / 3 = 40. Then, the peaks smaller than the filtering threshold may be filtered out, and the peaks greater than the filtering threshold may be retained.
[0080] In step S640, when the detection result does not meet the preset condition, the adjustment parameter is corrected based on the detection result, and the brightness adjustment process is performed on the original brightness data according to the corrected adjustment parameter until the detection result meets the preset condition.
[0081] In an exemplary embodiment, when the detection result includes the gray level value corresponding to the peak in the image histogram, the preset condition may include a gray level range. At this time, if all the gray level values in the detection result are within the gray level range, it may indicate that in the intermediate image corresponding to the detection result, the gray levels of most pixels belong to a specific range, that is, the dynamic range of the intermediate image is appropriate, the contrast is suitable, and correspondingly, there will be no overexposure or underexposure.
[0082] On the contrary, if there is at least one gray level value in the detection result that is not within the gray level range, it may indicate that in the intermediate image corresponding to the detection result, a relatively large number of pixels have gray levels that do not belong to the specific range, that is, the overall intermediate image may have a situation of brightness polarization, and there may be overexposed or underexposed areas in the intermediate image.
[0083] It should be noted that in some exemplary embodiments, in order to ensure that the dynamic range of the over-dark or over-bright areas in the image to be processed is appropriate and the contrast is suitable after brightness adjustment, the part originally being the over-dark or over-bright area in the intermediate image may also be identified based on the original brightness data, cropped for this part, and the above-mentioned brightness detection process is performed based on the cropped intermediate image, and then it is determined whether the target image can be output. It should be noted that in addition to identifying the area based on the original brightness data, other identification methods may also be used for identification, such as a machine learning identification model, etc.
[0084] In an exemplary embodiment, after determining that the detection result does not meet the preset conditions, the set adjustment parameters can be corrected, and the brightness adjustment process can be cycled according to the corrected adjustment parameters until the intermediate image obtained according to the target brightness data can meet the preset conditions, and the intermediate image is output as the target image. It should be noted that the cyclically executed brightness adjustment process needs to be the same as the first brightness adjustment process. When the adjustment parameters only include the preset brightness corresponding to the image to be processed, only the preset brightness is adjusted subsequently; when the adjustment parameters also include the preset scaling parameters, the preset brightness and the preset scaling parameters can be adjusted simultaneously during subsequent adjustments.
[0085] In an exemplary embodiment, the above adjustment process can be executed based on a trained parameter adjustment model. Specifically, a well-established machine learning model or deep learning model can be trained with the detection results of the brightness detection of different sample images and the parameters when outputting the target image as a sample pair to obtain a trained parameter adjustment model.
[0086] In addition, in other embodiments, a custom adjustment method can also be used for adjustment. For example, a function of the preset brightness can be set based on the initial preset brightness, and the preset brightness decreases based on the initial preset brightness as the number of cycles increases; or a series of preset brightness values can be customized in advance and adjusted continuously according to the set series of preset brightness values. In addition, other custom methods can also be used, and the present disclosure does not make special limitations on this.
[0087] It should be noted that the technical solution of the embodiment of the present disclosure can not only brighten the too dark areas in the image to be processed, but also adjust parameters such as the preset brightness and the piecewise mapping function to achieve the effect of dimming the too bright areas in the image to be processed.
[0088] The following refers to Figures 8 to 12 , taking the adjustment of the portrait image shown in Figure 3 as an example by the image processing method of the present disclosure, the technical solution of the embodiment of the present disclosure will be elaborated in detail.
[0089] Figure 3 In the portrait image shown in
[0090] Step S801, convert the portrait image shown in Figure 3 to the RGB linear color space;
[0091] Step S803, further convert the portrait image to the XYZ color space and extract the Y value as the original brightness data;
[0092] Step S805: Calculate the log average luminance value corresponding to the original luminance data based on the above formula (1);
[0093] Step S807: Substitute the log average luminance value and the preset scaling parameter into the above formula (2) to scale the original luminance data;
[0094] Step S809: Adjust the coefficients of the linear function segment and the non - linear function segment based on the preset luminance and the preset piece - wise function to determine the piece - wise mapping function where the function value at the piece - wise point is equal to the preset luminance;
[0095] Among them, the above linear function can be a direct - proportion function, and the above non - linear function can be a non - linear function with a decreasing derivative; the determined piece - wise mapping function can be, for example, the piece - wise function as Figure 7 shown, where m is the piece - wise point and n is the preset luminance. It should be noted that in this embodiment, n can usually be set to 0.7 in the portrait image.
[0096] Step S811: Map the original luminance data through the piece - wise mapping function to obtain the target luminance data;
[0097] Step S813: Replace the original luminance data with the target luminance data and convert the image to be processed in the XYZ color space to the RGB linear color space to obtain an intermediate image;
[0098] Step S815: Perform gamma correction on the converted intermediate image;
[0099] Step S817: Identify the face region in the intermediate image and perform histogram analysis on this region to obtain an image histogram, as Figure 9 shown (the image histogram corresponding to the face region of the original portrait image is as Figure 10 shown);
[0100] Step S819: Extract each peak in the image histogram. Based on the preset filtering parameter 3 and the quantity max corresponding to the largest peak in the image histogram, calculate the filtering threshold max / 3, and then filter out the peaks in the image histogram that are less than max / 3 (as Figure 11 shown, filter out the left - most and right - most peaks), and use the gray - level values corresponding to the remaining peaks as the detection result.
[0101] Step S821: When all the detection results are within the gray - level range from L to H, output the intermediate image;
[0102] Step S823, when there is at least one in the detection result outside the gray scale range L to H, correct the value of the preset brightness and the value of the preset scaling parameter, and repeat the above steps S807 to S811 until the detection result corresponding to the intermediate image determined according to the target brightness data meets the preset conditions;
[0103] Among them, when correcting the value of the preset brightness and the value of the preset scaling parameter, the value of the preset scaling parameter can be adjusted first to make the gray scale value corresponding to the peak close to the range of L to H, and then the preset brightness can be adjusted to make the peak with a gray scale value higher than H or lower than L fall back to the range of L to H.
[0104] Figure 12 shows a portrait image processed according to the technical solution of the embodiment of the present disclosure. Relative to Figure 3 and Figure 4 in terms of, Figure 12 it significantly brightens the too dark face area, Figure 3 the overexposed area in Figure 12 does not show overexposure or loss of image details in Figure 4 either, and at the same time, there are no problems such as unnatural edge processes and distortion that appear in
[0105] In summary, in this exemplary embodiment, by performing at least one brightness adjustment process on the image to be processed, different mapping processes can be performed on different brightness data through a piecewise mapping function, so as to achieve the purpose of adjusting the insufficient dynamic range and low contrast in the image to be processed.
[0106] It should be noted that the above drawings are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, rather than for limiting purposes. It is easy to understand that the processes shown in the above drawings do not indicate or limit the time sequence of these processes. Additionally, it is also easy to understand that these processes can be executed synchronously or asynchronously in, for example, multiple modules.
[0107] Furthermore, as shown in Figure 13 in this exemplary embodiment, an image processing apparatus 1300 is further provided, including a brightness adjustment module 1310, a brightness detection module 1320, and an image output module 1330. Among them:
[0108] The brightness adjustment module 1310 can be used to obtain the original brightness data of the image to be processed, and perform a brightness adjustment process on the original brightness data based on the adjustment parameters to obtain the target brightness data; the adjustment parameters include the preset brightness corresponding to the image to be processed;
[0109] The brightness detection module 1320 can be used to generate an intermediate image according to the image to be processed and the target brightness data, and perform brightness detection on the intermediate image;
[0110] The image output module 1330 can be used to output the intermediate image as the target image when the detection result of the brightness detection meets the preset conditions; and when the detection result does not meet the preset conditions, correct the adjustment parameters based on the detection result, and control the brightness adjustment module 1310 to perform the brightness adjustment process on the original brightness data according to the corrected adjustment parameters until the detection result meets the preset conditions;
[0111] Among them, the brightness adjustment process includes:
[0112] Adjust the coefficients of the linear function segment and the non-linear function segment in the preset piecewise function based on the preset brightness to determine the piecewise mapping function;
[0113] Map the original brightness data according to the piecewise mapping function to obtain the target brightness data.
[0114] In an exemplary embodiment, the brightness adjustment module 1310 can be used to obtain the average brightness value of the original brightness data and scale the original brightness data based on the average brightness value and the preset scaling parameter.
[0115] In an exemplary embodiment, the brightness adjustment module 1310 can be used to calculate the original brightness data according to a preset calculation formula to obtain the average brightness value of the original brightness data.
[0116] In an exemplary embodiment, the brightness adjustment module 1310 can be used to adjust the coefficients of the linear function segment and the non-linear function segment in the preset piecewise function; when the function value corresponding to the piecewise point of the preset piecewise function is equal to the preset brightness, determine the preset piecewise function determined by the coefficients as the piecewise mapping function.
[0117] In an exemplary embodiment, the brightness detection module 1320 can be used to convert the intermediate image into an image histogram and extract the peak value in the image histogram; determine the gray level value corresponding to the peak value as the detection result of the brightness detection.
[0118] In an exemplary embodiment, the brightness detection module 1320 can be used to filter the peak value of the image histogram based on a preset filtering parameter to obtain the filtered peak value.
[0119] In an exemplary embodiment, the brightness detection module 1320 can be used to calculate the filtering threshold based on the preset filtering parameter and the maximum peak value in the image histogram, and filter out the peak values in the image histogram that are less than the filtering threshold to obtain the filtered peak values.
[0120] In an exemplary embodiment, the brightness detection module 1320 can be used to determine that the detection result meets the preset condition when all the gray-scale values in the detection result are within the gray-scale range; and determine that the detection result does not meet the preset condition when there is at least one gray-scale value in the detection result that is not within the gray-scale range.
[0121] In an exemplary embodiment, the brightness detection module 1320 can be used to crop the intermediate image based on the original brightness data to obtain the cropped intermediate image.
[0122] In an exemplary embodiment, the image output module 1330 can be used to correct the adjustment parameters based on the trained parameter adjustment model.
[0123] In an exemplary embodiment, the brightness adjustment module 1310 can be used to convert the image to be processed into the XYZ color space and extract the Y value corresponding to each pixel point in the image to be processed as the original brightness data corresponding to the image to be processed.
[0124] In an exemplary embodiment, the brightness adjustment module 1310 can be used to convert the image to be processed into the first linear color space.
[0125] In an exemplary embodiment, the brightness detection module 1320 can be used to replace the original brightness data with the target brightness data and convert the image to be processed into the second linear color space to generate an intermediate image.
[0126] The specific details of each module in the above device have been described in detail in the implementation manner of the method part. The details not disclosed can be referred to the implementation manner content of the method part, and thus will not be elaborated here.
[0127] Those skilled in the art can understand that various aspects of the present disclosure can be implemented as a system, a method, or a program product. Therefore, various aspects of the present disclosure can be specifically implemented in the following forms, namely: a complete hardware implementation manner, a complete software implementation manner (including firmware, microcode, etc.), or an implementation manner combining hardware and software aspects, which can be collectively referred to as "circuit", "module", or "system" here.
[0128] The exemplary embodiments of the present disclosure also provide a computer-readable storage medium, on which a program product capable of implementing the above method of this specification is stored. In some possible implementation manners, various aspects of the present disclosure can also be implemented in the form of a program product, which includes program code. When the program product runs on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present disclosure described in the above "Exemplary Method" part of this specification, for example, it can execute Figure 6 and Figure 8 any one or more of the steps.
[0129] It should be noted that the computer-readable medium shown in this disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0130] In this disclosure, a computer-readable storage medium can be any tangible medium that contains or stores a program, which can be used by or in conjunction with an instruction execution system, apparatus, or device. And in this disclosure, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination of the above.
[0131] In addition, the program code for performing the operations of this disclosure can be written in any combination of one or more programming languages. The programming languages include object-oriented programming languages such as Java, C++, etc., and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, executed as an independent software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, by using an Internet service provider to connect through the Internet).
[0132] Other embodiments of the present disclosure will be readily apparent to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include known or customary technical means in the technical field not disclosed in the present disclosure. The specification and examples are only to be considered as exemplary, and the true scope and spirit of the present disclosure are pointed out by the claims.
[0133] It should be understood that the present disclosure 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 disclosure is only limited by the appended claims.
Claims
1. An image processing method, characterized in that, Including: Obtain the original brightness data of the image to be processed, and perform a brightness adjustment process on the original brightness data based on adjustment parameters to obtain target brightness data; The adjustment parameters include the preset brightness corresponding to the image to be processed; Generate an intermediate image according to the image to be processed and the target brightness data, and perform brightness detection on the intermediate image; When the detection result of the brightness detection meets a preset condition, output the intermediate image as the target image; When the detection result does not meet the preset condition, correct the adjustment parameters based on the detection result, and perform the brightness adjustment process on the original brightness data according to the corrected adjustment parameters until the detection result meets the preset condition; Wherein, the brightness adjustment process includes: Adjust the coefficients of the linear function segment and the non-linear function segment in the preset piecewise function based on the preset brightness to determine a piecewise mapping function; Map the original brightness data according to the piecewise mapping function to obtain the target brightness data, Wherein, the adjusting the coefficients of the linear function segment and the non-linear function segment in the preset piecewise function based on the preset brightness to determine a piecewise mapping function includes: Adjust the coefficients of the linear function segment and the non-linear function segment in the preset piecewise function; When the function value corresponding to the breakpoint of the preset piecewise function is equal to the preset brightness with the coefficients, determine the preset piecewise function determined by the coefficients as the piecewise mapping function.
2. The method according to claim 1, characterized in that, The adjustment parameters include a preset scaling parameter; Before mapping the original brightness data according to the piecewise mapping function to obtain the target brightness data, the brightness adjustment process further includes: Obtain the average brightness value of the original brightness data, and scale the original brightness data based on the average brightness value and the preset scaling parameter.
3. The method according to claim 2, characterized in that, The obtaining the average brightness value of the original brightness data includes: Calculate the original brightness data according to a preset calculation formula to obtain the average brightness value of the original brightness data.
4. The method according to claim 1, characterized in that, The performing brightness detection on the intermediate image includes: Convert the intermediate image into an image histogram, and extract the peak value in the image histogram; Determine the gray level value corresponding to the peak value as the detection result of the brightness detection.
5. The method according to claim 4, characterized in that, Before determining the gray level value corresponding to the peak value as the detection result of the brightness detection, the method further includes: Filter the peak value of the image histogram based on a preset filtering parameter to obtain a filtered peak value.
6. The method according to claim 5, characterized in that, The filtering the peak value of the image histogram based on a preset filtering parameter includes: Calculate a filtering threshold based on the preset filtering parameter and the maximum peak value in the image histogram, and filter out the peak values in the image histogram that are less than the filtering threshold.
7. The method according to claim 4, characterized in that, The preset condition includes a gray level range; When all the gray level values in the detection result are within the gray level range, determine that the detection result meets the preset condition; When there is at least one gray level value in the detection result that is not within the gray level range, determine that the detection result does not meet the preset condition.
8. The method according to claim 4, characterized in that, Before converting the intermediate image into an image histogram, the method further includes: Cropping the intermediate image based on the original luminance data to obtain a cropped intermediate image.
9. The method according to claim 1, characterized in that, The correcting the adjustment parameter based on the detection result includes: Taking the detection result as an input and correcting the adjustment parameter based on a trained parameter adjustment model.
10. The method according to claim 1, wherein, The obtaining the original luminance data of the image to be processed includes: Converting the image to be processed into the XYZ color space and extracting the Y value corresponding to each pixel point in the image to be processed as the original luminance data corresponding to the image to be processed.
11. The method according to claim 10, wherein, Before converting the image to be processed into the XYZ color space, the method further includes: Converting the image to be processed into a first linear color space.
12. The method according to claim 1, wherein, The generating the intermediate image according to the image to be processed and the target luminance data includes: Replacing the original luminance data with the target luminance data and converting the image to be processed into a second linear color space to generate an intermediate image.
13. An image processing apparatus, wherein, Including: A luminance adjustment module, configured to obtain the original luminance data of the image to be processed and perform a luminance adjustment process on the original luminance data based on an adjustment parameter to obtain a target luminance data; the adjustment parameter includes a preset luminance corresponding to the image to be processed; A luminance detection module, configured to generate an intermediate image according to the image to be processed and the target luminance data and perform luminance detection on the intermediate image; An image output module, configured to output the intermediate image as a target image when a detection result of the luminance detection meets a preset condition; And when the detection result does not meet the preset condition, correcting the adjustment parameter based on the detection result and controlling the luminance adjustment module to perform the luminance adjustment process on the original luminance data according to the corrected adjustment parameter until the detection result meets the preset condition; Wherein, the luminance adjustment process includes: Adjusting coefficients of a linear function segment and a non-linear function segment in a preset piecewise function based on the preset luminance to determine a piecewise mapping function; Mapping the original luminance data according to the piecewise mapping function to obtain the target luminance data, Wherein, the adjusting coefficients of the linear function segment and the non-linear function segment in the preset piecewise function based on the preset luminance to determine the piecewise mapping function includes: Adjusting coefficients of the linear function segment and the non-linear function segment in the preset piecewise function; When the function value corresponding to a segmentation point of the preset piecewise function is equal to the preset luminance by the coefficients, determining the preset piecewise function determined by the coefficients as the piecewise mapping function.
14. A computer-readable medium having a computer program stored thereon, wherein, The computer program, when executed by a processor, implements the method according to any one of claims 1 to 12.
15. An electronic device, wherein, Including: A processor; And A memory, configured to store executable instructions of the processor; Wherein, the processor is configured to execute the method according to any one of claims 1 to 12 by executing the executable instructions.
Citation Information
Patent Citations
Self-adaptive low-illuminance or non-uniform-brightness image enhancement method
CN104156921A
Image processing method, terminal and storage medium
CN111160267A