Image processing method and device, equipment and storage medium
By adjusting the brightness histogram of the image, the problem of excessive brightness enhancement in the dark part of the image is solved, and the brightness and contrast are improved, while maintaining the hierarchy and visual balance of the image.
Patent Information
- Application Number
- CN202510105604.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-22
- Publication Date
- 2025-05-27
AI Technical Summary
The overall image taken in a low-light environment is darker, and the brightness of the dark part of the image is easily increased when the global histogram equalization process is based on the global histogram.
By determining the dark area on the original brightness histogram of the image to be processed, the original brightness histogram is adjusted according to the total number of pixels in the dark area, a target brightness histogram is obtained, and the image is processed using the histogram.
While improving image brightness and contrast, excessive brightness in dark parts of the image is avoided, and the layering and visual balance of the image are maintained.
Smart Images

Figure CN120047369A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technologies, and in particular, to an image processing method, apparatus, device, and storage medium. Background Art
[0002] Images taken in low-light environments tend to be overall dark. In order to make the details hidden in the dark parts of such images perceptible, in the related art, the image is usually processed based on global histogram equalization. However, it has been found in practice that when processing the image based on global histogram equalization, it is often easy to cause the brightness of the dark parts of the image to be overly enhanced. Summary of the Invention
[0003] This application provides an image processing method, apparatus, device, and storage medium, which can improve the brightness and contrast of the image while avoiding the over-enhancement of the brightness of the dark parts of the image.
[0004] In a first aspect of an embodiment of this application, an image processing method is provided, including:
[0005] Determine the dark part area on the original brightness histogram of the image to be processed, where the gray value of the dark part area is less than the gray value of the area other than the dark part area on the original brightness histogram;
[0006] Adjust the original brightness histogram according to the total number of pixels in the dark part area to obtain a target brightness histogram;
[0007] Process the image to be processed using the target brightness histogram to obtain a target image.
[0008] In a second aspect of an embodiment of this application, an image processing apparatus is provided, including:
[0009] A determination unit, configured to determine the dark part area on the original brightness histogram of the image to be processed, where the gray value of the dark part area is less than the gray value of the area other than the dark part area on the original brightness histogram;
[0010] An adjustment unit, configured to adjust the original brightness histogram according to the total number of pixels in the dark part area to obtain a target brightness histogram;
[0011] A processing unit, configured to process the image to be processed using the target brightness histogram to obtain a target image.
[0012] In a third aspect of an embodiment of this application, an electronic device is provided,
[0013] A memory storing executable program code;
[0014] And a processor coupled to the memory;
[0015] The processor calls the executable program code stored in the memory. When the executable program code is executed by the processor, the processor implements the method disclosed in the first aspect of the embodiments of the present application.
[0016] The fourth aspect of the embodiments of the present application provides a computer-readable storage medium, on which executable program code is stored. When the executable program code is executed by a processor, the method disclosed in the first aspect of the embodiments of the present application is implemented.
[0017] The fifth aspect of the embodiments of the present application discloses a computer program product. When the computer program product runs on a computer, the computer is caused to execute the method disclosed in the first aspect of the embodiments of the present application.
[0018] The sixth aspect of the embodiments of the present application discloses an application publishing platform, which is used to publish a computer program product. Among them, when the computer program product runs on a computer, the computer is caused to execute the method disclosed in the first aspect of the embodiments of the present application.
[0019] From the above technical solutions, it can be seen that the embodiments of the present application have at least the following advantages:
[0020] Determine the dark area on the original brightness histogram of the image to be processed, where the gray value of the dark area is less than the gray value of the area other than the dark area on the original brightness histogram; adjust the original brightness histogram according to the total number of pixels in the dark area to obtain a target brightness histogram; process the image to be processed using the target brightness histogram to obtain a target image.
[0021] By implementing this method, first determine the dark area on the original brightness histogram of the image to be processed, and then adjust the original brightness histogram based on the total number of pixels in the dark area, which helps to maintain the relative brightness relationship between different gray areas in the image. This enables the image to still maintain the original sense of hierarchy and visual balance after adjusting the brightness and contrast, effectively controlling the brightness level of the dark part of the image, and thus solving the problem of over-enhanced brightness in the dark part of the image. Description of the Drawings
[0022] Figure 1A is a scenario diagram of the image processing method disclosed in the embodiments of the present application;
[0023] Figure 1B is another scenario diagram of the image processing method disclosed in the embodiments of the present application;
[0024] Figure 2 is a flowchart of the image processing method disclosed in the embodiments of the present application;
[0025] Figure 3It is another flowchart of the image processing method disclosed in the embodiments of the present application;
[0026] Figure 4 It is yet another flowchart of the image processing method disclosed in the embodiments of the present application;
[0027] Figure 5 It is yet another flowchart of the image processing method disclosed in the embodiments of the present application;
[0028] Figure 6 It is a structural diagram of an image processing device disclosed in the embodiments of the present application;
[0029] Figure 7 It is a structural diagram of an electronic device disclosed in the embodiments of the present application. Detailed implementation manners
[0030] The present application provides an image processing method, device, equipment and storage medium, which can improve the brightness and contrast of an image while avoiding excessive enhancement of the brightness of the dark part of the image.
[0031] In order to enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all should belong to the scope protected by the present application.
[0032] It should be noted that in the present application, words such as "exemplarily" or "for example" are used to represent examples, illustrations or explanations. Any embodiment or design solution described as "exemplarily" or "for example" in the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Exactly, using words such as "exemplarily" or "for example" is intended to present relevant concepts in a specific manner.
[0033] "At least one" means one or more, and "a plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone, where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after. "At least one (item)" or similar expressions thereof refer to any combination of these items, including any combination of single item (item) or plural items (items). For example, at least one (item) of a, b and c can represent: a, or b, or c, or a and b, or a and c, or b and c, or a, b and c, where a, b, c can be single or multiple.
[0034] Please refer toFigure 1A , Figure 1A is a scene diagram disclosed in an embodiment of the present application. As shown in Figure 1A the scene diagram, it includes an electronic device 10. The electronic device 10 may include an image sensor. The electronic device 10 can capture images through the image sensor. However, in a low-light environment, the images captured by the electronic device 10 are often overall dark. In order to enable the details hidden in the dark parts of the captured images to be perceived by the user, it is usually necessary to process the captured images to enhance the contrast and brightness of the images.
[0035] It should be noted that the processing of the captured images can be performed by the electronic device 10, or by Figure 1B the server 20 shown in
[0036] That is, the electronic device 10 captures an image and sends the captured image to the server 20. The server 20 processes the captured image and sends the processed image to the electronic device 10.
[0037] In the related art, the electronic device 10 usually processes images based on global histogram equalization to improve the brightness and contrast of the images. Performing equalization based on the global histogram means statistically analyzing the histogram of the entire image, and then redistributing the gray values of each pixel in the image so that the gray distribution of the image is more uniform, thereby enhancing the contrast and brightness of the image. However, it is found in practice that when the electronic device 10 processes images based on global histogram equalization, the problem of excessive enhancement of the brightness of the dark parts of the image usually easily occurs.
[0038] To solve the above problems, the prior art has proposed a method for processing images based on local histogram equalization. The electronic device 10 performing image processing based on local histogram equalization may mean that the electronic device 10 divides the image into multiple local regions, performs histogram equalization processing on each local region separately, and then combines the processed local regions into the final image. Since the image processing based on local histogram equalization is to perform histogram equalization processing on each local region separately, in this way, the electronic device 10 can adjust according to the gray distribution characteristics of each region. For those regions where the gray value distribution is relatively concentrated, the enhanced contrast after equalization will be more appropriate, avoiding the problem of excessive enhancement of the brightness of the dark parts caused by global adjustment.
[0039] However, the method of performing equalization based on the local histogram usually involves the manual selection of some key parameters, such as the size of the local area, the contrast limit, etc. If these parameters are not properly selected, the effect of processing the image by performing equalization based on the local histogram is not ideal. Therefore, it is necessary to repeatedly try and adjust the key parameters, and the processing efficiency is low. In addition, the method of performing equalization based on the local histogram has a high computational complexity.
[0040] The embodiments of the present application disclose an image processing method, apparatus, device, and storage medium, which can improve the brightness and contrast of an image while avoiding excessive enhancement of the brightness of the dark part of the image.
[0041] The image processing method disclosed in the embodiments of the present application may include: an electronic device 10 determines a dark part area on the original brightness histogram of the image to be processed, and the gray value of the dark part area is less than the gray value of the area other than the dark part area on the original brightness histogram; and, adjusts the original brightness histogram according to the total number of pixels in the dark part area to obtain a target brightness histogram; and, processes the image to be processed using the target brightness histogram to obtain a target image.
[0042] By implementing this method, the electronic device 10 first determines the dark part area on the original brightness histogram of the image to be processed, and then adjusts the original brightness histogram based on the total number of pixels in the dark part area, which helps to maintain the relative brightness relationship between different gray areas in the image. This enables the image to still maintain the original sense of hierarchy and visual balance after adjusting the brightness and contrast, effectively controlling the brightness level of the dark part of the image, and thus solving the problem of excessive enhancement of the brightness of the dark part of the image. In addition, adjusting the original brightness histogram based on the total number of pixels in the dark part area does not require complex histogram calculations and processing for a large number of local areas respectively, and the computational complexity is relatively low.
[0043] It should be noted that the electronic device 10 disclosed in the embodiments of the present application may include general handheld screen electronic devices, such as mobile phones, smart phones, portable terminals, terminals, personal digital assistants (Personal Digital Assistant, PDA), portable multimedia players (Personal Media Player, PMP) devices, laptop computers, notebooks (NotePad), wireless broadband (Wireless Broadband, Wibro) terminals, tablet computers (Personal Computer, PC), and smart PCs, etc.
[0044] The electronic device 10 may also include a wearable device. A wearable device is a portable electronic device that can be directly worn on the user's body or integrated into the user's clothing or accessories. A wearable device is not just a hardware device, but can also achieve powerful intelligent functions through software support, data interaction, and cloud server interaction, such as computing functions, positioning functions, and alarm functions. At the same time, it can also be connected to mobile phones and various terminals. Wearable devices may include, but are not limited to, watch-type devices supported by the wrist (such as watches, bracelets, etc.), shoes-type devices supported by the feet (such as shoes, socks, or other products worn on the legs), glass-type devices supported by the head (such as glasses, helmets, headbands, etc.), and smart clothing, as well as various non-mainstream product forms such as schoolbags, crutches, and accessories.
[0045] The following further describes the solution of this application with specific embodiments.
[0046] Please refer to Figure 2 , Figure 2 which is a flowchart of an image processing method disclosed in an embodiment of this application. As Figure 2 shown, the image processing method may include the following steps:
[0047] 201. The electronic device determines the dark area on the original brightness histogram of the image to be processed.
[0048] The image to be processed may be an image captured in real time by an image sensor or an image pre-stored in the electronic device, etc., which is not limited in the embodiments of this application.
[0049] It should be noted that the gray value of the dark area is less than the gray value of the area other than the dark area on the original brightness histogram.
[0050] It can be understood that the original brightness histogram can be divided into a dark area and other areas outside the dark area. The area outside the dark area may include one area or multiple areas, which is not limited in the embodiments of this application.
[0051] In the case where the area outside the dark area includes multiple areas, the multiple areas outside the dark area may be an intermediate area and a bright area respectively. The gray value of the intermediate area is greater than the gray value of the dark area and less than the gray value of the bright area. That is, the gray value of the dark area is the smallest, the gray value of the bright area is the largest, and the gray value of the intermediate area is in the middle.
[0052] In the embodiments of this application, the electronic device determines the dark area on the original brightness histogram of the image to be processed may include: The electronic device determines the dark area on the original brightness histogram according to the original brightness histogram of the image to be processed, the total number of pixels of the image to be processed, and the weight coefficient corresponding to the dark area.
[0053] Among them, the total number of pixels of the image to be processed refers to the total number of pixel points in the image to be processed. The weight coefficient corresponding to the dark area can be preset based on the content of the image screen. Exemplarily, the weight coefficient corresponding to the dark area can be 0.2 or 0.3, etc., and the embodiments of the present application do not make limitations.
[0054] In some embodiments, the electronic device determines the dark area on the original brightness histogram according to the original brightness histogram of the image to be processed, the total number of pixels of the image to be processed, and the weight coefficient corresponding to the dark area, which may include:
[0055] The electronic device calculates the cumulative distribution histogram corresponding to the original brightness histogram according to the original brightness histogram of the image to be processed;
[0056] The electronic device determines the first boundary gray value in the cumulative distribution histogram corresponding to the original brightness histogram according to the total number of pixels of the image to be processed and the weight coefficient corresponding to the dark area, and the first boundary gray value is used to divide the dark area and the area other than the dark area;
[0057] According to the first boundary gray value, the dark area is determined from the original brightness histogram.
[0058] The abscissa of the original brightness histogram of the image to be processed is the gray value, and the abscissa is the number of pixels corresponding to the gray value. The calculation formula of the ordinate of the original brightness histogram is the following formula (1).
[0059] h(i) = n i , i = 0, 1, …, L - 1; (1)
[0060] Among them, n i represents the number of pixels with a gray value of i, and L represents the number of gray levels of the original brightness histogram. When the image to be processed is an 8-bit image, L can be 256. When the image to be processed is a 10-bit image, L can be 1024. Of course, when the image to be processed is an image of other bits, L can also be other values, and the embodiments of the present application will not elaborate one by one.
[0061] The abscissa of the cumulative distribution histogram corresponding to the original brightness histogram is the gray value, and the abscissa is the cumulative number of pixels corresponding to the gray value (that is, the sum of the number of pixels with a gray value less than or equal to this gray value). The calculation formula of the ordinate of the cumulative distribution histogram is the following formula (2).
[0062]
[0063] Among them, represents the cumulative number of pixels at gray level i, which is the sum of the number of pixels from gray value 0 to i.
[0064] The electronic device determines the first boundary gray value in the cumulative distribution histogram according to the total number of pixels of the image to be processed and the weight coefficient corresponding to the dark area, which may include: The electronic device multiplies the total number of pixels of the image to be processed by the weight coefficient corresponding to the dark area to obtain the total number of pixels in the dark area, and in the cumulative distribution histogram corresponding to the original brightness histogram, searches for the gray value corresponding to the total number of pixel accumulations being the total number of pixels in the dark area, and uses this gray value as the first boundary gray value.
[0065] It can be understood that if the total number of pixels of the image to be processed is N and the weight coefficient corresponding to the dark area is A1, then the total number of pixels in the dark area ThresholdLow = N×A1. After that, based on ThresholdLow, the first boundary gray value lower_bound is found in the cumulative distribution histogram corresponding to the original brightness histogram, where H(lower_bound) = ThresholdLow.
[0066] Exemplarily, when A1 is 0.3, H(lower_bound) = ThresholdLow = N×0.3; when A1 is 0.2, H(lower_bound) = ThresholdLow = N×0.2.
[0067] The electronic device determines the dark area from the original brightness histogram according to the first boundary gray value, which may include: The electronic device divides the original brightness histogram into a dark area and an area other than the dark area with the first boundary gray value as the boundary.
[0068] It should be noted that when the area other than the dark area includes multiple areas, the electronic device also needs to determine other boundary gray values for dividing these multiple areas. For example, when the area other than the dark area includes a middle area and a bright area, the electronic device also needs to determine the second boundary gray value in the original brightness histogram to divide the middle area and the bright area in the original brightness histogram.
[0069] The determination process of the second boundary gray value may be that the electronic device multiplies the total number of pixels of the image to be processed by the sum of the weight coefficients of the dark area and the middle area to obtain the total number of pixels in the dark area and the middle area, and in the cumulative distribution histogram corresponding to the original brightness histogram, searches for the gray value corresponding to the total number of pixel accumulations being the total number of pixels, and uses this gray value as the second boundary gray value.
[0070] It can be understood that if the total number of pixels of the image to be processed is N, the weight coefficient corresponding to the dark area is A1, and the weight coefficient corresponding to the middle area is A2, then the total number of pixels in the dark area and the middle area ThresholdHigh = N×(A1 + A2). Then, based on ThresholdHigh, the second boundary gray value upper_bound is found in the cumulative distribution histogram corresponding to the original brightness histogram, where H(upper_bound) = ThresholdHigh.
[0071] Exemplarily, when A1 is 0.3 and A2 is 0.4, H(upper_bound) = ThresholdHigh = N×(0.3 + 0.4). When A1 is 0.2 and A2 is 0.7, H(upper_bound) = ThresholdHigh = N×(0.2 + 0.7)
[0072] 202. The electronic device adjusts the original brightness histogram according to the total number of pixels in the dark area to obtain a target brightness histogram.
[0073] It can be understood that the electronic device adjusts the dark area and the area other than the dark area on the original brightness histogram according to the total number of pixels in the dark area. For example, when the electronic device divides the original brightness histogram into a dark area, a middle area, and a bright area, the electronic device can adjust the dark area, the middle area, and the bright area according to the total number of pixels in the dark area.
[0074] In some embodiments, the electronic device adjusts the original brightness histogram according to the total number of pixels in the dark area to obtain a target brightness histogram, which may include: the electronic device divides the number of pixels corresponding to each gray value in the original brightness histogram by the total number of pixels in the dark area to obtain a target brightness histogram.
[0075] In other embodiments, the electronic device adjusts the original brightness histogram according to the total number of pixels in the dark area to obtain a target brightness histogram, which may include: the electronic device adjusts the original brightness histogram according to the total number of pixels in the dark area and the weight coefficient corresponding to the dark area to obtain a target brightness histogram.
[0076] Further, the electronic device adjusts the original brightness histogram according to the total number of pixels in the dark area and the weight coefficient corresponding to the dark area to obtain a target brightness histogram, which may include: the electronic device divides the number of pixels corresponding to each gray value in the dark area by the total number of pixels in the dark area, and divides the number of pixels corresponding to each gray value in the area other than the dark area by a first calculation value to obtain a target brightness histogram; wherein, the first calculation value is obtained by multiplying the total number of pixels in the dark area by a weight ratio, and the weight ratio is obtained by dividing the weight coefficient corresponding to the area other than the dark area by the weight coefficient corresponding to the dark area.
[0077] For example, when the area other than the dark area includes a middle area and a bright area, the weight coefficient corresponding to the middle area is A2, the weight coefficient corresponding to the bright area is A3, the first calculation value corresponding to the middle area is obtained by multiplying the total number of pixels in the dark area ThresholdLow by (A2 / A1), and the first calculation value corresponding to the bright area is obtained by multiplying the total number of pixels in the dark area ThresholdLow by (A3 / A1).
[0078] Exemplarily, if NormalizedHistogram represents the target brightness histogram, and A1, A2, and A3 are 0.3, 0.4, and 0.3 in sequence, then the obtaining process of NormalizedHistogram is as follows:
[0079]
[0080] Among them, i <= lower_bound refers to the gray value in the dark area, and NormalizedHistogram(i) = h(i) / ThresholdLow refers to performing an adjustment operation on the dark area; i < upper_bound refers to the gray value in the middle area, and NormalizedHistogram(i) = (h(i) / ThresholdLow)*(0.4 / 0.3) refers to performing an adjustment operation on the middle area; NormalizedHistogram(i) = (h(i) / ThresholdLow)*(0.3 / 0.3) refers to performing an adjustment operation on the bright area.
[0081] 203. The electronic device processes the image to be processed using the target brightness histogram to obtain a target image.
[0082] In some embodiments, the electronic device processes the image to be processed using the target brightness histogram to obtain the target image, which may include: the electronic device calculates the cumulative distribution histogram corresponding to the target brightness histogram according to the target brightness histogram; and, calculates the image lookup table according to the cumulative distribution histogram and the gray level series of the image to be processed; and, maps the image to be processed using the image lookup table to obtain the target image.
[0083] It should be noted that the calculation of the cumulative distribution histogram corresponding to the target brightness histogram can refer to the relevant introduction about calculating the cumulative distribution histogram corresponding to the original brightness histogram above, and will not be elaborated here.
[0084] Among them, the image lookup table may include the new gray value corresponding to each gray value in the cumulative distribution histogram.
[0085] The electronic device calculates the image lookup table according to the cumulative distribution histogram and the gray level series of the image to be processed, which may include but are not limited to the following methods:
[0086] Method 1: The electronic device multiplies the pixel cumulative quantity corresponding to each gray value in the cumulative distribution histogram by the target value and takes the integer to obtain the new gray value corresponding to each gray value; where the target value is obtained by subtracting 1 from the gray level series of the image to be processed.
[0087] Exemplarily, the cumulative distribution histogram is represented by cumulative_sum, each gray value in cumulative_sum is represented by m, and LUT[m] represents the new gray value corresponding to each gray value m in cumulative_sum. Based on this, the calculation formula of the image lookup table is as follows: LUT[m] = round(cumulative_sum[m] * (L - 1)).
[0088] Method 2: The electronic device divides the pixel cumulative quantity corresponding to each gray value in the cumulative distribution histogram by the pixel cumulative quantity corresponding to the last gray level in the cumulative distribution histogram to obtain the target ratio, and multiplies the target ratio by the target value to obtain the new gray value corresponding to each gray value; where the target value is obtained by subtracting 1 from the gray level series of the image to be processed.
[0089] Exemplarily, the cumulative distribution histogram is represented by cumulative_sum, each gray value in cumulative_sum is represented by m, and LUT[m] represents the new gray value corresponding to each gray value m in cumulative_sum. Based on this, the calculation formula of the image lookup table is as follows:
[0090] LUT[m] = round((cumulative_sum[m] / cumulative_sum[L - 1]) * (L - 1)).
[0091] In the embodiments of the present application, when an electronic device uses an image lookup table to map a to-be-processed image to obtain a target image, it may include: the electronic device traverses the gray values of each pixel in the to-be-processed image, reads the new gray value corresponding to the gray value from the image lookup table, and modifies the gray value to the new gray value corresponding to the gray value to obtain the target image.
[0092] By implementing Figure 2 the method shown, the electronic device first determines the dark area on the original brightness histogram of the to-be-processed image, and then adjusts the original brightness histogram based on the total number of pixels in the dark area, which helps to maintain the relative brightness relationship between different gray areas in the image. This enables the image to still maintain the original sense of hierarchy and visual balance after adjusting the brightness and contrast, effectively controlling the brightness level of the dark part of the image, and thus solving the problem of over-enhanced brightness in the dark part of the image.
[0093] In some embodiments, in addition to adjusting the original brightness histogram of the to-be-processed image based on the dark area, the electronic device may further process the original brightness histogram adjusted based on the dark area according to the brightness distribution of the to-be-processed image, so as to protect the details in the main brightness concentration area of the image. It can be understood that obtaining the target brightness histogram not only requires adjusting the original brightness histogram based on the dark area, but also requires continuing to adjust the original brightness histogram adjusted based on the dark area according to the brightness distribution of the to-be-processed image. The following will be described in detail in conjunction with Figure 3 this.
[0094] Please refer to Figure 3 , Figure 3 which is another flowchart of the image processing method disclosed in the embodiments of the present application. As Figure 3 shown, the image processing method may include the following steps:
[0095] 301. The electronic device determines the dark area on the original brightness histogram of the to-be-processed image.
[0096] 302. The electronic device adjusts the original brightness histogram according to the total number of pixels in the dark area.
[0097] It should be noted that for the detailed introduction of steps 301 - 302, reference can be made to the relevant descriptions in the embodiments shown in Figure 2 and will not be elaborated here.
[0098] 303. The electronic device determines a first region and a second region from the adjusted original brightness histogram. The total number of pixels in both the first region and the second region is greater than or equal to the first quantity threshold, and the gray value of the first region is less than the gray value of the second region.
[0099] The first region and the second region refer to the regions where the gray values of most pixels are located.
[0100] It can be understood that before step 303, the electronic device can divide the adjusted original brightness histogram into multiple regions on average, calculate the total number of pixels in each region (that is, sum the number of pixels corresponding to each gray value in each region), and determine multiple target regions from the multiple regions obtained by the average division based on the total number of pixels in each region, and determine the first region and the second region from the multiple target regions.
[0101] In some embodiments, the first quantity threshold can be the average value or median of the total number of pixels in the multiple regions obtained by the average division, etc.
[0102] In other embodiments, the first quantity threshold can also be the total number of pixels in the region corresponding to the specified ranking position. Among them, the basis for ranking the multiple regions obtained by the average division is the total number of pixels in each region. The larger the total number of pixels, the higher the ranking position of the corresponding region.
[0103] Exemplarily, the specified ranking position can be the 2nd ranking position, the 3rd ranking position, or the 4th ranking position, etc., which is not limited in the embodiments of the present application.
[0104] Among them, the total number of pixels in the target region is greater than the first quantity threshold. When the number of target regions is two, the first region is the target region with a smaller gray value, and the second region is the target region with a larger gray value. When the number of target regions is greater than or equal to 3, the target regions corresponding to the gray values less than or equal to the gray value of the fourth region can be used as the first region, and the target regions corresponding to the gray values greater than the gray value of the fourth region can be used as the second region. Among them, the fourth region is the region with the middle gray value among the multiple regions obtained by the average division.
[0105] For example, when the image to be processed is a 10-bit image, the number of gray levels L of the image to be processed is 1024. Based on this, the electronic device can divide the adjusted original brightness histogram into 10 regions. The gray value intervals of these 10 regions are Region 0: [0, 102], Region 1: [103, 205], Region 2: [206, 308], Region 3: [309, 411], Region 4: [412, 514], Region 5: [515, 617], Region 6: [618, 720], Region 7: [721, 823], Region 8: [824, 926], Region 9: [927, 1023]. Among them, the target regions where the total number of pixels is greater than the first quantity threshold are Region 1, Region 2, and Region 9, and the fourth region is Region 4. Then, the first region is Region 1 and Region 2, and the second region is Region 9.
[0106] 304. The electronic device reduces the number of pixels in the second region according to the number of pixels in the first region, and evenly distributes the reduced number of pixels to the third region to obtain a target brightness histogram, where the third region is different from the second region.
[0107] In some embodiments, the electronic device reducing the number of pixels in the second region according to the number of pixels in the first region may include but is not limited to the following methods:
[0108] Method 1: The electronic device determines the maximum number of pixels corresponding to each gray value in the first region; and determines a target gray value in the second region, where the number of pixels corresponding to the target gray value is greater than m times the maximum number of pixels; and reduces the number of pixels corresponding to the target gray value to m times the maximum number of pixels, where m is an integer greater than or equal to 1.
[0109] Optionally, m can be 3.
[0110] It can be understood that when the first region is Region 1 and Region 2, and the second region is Region 9, the maximum number of pixels can be obtained by traversing the number of pixels corresponding to each gray value in Region 1 and Region 2, and then traversing the number of pixels corresponding to each gray value in Region 9 to find the target gray value in Region 9, where the number of pixels corresponding to the target gray value is greater than 3 times the maximum number of pixels, and reducing the number of pixels corresponding to the target gray value in Region 9 to 3 times the maximum number of pixels.
[0111] Method 2: The electronic device determines the maximum total number of pixels from the total number of pixels in at least one first region, and when the total number of pixels in the second region is greater than n times the maximum total number of pixels, reduces the total number of pixels in the second region to n times the maximum total number of pixels, where n is an integer greater than or equal to 1.
[0112] In some embodiments, reducing the total number of pixels in the second region to n times the maximum total number of pixels by the electronic device may be that the electronic device subtracts n times the maximum total number of pixels from the total number of pixels in the second region to obtain the total number of pixels to be subtracted, divides the total number of pixels to be inspected by the number of gray values in the second region to obtain the number of pixels to be subtracted corresponding to each gray value in the second region, and subtracts the number of pixels to be subtracted corresponding to each gray value from the number of pixels corresponding to each gray value in the second region.
[0113] Optionally, n may be 5.
[0114] It can be understood that in the case where the first region is region 1 and region 2 and the second region is region 9, the maximum total number of pixels of the two can be obtained from the total number of pixels in region 1 and the total number of pixels in region 2. When the total number of pixels in region 9 is greater than 5 times the maximum total number of pixels, the total number of pixels in region 9 is reduced to 5 times the maximum total number of pixels.
[0115] In the embodiments of the present application, the electronic device evenly distributing the reduced number of pixels to the third region may mean that the electronic device evenly distributes the reduced number of pixels to other regions except the second region. Exemplarily, in the case where the second region is region 9, the electronic device may evenly distribute the reduced number of pixels to other regions except region 9.
[0116] 305. The electronic device processes the image to be processed using the target brightness histogram to obtain the target image.
[0117] It should be noted that for the introduction of step 305, reference can be made to Figure 2 the relevant descriptions in the embodiments shown, which will not be elaborated here.
[0118] By implementing Figure 3 the method shown, the electronic device first determines the dark region on the original brightness histogram of the image to be processed, and then adjusts the original brightness histogram based on the total number of pixels in the dark region, which helps to maintain the relative brightness relationship between different gray regions in the image. This enables the image to still maintain the original sense of hierarchy and visual balance after adjusting the brightness and contrast, effectively controlling the brightness level of the dark part of the image, and thus solving the problem of over-enhanced brightness in the dark part of the image. In addition, the electronic device further adjusts the original brightness histogram adjusted based on the dark region according to the gray distribution of the image to be processed, which can protect the details in the main brightness concentration region of the image.
[0119] Based on the above description, the embodiments of the present application disclose Figure 4 the image processing method shown, as Figure 4 the image processing method shown may include the following steps:
[0120] 401. The electronic device reads the image to be processed from the image sensor.
[0121] 402. The electronic device calculates the original brightness histogram of the image to be processed.
[0122] 403. The electronic device calculates the cumulative distribution histogram corresponding to the original brightness histogram.
[0123] 404. The electronic device calculates the total number of pixels in the dark area, and the total number of pixels in the dark area and the middle area, according to the weight coefficient of the dark area, the weight coefficient of the middle area, and the total number of pixels of the image to be processed.
[0124] 405. The electronic device searches for the first boundary gray value and the second boundary gray value on the cumulative distribution histogram according to the total number of pixels in the dark area, and the total number of pixels in the dark area and the middle area, and divides the original brightness histogram into a dark area, a middle area, and a bright area according to the first boundary gray value and the second boundary value.
[0125] 406. The electronic device adjusts the original brightness histogram by using the total number of pixels in the dark area and the weight coefficient of the dark area.
[0126] 407. The electronic device determines the first area and the second area from the adjusted original brightness histogram, reduces the number of pixels in the second area according to the number of pixels in the first area, and evenly distributes the reduced number of pixels to the third area to obtain the target brightness histogram.
[0127] 408. The electronic device maps the target brightness histogram to the image to be processed to obtain the target image.
[0128] Among them, for the detailed introduction of steps 401 - 408, reference can be made to the relevant introduction in the above embodiments, which will not be elaborated here.
[0129] In some embodiments, after the electronic device divides the dark area from the original brightness histogram, it can also first subdivide and process the dark area, which is beneficial to improving the detail protection of the dark area. The following is combined with Figure 5 for introduction.
[0130] Please refer to Figure 5 , Figure 5 which is another flowchart of the image processing method disclosed in the embodiments of the present application. As Figure 5 shown, the image processing method may include the following steps:
[0131] 501. The electronic device determines the dark area on the original brightness histogram of the image to be processed.
[0132] 502. The electronic device determines a dark sub-region within the dark region, and the brightness of the dark sub-region is less than the brightness of the sub-regions within the dark region other than the dark sub-region.
[0133] It should be noted that for the method by which the electronic device determines the dark sub-region within the dark region, reference can be made to the method of determining the dark region from the original brightness histogram described above, which will not be elaborated here.
[0134] It can be understood that the dark region can be divided into a dark sub-region and other sub-regions other than the dark sub-region. The number of such other sub-regions can be 2, 3, 4, etc., which is not limited in the embodiments of this application.
[0135] 503. The electronic device adjusts the dark region according to the total number of pixels in the dark sub-region to obtain a new dark region.
[0136] In some embodiments, the electronic device adjusts the dark region according to the total number of pixels in the dark sub-region to obtain a new dark region, which may include but is not limited to the following methods:
[0137] Method 1: The electronic device adjusts the dark region according to the total number of pixels in the dark sub-region to obtain a new dark region.
[0138] Method 2: The electronic device adjusts the dark region according to the total number of pixels in the dark sub-region; and determines a first sub-region and a second sub-region from the adjusted dark region. The total number of pixels in the first sub-region and the second sub-region is greater than or equal to a second quantity threshold, and the gray value of the first sub-region is less than the gray value of the second sub-region; and according to the number of pixels in the first sub-region, the number of pixels in the second sub-region is reduced, and the reduced number of pixels is evenly distributed to a third sub-region to obtain a new dark region, where the third sub-region is different from the second sub-region.
[0139] It should be noted that for the determination and processing process of the first sub-region and the second sub-region, reference can be made to the determination and processing process of the first region and the second region in the above embodiments, which will not be elaborated here.
[0140] In addition, it should be noted that for the method of adjusting the dark region according to the total number of pixels in the dark sub-region, reference can be made to the method of adjusting the original brightness histogram according to the total number of pixels in the dark region in the above embodiments, which will not be elaborated here.
[0141] 504. The electronic device processes the image to be processed using the new dark region to obtain a new original brightness histogram.
[0142] When an electronic device processes an image to be processed using a new dark area, it may mean that the electronic device maps the new dark area onto the image to be processed to obtain an intermediate image, and then obtains the brightness histogram of the intermediate image, that is, the new original brightness histogram.
[0143] It can be understood that after the electronic device obtains the new dark area, it needs to calculate the cumulative distribution histogram of the new dark area, then obtain the sub-image lookup table corresponding to the dark area based on the cumulative distribution histogram of the new dark area, and finally map the image to be processed based on the sub-image lookup table corresponding to the dark area to obtain the intermediate image.
[0144] It should be noted that for the acquisition of the sub-image lookup table corresponding to the dark area, reference can be made to the introduction of obtaining the image lookup table above, and details will not be elaborated here.
[0145] In addition, it should be noted that the total number of pixels in the new dark area is the same as the total number of pixels in the dark area determined in step 501.
[0146] 505. The electronic device adjusts the new original brightness histogram according to the total number of pixels in the dark area to obtain the target brightness histogram.
[0147] 506. The electronic device processes the image to be processed using the target brightness histogram to obtain the target image.
[0148] It should be noted that for the detailed introduction of steps 505 - 506, reference can be made to the relevant introduction in the above embodiments, and details will not be elaborated here.
[0149] By implementing Figure 5 the method shown, the electronic device first determines the dark area on the original brightness histogram of the image to be processed, and then adjusts the original brightness histogram based on the total number of pixels in the dark area, which helps to maintain the relative brightness relationship between different gray-scale areas in the image. This enables the image to still maintain the original sense of hierarchy and visual balance after adjusting the brightness and contrast, effectively controls the brightness level of the dark part of the image, and thus solves the problem of over-enhanced brightness in the dark part of the image. In addition, the electronic device further adjusts the original brightness histogram adjusted based on the dark area according to the gray-scale distribution of the image to be processed, which can protect the details in the main brightness concentration area of the image. Furthermore, after determining the dark area, the electronic device first subdivides and processes the dark area, which can further effectively protect the details of the dark area.
[0150] Please refer to Figure 6 , Figure 6 which is a structural diagram of an image processing device disclosed in an embodiment of the present application. As Figure 6The illustrated image processing apparatus may include a determination unit 601, an adjustment unit 602, and a processing unit 603; wherein:
[0151] The determination unit 601 is configured to determine a dark region on the original brightness histogram of the image to be processed, and the brightness of the dark region is less than the brightness of the region other than the dark region on the original brightness histogram;
[0152] The adjustment unit 602 is configured to adjust the original brightness histogram according to the total number of pixels in the dark region to obtain a target brightness histogram;
[0153] The processing unit 603 is configured to process the image to be processed by using the target brightness histogram to obtain a target image.
[0154] In some embodiments, the manner in which the adjustment unit 602 adjusts the original brightness histogram according to the total number of pixels in the dark region to obtain a target brightness histogram may specifically include:
[0155] The adjustment unit 602 is configured to adjust the original brightness histogram according to the total number of pixels in the dark region; and determine a first region and a second region from the adjusted original brightness histogram, the total number of pixels in both the first region and the second region is greater than or equal to a first quantity threshold, and the gray value of the first region is less than the gray value of the second region; and reduce the number of pixels in the second region according to the number of pixels in the first region, and evenly distribute the reduced number of pixels to a third region different from the second region to obtain a target brightness histogram.
[0156] In some embodiments, the manner in which the adjustment unit 602 adjusts the original brightness histogram according to the total number of pixels in the dark region may specifically include: the adjustment unit 602 is configured to adjust the original brightness histogram according to the total number of pixels in the dark region and the weight coefficient corresponding to the dark region.
[0157] In some embodiments, the manner in which the adjustment unit 602 reduces the number of pixels in the second region according to the number of pixels in the first region may include:
[0158] The adjustment unit 602 is configured to determine the largest number of pixels from the number of pixels corresponding to each gray value in the first region; and determine a target gray value from the second region, the number of pixels corresponding to the target gray value is greater than m times the largest number of pixels; and reduce the number of pixels corresponding to the target gray value to m times the largest number of pixels, where m is an integer greater than or equal to 1.
[0159] In some embodiments, the manner in which the adjustment unit 602 reduces the number of pixels in the second region according to the number of pixels in the first region may include:
[0160] The adjustment unit 602 is configured to determine the largest total number of pixels from the total number of pixels in at least one first region; and, in the case where the total number of pixels in the second region is greater than n times the largest total number of pixels, reduce the total number of pixels in the second region to n times the largest total number of pixels, where n is an integer greater than or equal to 1.
[0161] In some embodiments, the region other than the dark region includes a middle region and a bright region.
[0162] In some embodiments, the manner in which the processing unit 603 processes the image to be processed using the target brightness histogram to obtain a target image may specifically include:
[0163] The processing unit 603 is configured to calculate a cumulative distribution histogram corresponding to the target brightness histogram according to the target brightness histogram; and calculate an image lookup table according to the cumulative distribution histogram and the gray level of the image to be processed; and map the image to be processed using the image lookup table to obtain a target image.
[0164] In some embodiments, the determination unit 601 is further configured to determine a dark sub-region within the dark region after determining the dark region on the original brightness histogram of the image to be processed, where the brightness of the dark sub-region is less than the brightness of the sub-region other than the dark sub-region in the dark region;
[0165] The adjustment unit 602 is further configured to adjust the dark region according to the total number of pixels in the dark sub-region to obtain a new dark region;
[0166] The processing unit 603 is further configured to process the image to be processed using the new dark region to obtain a new original brightness histogram;
[0167] And the manner in which the adjustment unit 602 adjusts the original brightness histogram according to the total number of pixels in the dark region to obtain a target brightness histogram may specifically include: the adjustment unit 602 is configured to adjust the new original brightness histogram according to the total number of pixels in the dark region to obtain a target brightness histogram.
[0168] In some embodiments, the manner in which the adjustment unit 602 is configured to adjust the dark region according to the total number of pixels in the dark sub-region may specifically include: the adjustment unit 602 is configured to adjust the dark region according to the total number of pixels in the dark sub-region; and, determining a first sub-region and a second sub-region from the adjusted dark region, the total number of pixels in the first sub-region and the second sub-region being greater than or equal to a second quantity threshold, and the gray value of the first sub-region being less than the gray value of the second sub-region; and, reducing the number of pixels in the second sub-region according to the number of pixels in the first sub-region, and equally distributing the reduced number of pixels to a third sub-region to obtain a new dark region, the third sub-region being different from the second sub-region.
[0169] In some embodiments, the manner in which the adjustment unit 602 is configured to adjust the dark region according to the total number of pixels in the dark sub-region may specifically include: the adjustment unit 602 is configured to adjust the dark region according to the total number of pixels in the dark sub-region and the weight coefficient corresponding to the dark sub-region.
[0170] In some embodiments, the manner in which the determination unit 601 is configured to determine the dark region on the original brightness histogram of the image to be processed may specifically include: the determination unit 601 is configured to determine the dark region on the original brightness histogram according to the original brightness histogram of the image to be processed, the total number of pixels of the image to be processed, and the weight coefficient corresponding to the dark region.
[0171] Please refer to Figure 7 , Figure 7 which is a structural diagram of an electronic device disclosed in an embodiment of the present application. As Figure 7 shown, the electronic device may include components such as a processor 701, a memory 702, a display unit 703, an input unit 704, a sensor 705, and an audio circuit 706.
[0172] Among them, the processor 701 is the control center of the electronic device, connecting various parts of the entire electronic device through various interfaces and lines, and by running or executing software programs and / or modules stored in the memory 702, and calling data stored in the memory 702, performing various functions of the electronic device and processing data, so as to perform overall monitoring of the electronic device. Optionally, the processor 701 may include one or more processing units; optionally, the processor 701 may integrate an application processor, and the application processor mainly processes operating systems, user interfaces, and application programs, etc. Of course, other processors may also be included, which will not be listed one by one here.
[0173] The memory 702 can be used to store software programs and modules. The processor 701 executes various functional applications and data processing of the electronic device by running the software programs and modules stored in the memory 702. The memory 702 mainly includes a program storage area and a data storage area. Among them, the program storage area can store the operating device, application programs required for at least one function (such as the sound playback function, the image playback function, etc.); the data storage area can store data created according to the use of the electronic device (such as audio data, phone book, etc.). In addition, the memory 702 can include high-speed random access memory, and can also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage devices.
[0174] The display unit 703 can be used to display information input by the user or information provided to the user, as well as various menus of the electronic device. The display unit 703 can include a display panel. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, a touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it transmits it to the processor 701 to determine the type of touch event. Subsequently, the processor 701 provides a corresponding visual output on the display panel according to the type of touch event. Among them, the touch panel and the display panel are not shown in Figure 7 the figure. The touch panel and the display panel can be implemented as two independent components to realize the input and input functions of the electronic device, or the touch panel and the display panel can be integrated to realize the input and output functions of the electronic device.
[0175] The input unit 704 can be used to receive input digital or character information, and generate key signal inputs related to the user settings and function controls of the electronic device. Specifically, the input unit 704 can include a touch panel and other input devices. The touch panel, also known as a touch screen, can collect touch operations of the user on or near it (such as operations of the user using a finger, a stylus, or any suitable object or accessory on or near the touch panel), and drive the corresponding connection device according to a preset program. In addition, the touch panel can be implemented in multiple types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel, the input unit 704 can also include other input devices. Specifically, the other input devices can include, but are not limited to, function keys (such as volume control buttons, switch buttons, etc.), trackballs, joysticks, etc.
[0176] The electronic device may further include at least one sensor 705, such as a magnetometer, a gyroscope sensor, a motion sensor, and other sensors. Specifically, the magnetometer is used to determine the orientation of the electronic device, and the gyroscope sensor can be used to determine the motion posture of the electronic device, which can be used for anti-shake shooting, and can also be used for navigation and somatosensory game scenarios. As a kind of motion sensor, the acceleration sensor can detect the magnitude of acceleration in all directions, and can detect the magnitude and direction of gravity when stationary, and can be used for applications that identify the posture of the electronic device, such as horizontal and vertical screen switching, related games, and magnetometer posture calibration, etc. As for other sensors such as a pressure gauge, a barometer, a hygrometer, a thermometer, and an infrared sensor that the electronic device may also be configured with, they will not be elaborated here.
[0177] The audio circuit 706 may include a speaker and a microphone, and may provide an audio interface between the user and the electronic device. The audio circuit 706 can transmit the electrical signal converted from the received audio data to the speaker, and the speaker converts it into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 706 and then converted into audio data, and then the audio data is output to the processor 701 for processing, and then sent to another device such as through the video circuit, or the audio data is output to the memory 702 for further processing.
[0178] Although not shown, the electronic device may further include a power supply and a camera. Optionally, the position of the camera on the electronic device can be front-facing or rear-facing, and the embodiments of the present application do not limit this.
[0179] It can be understood that the structure schematically shown in the embodiments of the present application does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown, or combine certain components, or split certain components, or have different component arrangements. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.
[0180] In the embodiments of the present application, the processor 701 further has the following functions:
[0181] Determine the dark area on the original brightness histogram of the image to be processed, where the brightness of the dark area is less than the brightness of the area other than the dark area on the original brightness histogram;
[0182] Adjust the original brightness histogram according to the total number of pixels in the dark area to obtain a target brightness histogram;
[0183] Process the image to be processed using the target brightness histogram to obtain a target image.
[0184] In the embodiments of the present application, the processor 701 further has the following functions:
[0185] Adjust the original brightness histogram according to the total number of pixels in the dark area;
[0186] Determine a first region and a second region from the adjusted original brightness histogram, where the total number of pixels in both the first region and the second region is greater than or equal to a first quantity threshold, and the gray value of the first region is less than the gray value of the second region;
[0187] According to the number of pixels in the first region, reduce the number of pixels in the second region, and evenly distribute the reduced number of pixels to a third region, obtaining a target brightness histogram, where the third region is different from the second region.
[0188] In the embodiment of the present application, the processor 701 further has the following functions:
[0189] Adjust the original brightness histogram according to the total number of pixels in the dark area and the weight coefficient corresponding to the dark area.
[0190] In the embodiment of the present application, the processor 701 further has the following functions:
[0191] Determine the largest number of pixels from the number of pixels corresponding to each gray value within the first region;
[0192] Determine a target gray value from the second region, where the number of pixels corresponding to the target gray value is greater than m times the largest number of pixels;
[0193] Reduce the number of pixels corresponding to the target gray value to m times the largest number of pixels, where m is an integer greater than or equal to 1.
[0194] In the embodiment of the present application, the processor 701 further has the following functions:
[0195] Determine the largest total number of pixels from the total number of pixels in at least one first region;
[0196] In the case where the total number of pixels in the second region is greater than n times the largest total number of pixels, reduce the total number of pixels in the second region to n times the largest total number of pixels, where n is an integer greater than or equal to 1.
[0197] In the embodiment of the present application, the region other than the dark area includes an intermediate area and a bright area.
[0198] In the embodiment of the present application, the processor 701 further has the following functions:
[0199] Calculate the cumulative distribution histogram corresponding to the target brightness histogram according to the target brightness histogram;
[0200] Calculate an image lookup table according to the cumulative distribution histogram and the gray level number of the image to be processed;
[0201] Map the image to be processed by using the image lookup table to obtain a target image.
[0202] In the embodiment of the present application, the processor 701 further has the following functions:
[0203] Determine a dark sub-region within the dark region, where the brightness of the dark sub-region is less than the brightness of the sub-regions other than the dark sub-region in the dark region;
[0204] Adjust the dark region according to the total number of pixels in the dark sub-region to obtain a new dark region;
[0205] Process the image to be processed by using the new dark region to obtain a new original brightness histogram;
[0206] Adjust the new original brightness histogram according to the total number of pixels in the dark region to obtain a target brightness histogram.
[0207] In the embodiment of the present application, the processor 701 further has the following functions:
[0208] Adjust the dark region according to the total number of pixels in the dark sub-region;
[0209] Determine a first sub-region and a second sub-region from the adjusted dark region, where the total number of pixels in the first sub-region and the second sub-region is greater than or equal to a second quantity threshold, and the gray value of the first sub-region is less than the gray value of the second sub-region;
[0210] Reduce the number of pixels in the second sub-region according to the number of pixels in the first sub-region, and evenly distribute the reduced number of pixels to a third sub-region to obtain a new dark region, where the third sub-region is different from the second sub-region.
[0211] In the embodiment of the present application, the processor 701 further has the following functions:
[0212] Adjust the dark region according to the total number of pixels in the dark sub-region and the weight coefficient corresponding to the dark sub-region.
[0213] In the embodiment of the present application, the processor 701 further has the following functions:
[0214] Determine the dark region on the original brightness histogram according to the original brightness histogram of the image to be processed, the total number of pixels of the image to be processed, and the weight coefficient corresponding to the dark region.
[0215] An embodiment of the present application discloses a computer-readable storage medium, on which executable program code is stored. When the executable program code is executed by a processor, the method executed by the electronic device in the embodiment of the present application is implemented.
[0216] An embodiment of the present application discloses a computer program product. When the computer program product runs on a computer, the computer is enabled to implement the method executed by the electronic device in the embodiment of the present application.
[0217] An embodiment of the present application discloses an application publishing platform, which is used to publish a computer program product. When the computer program product runs on a computer, the computer is enabled to implement the method executed by the electronic device in the embodiment of the present application.
[0218] It should be noted here that the descriptions of the above storage medium and device embodiments are similar to those of the above method embodiments and have similar beneficial effects to the method embodiments. For the technical details not disclosed in the storage medium, storage medium and device embodiments of the present application, please refer to the descriptions of the method embodiments of the present application for understanding.
[0219] It should be understood that the term "one embodiment" or "an embodiment" or "some embodiments" mentioned throughout the specification means that a specific feature, structure or characteristic related to the embodiment is included in at least one embodiment of the present application. Therefore, the appearances of "in one embodiment" or "in an embodiment" or "in some embodiments" throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics may be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the order numbers of the above processes do not mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application. The serial numbers of the embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments. The above descriptions of the various embodiments tend to emphasize the differences between the various embodiments. Their similarities or similarities can be referred to each other. For the sake of brevity, they will not be repeated herein.
[0220] The term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, object A and / or object B can represent: object A exists alone, object A and object B exist simultaneously, and object B exists alone.
[0221] It should be noted that, in this article, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising a..." does not exclude the presence of additional identical elements in the process, method, article or device comprising such element.
[0222] In several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The above-described embodiments are merely illustrative. For example, the division of the modules is only a logical function division, and there can be other division methods in actual implementation. For example, multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. Additionally, the coupling, direct coupling, or communication connection between the components shown or discussed with each other can be through some interfaces, and the indirect coupling or communication connection of devices or modules can be electrical, mechanical, or other forms.
[0223] The modules described above as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules; they can be located in one place or distributed to multiple network units; some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0224] In addition, each functional module in the embodiments of this application can be all integrated in a processing unit, or each module can be separately a unit alone, or two or more modules can be integrated in a unit; the above-integrated modules can be implemented in the form of hardware, or in the form of a combination of hardware and software functional units.
[0225] Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps including the above method embodiments; and the foregoing storage medium includes: various media such as removable storage devices, read-only memory (ROM), magnetic disks, or optical discs that can store program codes.
[0226] Alternatively, if the above-integrated units of the present application are implemented in the form of software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the embodiments of the present application, in essence or the part that contributes to the related technology, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing an electronic device to execute all or part of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes such as removable storage devices, ROMs, magnetic disks, or optical discs.
[0227] The methods disclosed in the several method embodiments provided by the present application can be arbitrarily combined without conflict to obtain new method embodiments.
[0228] The features disclosed in the several product embodiments provided by the present application can be arbitrarily combined without conflict to obtain new product embodiments.
[0229] The features disclosed in the several method or device embodiments provided by the present application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0230] As described above, only the embodiments of the present application are provided, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of changes or substitutions, which should all be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. An image processing method, characterized in that: include: Determine a dark region on an original brightness histogram of the image to be processed, wherein a grayscale value of the dark region is smaller than a grayscale value of a region other than the dark region on the original brightness histogram; Adjusting the original brightness histogram according to the total number of pixels in the dark area to obtain a target brightness histogram; The image to be processed is processed using the target brightness histogram to obtain a target image.
2. The method according to claim 1, characterized in that The adjusting the original brightness histogram according to the total number of pixels in the dark area to obtain a target brightness histogram includes: Adjusting the original brightness histogram according to the total number of pixels in the dark area; Determine a first region and a second region from the adjusted original brightness histogram, the total number of pixels in the first region and the second region are both greater than or equal to a first quantity threshold, and the grayscale value of the first region is less than the grayscale value of the second region; According to the number of pixels in the first area, the number of pixels in the second area is reduced, and the reduced number of pixels is evenly distributed to a third area to obtain a target brightness histogram, and the third area is different from the second area.
3. The method according to claim 1 or 2, characterized in that: The adjusting the original brightness histogram according to the total number of pixels in the dark area includes: The original brightness histogram is adjusted according to the total number of pixels in the dark area and the weight coefficient corresponding to the dark area.
4. The method according to claim 2, characterized in that: The reducing the number of pixels in the second area according to the number of pixels in the first area comprises: Determining the maximum number of pixels from the number of pixels corresponding to each gray value in the first area; Determine a target grayscale value from the second area, the number of pixels corresponding to the target grayscale value being greater than m times the maximum number of pixels; The number of pixels corresponding to the target grayscale value is reduced to m times the maximum number of pixels, where m is an integer greater than or equal to 1.
5. The method according to claim 2, characterized in that: The reducing the number of pixels in the second area according to the number of pixels in the first area comprises: Determining a maximum total number of pixels from the total number of pixels of the at least one first region; When the total number of pixels in the second area is greater than n times the maximum total number of pixels, the total number of pixels in the second area is reduced to n times the maximum total number of pixels, where n is an integer greater than or equal to 1.
6. The method according to claim 1, characterized in that The region other than the dark region includes a middle region and a bright region.
7. The method according to claim 1, characterized in that The step of processing the image to be processed by using the target brightness histogram to obtain a target image includes: According to the target brightness histogram, calculating a cumulative distribution histogram corresponding to the target brightness histogram; Calculating an image lookup table according to the cumulative distribution histogram and the grayscale level of the image to be processed; The image to be processed is mapped using the image lookup table to obtain a target image.
8. The method according to claim 1, characterized in that After determining the dark area on the original brightness histogram of the image to be processed, the method further includes: Determine a dark sub-region within the dark region, wherein the brightness of the dark sub-region is lower than the brightness of sub-regions other than the dark sub-region within the dark region; Adjust the dark area according to the total number of pixels in the dark sub-area to obtain a new dark area; Processing the image to be processed using the new dark area to obtain a new original brightness histogram; and, The adjusting the original brightness histogram according to the total number of pixels in the dark area to obtain a target brightness histogram includes: The new original brightness histogram is adjusted according to the total number of pixels in the dark area to obtain a target brightness histogram.
9. The method according to claim 8, characterized in that The step of adjusting the dark region according to the total number of pixels of the dark sub-region to obtain a new dark region includes: Adjusting the dark area according to the total number of pixels in the dark sub-area; Determine a first sub-region and a second sub-region from the adjusted dark region, the total number of pixels in the first sub-region and the second sub-region are both greater than or equal to a second quantity threshold, and the grayscale value of the first sub-region is less than the grayscale value of the second sub-region; According to the number of pixels in the first sub-region, the number of pixels in the second sub-region is reduced, and the reduced number of pixels is evenly distributed to the third sub-region to obtain a new dark region, and the third sub-region is different from the second sub-region.
10. The method according to claim 8 or 9, characterized in that: The adjusting the dark area according to the total number of pixels in the dark sub-area comprises: The dark area is adjusted according to the total number of pixels in the dark sub-area and the weight coefficient corresponding to the dark sub-area.
11. The method according to claim 1, characterized in that: The step of determining a dark area on an original brightness histogram of the image to be processed comprises: The dark area on the original brightness histogram is determined according to the original brightness histogram of the image to be processed, the total number of pixels of the image to be processed and the weight coefficient corresponding to the dark area.
12. An image processing device, characterized in that: include: A determination unit, configured to determine a dark region on an original brightness histogram of an image to be processed, wherein a grayscale value of the dark region is smaller than a grayscale value of a region other than the dark region on the original brightness histogram; An adjustment unit, configured to adjust the original brightness histogram according to the total number of pixels in the dark area to obtain a target brightness histogram; A processing unit is used to process the image to be processed using the target brightness histogram to obtain a target image.
13. An electronic device, characterized in that: include: A memory storing executable program code; and a processor coupled to the memory; The processor calls the executable program code stored in the memory, and when the executable program code is executed by the processor, the processor implements the method according to any one of claims 1 to 11.
14. A computer-readable storage medium having executable program code stored thereon, characterized in that: When the executable program code is executed by a processor, the method according to any one of claims 1 to 11 is implemented.