Brightness adjustment method and device, computer device, and storage medium
By performing cluster analysis and curve fusion on histograms, the image layering problem caused by histogram equalization was solved, achieving a better brightness enhancement effect.
Patent Information
- Application Number
- CN202110356997.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-01
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2041-04-01
AI Technical Summary
In existing technologies, histogram equalization methods are prone to causing image layering during brightness enhancement, which affects the imaging effect.
By performing cluster analysis on the histogram, it is divided into multiple sub-histograms, and the cumulative probability curves of each sub-histogram are fused to obtain a flat brightness adjustment relationship, which is used for image brightness enhancement.
It reduces the layering phenomenon during image brightness enhancement, thus improving the imaging effect.
Smart Images

Figure CN115187492B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing, and in particular to a brightness adjustment method, apparatus, computer device, and storage medium. Background Technology
[0002] The brightness of an image greatly affects the final image quality of a camera.
[0003] During camera imaging, brightness enhancement is performed to process the brightness of the acquired image to achieve a better display effect. Related techniques employ histogram equalization for brightness enhancement. However, this method can easily cause two brightness values that were originally similar to be adjusted to two brightness values that differ significantly, thus resulting in layering. Summary of the Invention
[0004] This application provides a brightness adjustment method, apparatus, computer device, and storage medium, which can optimize the brightness enhancement effect. The technical solution is as follows.
[0005] According to one aspect of this application, a brightness adjustment method is provided, the method comprising:
[0006] Obtain the histogram corresponding to the input image, wherein the histogram is used to characterize the pixel number distribution of brightness values;
[0007] Cluster analysis related to the number of pixels with brightness values is performed on the histogram to obtain K sub-histograms corresponding to K cluster centers. The sub-histograms are used to characterize the distribution of the number of pixels with brightness values belonging to the same class, where K is a positive integer.
[0008] The brightness adjustment relationship is obtained by fusing the K cumulative probability curves corresponding to the K sub-histograms;
[0009] The input image is enhanced in brightness according to the brightness adjustment relationship.
[0010] According to one aspect of this application, a brightness adjustment device is provided, the device comprising: a histogram acquisition module, a cluster analysis module, a curve fusion module, and a brightness enhancement module;
[0011] The histogram acquisition module is used to acquire the histogram corresponding to the input image, and the histogram is used to characterize the pixel number distribution of brightness values;
[0012] The clustering analysis module is used to perform clustering analysis on the histogram related to the number of pixels of brightness value, and obtain K sub-histograms corresponding to K cluster centers. The sub-histograms are used to characterize the distribution of the number of pixels of brightness value belonging to the same class, where K is a positive integer.
[0013] The curve fusion module is used to fuse the K cumulative probability curves corresponding to the K sub-histograms respectively to obtain the brightness adjustment relationship;
[0014] The brightness enhancement module is used to enhance the brightness of the input image according to the brightness adjustment relationship.
[0015] According to another aspect of this application, a computer device is provided, the computer device comprising: a processor and a memory, the memory storing at least one instruction, at least one program, a code set or an instruction set, the at least one instruction, the at least one program, the code set or instruction set being loaded and executed by the processor to implement the brightness adjustment method as described above.
[0016] According to another aspect of this application, a computer-readable storage medium is provided, wherein at least one instruction, at least one program, code set, or instruction set is stored therein, wherein the at least one instruction, the at least one program, the code set, or the instruction set is loaded and executed by a processor to implement the brightness adjustment method as described above.
[0017] According to another aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the brightness adjustment method provided in the above-described optional implementation.
[0018] The beneficial effects of the technical solutions provided in this application include at least the following:
[0019] By performing cluster analysis on the histogram related to the number of pixels in the brightness value, the histogram is transformed into multiple sub-histograms. Each sub-histogram corresponds to the brightness value in which the number of pixels belongs to the same class. Since the number of pixels in the same class is not significantly different, the distribution of the number of pixels in the sub-histograms is relatively uniform. Therefore, the brightness adjustment relationship obtained by fusing the cumulative probability curves of the various sub-histograms is flatter in curve representation than the brightness adjustment relationship obtained by directly calculating the cumulative probability curve of the histogram in related technologies. The original image is enhanced in brightness through this brightness adjustment relationship, and the possibility of layering is smaller, resulting in a better brightness enhancement effect. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart of image signal processing provided in an exemplary embodiment of this application;
[0022] Figure 2 This is a flowchart of a brightness adjustment method provided in an exemplary embodiment of this application;
[0023] Figure 3 This is a schematic diagram illustrating cluster analysis of a histogram provided in an exemplary embodiment of this application;
[0024] Figure 4 This is a schematic diagram illustrating the restriction processing of a sub-histogram provided in an exemplary embodiment of this application;
[0025] Figure 5 This is a schematic diagram of curve merging provided in an exemplary embodiment of this application;
[0026] Figure 6 This is a schematic diagram illustrating a comparison of brightness functions provided in an exemplary embodiment of this application;
[0027] Figure 7 This is a flowchart of a brightness adjustment method provided in an exemplary embodiment of this application;
[0028] Figure 8 This is a flowchart of a brightness adjustment method provided in an exemplary embodiment of this application;
[0029] Figure 9 This is a schematic diagram illustrating the restriction processing of a sub-histogram provided in an exemplary embodiment of this application;
[0030] Figure 10 This is a flowchart of a brightness adjustment method provided in an exemplary embodiment of this application;
[0031] Figure 11 This is a flowchart of a brightness adjustment method provided in an exemplary embodiment of this application;
[0032] Figure 12 This is a block diagram of a brightness adjustment device provided in an exemplary embodiment of this application;
[0033] Figure 13 This is a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application. Detailed Implementation
[0034] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0035] In recent years, cameras have become an indispensable function of mobile devices, and users have increasingly higher demands for camera image quality. Therefore, image quality has become a key area for improvement in mobile devices, and image brightness plays a crucial role in the camera's imaging process, directly determining the final image quality. (Refer to reference...) Figure 1 It illustrates the basic processing flow of Image Signal Processing (ISP).
[0036] Step 101, Image Acquisition.
[0037] Optionally, the camera in the terminal can capture images to obtain raw images.
[0038] Step 102: The acquired raw image is transmitted to the image sensor.
[0039] Optionally, the image sensor includes a charge-coupled device (CCD) and a complementary metal-oxide image sensor (CMOS image sensor, CIS).
[0040] Step 103, digital gain processing.
[0041] Step 104, Raw domain noise reduction.
[0042] Optionally, noise reduction can be performed on the image in the Raw domain, primarily to improve the signal-to-noise ratio of the image.
[0043] Step 105, black level processing.
[0044] Black level is used to define the signal level corresponding to an image data value of 0. Black level processing is used to correct the black level.
[0045] Step 106, Lens shadow correction.
[0046] Due to the inherent physical properties of the lens, the brightness of the image gradually decreases from the center to the periphery, resulting in vignetting at the edges. Specifically, this manifests as a gradual decrease in brightness from the center outwards, with the image becoming darker the further away from the center. Lens shading correction is necessary to compensate for this.
[0047] Lens shadow correction methods calculate the brightness correction value for each pixel using a specific algorithm, thereby compensating for the reduced brightness in the surrounding area. Optionally, correction methods include quadratic correction and quartic correction.
[0048] Step 107: Remove the mosaic.
[0049] Demosaic is mainly used to convert the BAYER data format output by the image sensor into a complete RGB data format that can be seen by the human eye.
[0050] Step 108, color correction.
[0051] Color correction uses matrix operations and is primarily used to adjust the colors of an image.
[0052] Step 109, Brightness Adjustment.
[0053] Step 110, Gamma correction.
[0054] Gamma correction is mainly used to adjust the contrast and brightness of an image. It obtains new pixel values by mapping through a Gamma curve.
[0055] Step 111, color space conversion.
[0056] The image data format is converted from RGB to YUV through color space conversion. YUV is a basic color space, and it is more convenient to perform sharpening and other processing on YUV. Moreover, YUV is more bandwidth-efficient when storing and transmitting data.
[0057] Step 112, sharpen.
[0058] Sharpening is primarily used to improve the clarity of an image.
[0059] Step 113, Display device.
[0060] Depend on Figure 1 It is known that in the basic processing flow of an ISP, brightness adjustment usually occurs after color correction and before gamma correction.
[0061] Brightness enhancement techniques can be broadly categorized into two main types: global brightness adjustment methods and local brightness adjustment methods.
[0062] The most common method for global brightness adjustment is to apply a curve similar to gamma to the image; the most common method for local brightness adjustment is to divide the image into a base layer and a detail layer, then adjust the base layer and the detail layer, and finally superimpose the adjusted base layer and detail layer to obtain a brightness-adjusted result.
[0063] Each of the brightness adjustment methods mentioned above has its own drawbacks. For global adjustment methods, the disadvantage is that there are too many image adjustment parameters, which is not very user-friendly for adjustment work. For local adjustment methods, the implementation complexity is relatively high and they are prone to halo phenomena.
[0064] The histogram equalization provided by related technologies is a global brightness adjustment method. The following is an explanation of histogram equalization:
[0065] For a given image X, its histogram h(x) is defined as follows:
[0066] h(x) = n x
[0067] Where x is the normalized brightness value, and the range of x is [0, 1], n x This represents the number of pixels with a brightness value of x.
[0068] The probability density function p(x) of image brightness can be expressed as:
[0069]
[0070] Where N represents the number of pixels in the image.
[0071] The cumulative density function of an image can be expressed as:
[0072]
[0073] Define a brightness function f(x) to transform the original image to the grayscale range [0, 1] using histogram equalization. The definition of the brightness function is as follows:
[0074] f(x) = c(x)
[0075] The global brightness adjustment methods such as histogram equalization provided by related technologies are prone to causing layering phenomena. For example, if x1 and x2 are brightness values that are adjacent in value, and the probability of x2 appearing in the original image is much greater than the probability of x1 appearing, then c(x2) is much greater than c(x1), resulting in a large difference between the converted f(x2) and f(x1). Therefore, for users who view the image after histogram equalization, the image parts corresponding to brightness f(0) to brightness f(x1) are layered with the image parts corresponding to brightness f(x2) to brightness f(1).
[0076] To address the aforementioned problems, this application provides a clustering-based brightness adjustment method. Below, in conjunction with reference... Figure 2 An illustrative example is provided.
[0077] Figure 2A flowchart illustrating a brightness adjustment method provided in an exemplary embodiment of this application is shown. This method can be applied to a computer device and includes the following steps:
[0078] Step 201, Input image.
[0079] Step 202: Perform histogram statistics.
[0080] Histogram statistics are performed on the input image to obtain histogram H(i). Here, the horizontal axis i represents the normalized brightness value, i is [0, 1], and the vertical axis H(i) represents the number of pixels with brightness value i.
[0081] For example, in conjunction with the reference Figure 3 The histogram obtained by performing histogram statistics on the input image is shown in histogram 301.
[0082] Step 203: Cluster the histogram.
[0083] Using a clustering method, the histogram H(i) is clustered into K sub-histograms, denoted as H(1, i), H(2, i), ..., H(K, i). The K sub-histograms correspond to K cluster centers, denoted as C(0), C(1), ..., C(K).
[0084] Wherein, the cluster center corresponding to the sub-histogram H(k,i) is C(k), and the brightness value i1 belongs to the sub-histogram H(k,i), which means that the number of pixels H(i1) corresponding to the brightness value is the shortest distance from c(k) among the K cluster centers. Therefore, the brightness value i1 is clustered into the class corresponding to the sub-histogram H(k,i).
[0085] For example, in conjunction with the reference Figure 3 Histogram 301 is clustered to obtain four sub-histograms: sub-histogram 302, sub-histogram 303, sub-histogram 304 and sub-histogram 305. The above four sub-histograms are denoted as H(1,i), H(2,i), H(3,i) and H(4,i), respectively.
[0086] Step 204: Perform multi-scale curve calculation.
[0087] Multiscale curve calculation includes the following steps: restricting each sub-histogram and calculating the cumulative probability curve of each sub-histogram.
[0088] Restriction processing refers to truncating the number of pixels in the sub-histogram that are above a certain threshold, and then distributing the truncated portion evenly among the number of pixels corresponding to each brightness value.
[0089] Understandably, the threshold value for the number of sub-histograms will be different for different sub-histograms.
[0090] For example, the threshold for the number of sub-histograms 302 is th1, which is obtained after constraint processing. Figure 4 Sub-histogram 401 is denoted as H_clip(1, i); the threshold for the number of sub-histograms 303 is th2, and the result is obtained after constraint processing. Figure 4 Sub-histogram 402 is denoted as H_clip(2, i); the threshold for the number of sub-histograms 304 is th3, and the result is obtained after constraint processing. Figure 4 Sub-histogram 403 is denoted as H_clip(3, i); the threshold for the number of sub-histograms 305 is th4, and after constraint processing, we obtain... Figure 4 The sub-histogram 404 in the image is denoted as H_clip(4,i).
[0091] Taking sub-histogram 401 as an example, the restriction process is performed according to the following formula. The processing method for other sub-histograms is similar.
[0092]
[0093]
[0094]
[0095] Where th1 is the threshold number corresponding to sub-histogram 401, and L is the total number of brightness values.
[0096] The cumulative probability curve is the integral of the probability density function, used to characterize the probability distribution of brightness values.
[0097] For example, the cumulative probability curve corresponding to sub-histogram 401 is as follows: Figure 5 As shown in Figure 501, denoted as cdf(1, i); the cumulative probability curve corresponding to sub-histogram 402 is as follows: Figure 5 As shown in Figure 502, denoted as cdf(2, i); the cumulative probability curve corresponding to sub-histogram 403 is as follows: Figure 5 As shown in Figure 503, denoted as cdf(3, i); the cumulative probability curve corresponding to sub-histogram 404 is as follows Figure 5 As shown in Figure 504, it is denoted as cdf(4,i).
[0098] Taking sub-histogram 401 as an example, the cumulative probability curve is calculated using the following formula. The calculation method for the cumulative probability curve of other histograms is similar.
[0099] cdf(1,0)=0
[0100]
[0101] Where L is the total number of brightness values.
[0102] Step 205: Merge the curves.
[0103] Curve merging refers to using a fusion coefficient to merge the cumulative probability curves of individual sub-histograms into a single fused curve. The fusion coefficient corresponding to sub-histogram H(k,i) is denoted as w. k W1+W2+…+W K =1.
[0104] The cumulative probability curves are fused according to the following formula to obtain the fused curve cdf(i).
[0105]
[0106] Where K is the number of clusters, w k Let H(k,i) be the fusion weight corresponding to the defined sub-histogram H(k,i), and let cdf(k,i) be the cumulative probability curve corresponding to the sub-histogram H(k,i).
[0107] For example, for Figure 5 Figures 501, 502, 503, and 504 are merged to obtain the fused figure 505.
[0108] Step 206: Adjust the brightness.
[0109] To better highlight details in dark areas, the blending curve is adjusted according to the following formula to obtain the brightness function.
[0110]
[0111] Here, dark_ratio and dark_area are set parameters used to control the degree of brightening in dark areas and the range of brightness to be brightened, respectively.
[0112] The brightness function f(i) calculated above is applied to the input image to obtain the image with enhanced brightness.
[0113] img en =f(img in )
[0114] Step 207: Output the image.
[0115] Output the image with enhanced brightness.
[0116] In the method provided in this application embodiment, the brightness function obtained by fusing the cumulative probability curves of each sub-histogram is flatter in curve representation compared to the brightness function obtained by directly calculating the cumulative probability curve of the histogram in related technologies. The original image is then enhanced using this brightness function, reducing the likelihood of layering. For example... Figure 6As shown, the brightness function corresponding to the embodiment of this application is curve 601, while the brightness function corresponding to histogram equalization in related technologies is curve 602. Curve 601 is flatter than curve 602.
[0117] It is understood that the brightness function in this embodiment is a function used to adjust the brightness value of an image. The brightness function can also be understood as a brightness adjustment relationship. In the following embodiments, the use of a "brightness adjustment relationship" to adjust brightness will be further illustrated by example.
[0118] The following embodiments will further illustrate a cluster-based brightness adjustment method provided in this application.
[0119] Figure 7 A flowchart illustrating a brightness adjustment method provided in an exemplary embodiment of this application is shown. This method can be applied to a computer device and may include:
[0120] Step 701: Obtain the histogram corresponding to the input image. The histogram is used to represent the distribution of the number of pixels of brightness value.
[0121] Optionally, the computer device captures an image using a camera (such as a camera) to obtain an input image, processes the input image, and obtains a histogram corresponding to the input image.
[0122] A histogram is a graphical representation of data distribution; it is a two-dimensional statistical chart where the two axes represent the statistical sample and the measure of a specific attribute corresponding to that sample, respectively. In this embodiment, the horizontal axis of the histogram represents the image's brightness value, and the vertical axis represents the number of pixels corresponding to that brightness value, such as... Figure 3 As shown in Figure 301.
[0123] Step 702: Perform cluster analysis on the histogram related to the number of pixels with brightness values to obtain K sub-histograms corresponding to K cluster centers.
[0124] Among them, the sub-histogram is used to characterize the distribution of the number of pixels belonging to the same brightness value, where K is a positive integer.
[0125] Cluster analysis, also known as clustering, is an analytical method that classifies similar objects into different classes, so that objects within the same class have similar attributes. In this embodiment, brightness values belonging to the same class can be understood as brightness values belonging to the same group. In this embodiment, cluster analysis related to the number of pixels in brightness values refers to grouping brightness values with similar numbers of pixels into the same class, with each class represented by a sub-histogram.
[0126] In the embodiments of this application, each class / sub-histogram corresponds to a cluster center, which is a value used to characterize the number of pixels in the class / sub-histogram.
[0127] Understandably, clustering a histogram into several sub-histograms can be viewed as dividing the histogram into different scales. For example, referring to the reference... Figure 3 Histogram 301 was clustered to obtain four sub-histograms: sub-histogram 302, sub-histogram 303, sub-histogram 304, and sub-histogram 305. From Figure 3 As can be seen, the number of pixels in sub-histogram 302 is mostly concentrated in the range of 2*10^2. 5 Up to 2.5*10^ 5 The number of pixels in sub-histogram 303 is mostly concentrated in the range of 4*10^ 5 Up to 4.5*10^ 5 The number of pixels in sub-histogram 304 is mostly concentrated in the range of 6*10^ 5 The number of pixels in sub-histogram 305 is mostly concentrated between 0 and 6*10^ 4 .
[0128] Optionally, the clustering analysis methods include, but are not limited to, any of the following: K-means clustering, mean-shift clustering, density-based spatial clustering of applications with noise (DBSCAN), expectation-maximum clustering using a Gaussian mixture model, agglomerative hierarchical clustering, and graph community detection. This application does not limit the specific methods used for clustering analysis.
[0129] Optionally, the number K of sub-histograms can be a pre-set fixed value or can be dynamically adjusted according to different images. This application embodiment does not limit this.
[0130] Step 703: Fuse the K cumulative probability curves corresponding to the K sub-histograms to obtain the brightness adjustment relationship.
[0131] Optionally, after obtaining K sub-histograms, the computer device calculates K cumulative probability curves corresponding to the K sub-histograms, and fuses the K cumulative probability curves to obtain the brightness adjustment relationship.
[0132] The cumulative probability curve is obtained by integrating the probability density function of the pixel number distribution of the brightness values shown in the sub-histogram.
[0133] It is understandable that, since multiple sub-histograms divide the histogram at different scales, the multiple cumulative probability curves in this embodiment are multi-scale brightness adjustment curves. Therefore, the brightness adjustment relationship obtained by fusing multiple cumulative probability curves can achieve a better adjustment effect.
[0134] Step 704: Enhance the brightness of the input image according to the brightness adjustment relationship.
[0135] Optionally, the brightness values of the input image can be processed using brightness adjustment relationships to enhance the brightness of the input image.
[0136] In summary, the method provided in this embodiment transforms the histogram into multiple sub-histograms by performing cluster analysis on the histogram related to the number of pixels in the brightness value. Each sub-histogram corresponds to the brightness value in which the number of pixels belongs to the same class. Since the number of pixels in the same class is not significantly different, the distribution of the number of pixels in the sub-histograms is relatively uniform. Therefore, the brightness adjustment relationship obtained by fusing the cumulative probability curves of the various sub-histograms is flatter in curve representation than the brightness adjustment relationship obtained by directly calculating the cumulative probability curve of the histogram in related technologies. The original image is enhanced in brightness through this brightness adjustment relationship, with a lower possibility of layering, resulting in a better brightness enhancement effect.
[0137] In an illustrative embodiment, multiple cumulative probability curves corresponding to multiple sub-histograms are fused by fusion weights.
[0138] Figure 8 A flowchart illustrating a brightness adjustment method provided in an exemplary embodiment of this application is shown. This method can be applied to a computer device and may include:
[0139] Step 801: Obtain the histogram corresponding to the input image. The histogram is used to represent the distribution of the number of pixels of brightness value.
[0140] The implementation method for this step can be found in step 701 above, and will not be repeated here.
[0141] Step 802: Perform cluster analysis on the histogram related to the number of pixels with brightness values to obtain K sub-histograms corresponding to K cluster centers.
[0142] The implementation method for this step can be found in step 702 above, and will not be repeated here.
[0143] Step 803: Obtain the K cumulative probability curves corresponding to the K sub-histograms, and the K fusion weights corresponding to the K sub-histograms.
[0144] Optionally, after obtaining the K sub-histograms, the computer device calculates the K cumulative probability curves corresponding to the K sub-histograms and obtains the K fusion weights.
[0145] Optionally, the K fusion weights are fixed values preset in the computer device, or they can be dynamically adjusted according to different images; this embodiment does not limit this. Optionally, the sum of the K fusion weights is 1.
[0146] In one possible implementation, before calculating the cumulative probability curves corresponding to the sub-histograms, the histograms need to be constrained to avoid over-enhancing the image. That is, obtaining the K cumulative probability curves corresponding to the K sub-histograms includes:
[0147] (1) Restrict the K sub-histograms respectively to obtain the restricted K sub-histograms.
[0148] Among them, the restriction processing refers to the processing method of truncating the number of pixels in the sub-histogram using a number threshold.
[0149] Optionally, the restriction process includes the following steps: For any one of the K sub-histograms, obtain the corresponding number threshold for the sub-histogram, adjust the target pixel count to the number threshold, where the target pixel count is the number of pixels in the sub-histogram that are greater than the number threshold; distribute the sum of the restricted pixel counts of the sub-histogram evenly to the pixel counts corresponding to each brightness value of the sub-histogram to obtain the restricted sub-histogram; wherein, the sum of the restricted pixel counts is the sum of the pixel counts obtained by subtracting the number threshold from the total number of target pixels in the sub-histogram.
[0150] For example, a sub-histogram is as follows Figure 9 As shown in (a), this sub-histogram corresponds to a number threshold, such as Figure 9 As shown in (b) above. The number of pixels in the sub-histogram exceeding a certain threshold is truncated, as shown below. Figure 9 As shown in (c) above. The truncated portion is evenly distributed across the brightness values, as follows: Figure 9 As shown in (d) in the figure.
[0151] (2) Using the K sub-histograms after restriction processing, calculate the K cumulative probability curves corresponding to the K sub-histograms respectively.
[0152] Step 804: Calculate the brightness adjustment relationship based on K cumulative probability curves and K fusion weights.
[0153] Optionally, the computer device multiplies the cumulative probability curve with its corresponding fusion weight to obtain the fusion cumulative probability curve, and then adds the K fusion cumulative probability curves together to obtain the brightness adjustment relationship.
[0154] Step 805: Enhance the brightness of the input image according to the brightness adjustment relationship.
[0155] The implementation method for this step can be found in step 704 above, and will not be repeated here.
[0156] In summary, the method provided in this embodiment, after performing cluster analysis on the histogram to obtain sub-histograms, performs restriction processing on the sub-histograms, truncating the portion of the sub-histograms that exceeds a certain number threshold, and evenly distributing it to each brightness value. This can prevent noise from being excessively amplified and improve the display effect of the image.
[0157] In an illustrative embodiment, in order to further enhance the brightness of dark areas of the image, the computer device adjusts the brightness adjustment relationship after calculating it.
[0158] Figure 10 A flowchart illustrating a brightness adjustment method provided in an exemplary embodiment of this application is shown. This method can be applied to a computer device and may include:
[0159] Step 1001: Obtain the histogram corresponding to the input image. The histogram is used to represent the distribution of the number of pixels of brightness value.
[0160] The implementation method for this step can be found in step 701 above, and will not be repeated here.
[0161] Step 1002: Perform cluster analysis on the histogram related to the number of pixels with brightness values to obtain K sub-histograms corresponding to K cluster centers.
[0162] The implementation method for this step can be found in step 702 above, and will not be repeated here.
[0163] Step 1003: Fuse the K cumulative probability curves corresponding to the K sub-histograms to obtain the brightness adjustment relationship.
[0164] The implementation method for this step can be found in step 703 above, and will not be repeated here.
[0165] Step 1004: Multiply the first brightness adjustment relationship by the brightening parameter to obtain the adjusted first brightness adjustment relationship.
[0166] The brightness adjustment relationships include: a first brightness adjustment relationship and a second brightness adjustment relationship. The first brightness adjustment relationship corresponds to the portion of brightness values less than the threshold value, and the second brightness adjustment relationship corresponds to the portion of brightness values not less than the threshold value.
[0167] For an image, the portion below the brightness threshold can be considered the dark area. Computer devices can further brighten the dark areas of the image by multiplying the first brightness adjustment relationship corresponding to the portion below the brightness threshold by a brightening parameter.
[0168] Optionally, the brightness threshold value ranges from 0.2 to 0.5. Optionally, the brightness threshold value can be a fixed value preset in the computer device, or it can be dynamically adjusted according to different images; this application embodiment does not limit this.
[0169] Optionally, the value range of the brightening parameter is 2 to 8. Optionally, the brightening parameter can be a fixed value preset in the computer device, or it can be dynamically adjusted according to different images. This application embodiment does not limit this.
[0170] Step 1005: Combine the adjusted first brightness adjustment relationship and the second brightness adjustment relationship to obtain the adjusted brightness adjustment relationship.
[0171] For example, as shown in the following formula, the brightness adjustment relationship obtained by fusing K cumulative probability curves is denoted as cdf(i), the brightness value threshold is 0.3, the brightening parameter is 5, and the first brightness adjustment relationship corresponding to the part with brightness value less than 0.3 is multiplied by 5 so that the adjusted brightness adjustment relationship f(i) supports further brightening of the part with brightness value less than 0.3 in the image.
[0172]
[0173] Step 1006: Enhance the brightness of the input image according to the adjusted brightness adjustment relationship.
[0174] Optionally, the brightness values of the input image can be processed using the adjusted brightness adjustment relationship to enhance the brightness of the input image.
[0175] In summary, the method provided in this embodiment, after fusing multiple cumulative probability curves to obtain a brightness adjustment relationship, multiplies the first brightness adjustment relationship corresponding to the portion below the brightness value threshold by a brightening parameter. This allows the adjusted brightness adjustment relationship to further brighten the dark areas of the image, better preserve details in the dark areas, and improve the image display effect.
[0176] In an illustrative embodiment, the computer device uses K-means clustering to perform cluster analysis on the histogram.
[0177] Figure 11 This application illustrates a flowchart of a K-means clustering method for a histogram, provided by an exemplary embodiment of the present application. The method can be applied in a computer device and includes:
[0178] Step 1101: Obtain K cluster centers.
[0179] Optionally, the initial K cluster centers can be randomly set by the computer equipment, or set according to certain setting principles.
[0180] Step 1102: For any brightness value in the histogram, calculate the K distances between the number of pixels of the brightness value and the K cluster centers.
[0181] The distance between the number of pixels with brightness values and the cluster center refers to the numerical difference between the number of pixels with brightness values and the cluster center.
[0182] For example, there are 3 cluster centers, namely: C(1) = 8 * 10^ 4 C(2) = 2 * 10^ 5 C(3) = 8 * 10^ 5 The distance from the number of pixels with brightness values to the cluster center is calculated, and the calculation results are referenced in Table 1 below:
[0183] Table 1
[0184]
[0185] Step 1103: Based on the K distances, cluster the brightness value and the number of pixels of the brightness value into the class corresponding to the target cluster center. The target cluster center is the cluster center corresponding to the shortest distance among the K distances.
[0186] Optionally, for any brightness value in the histogram, after calculating the K distances between the number of pixels of that brightness value and the K cluster centers, the computer device determines the shortest distance among the K distances and clusters the brightness value and the number of pixels of that brightness value into the class corresponding to the shortest distance.
[0187] For example, referring to Table 1 above, the shortest distance is 1*10^ 5 Therefore, H(0.5) = 3 * 10^ 5 Clustering to cluster centers C(2) = 2 * 10^ 5 In the corresponding class.
[0188] Step 1104: Calculate the updated K cluster centers based on the K classes.
[0189] In one possible implementation, the computer device calculates updated K cluster centers based on K classes, including: for any one of the K classes, calculating the mean number of pixels belonging to that class; and using the mean as the cluster center corresponding to the updated class.
[0190] Step 1105: Determine whether the updated K cluster centers meet the clustering termination condition.
[0191] If the updated K cluster centers meet the clustering termination condition, proceed to step 1106; if the updated K cluster centers do not meet the clustering termination condition, jump to step 1102 and start looping.
[0192] Optionally, the computer device stores a threshold number of clustering attempts. The loop execution requires that the current clustering attempt count is less than the threshold. If the updated K cluster centers do not meet the clustering termination condition, and the clustering attempt count reaches the threshold, then step 1106 is executed; if the updated K cluster centers do not meet the clustering termination condition, and the clustering attempt count does not reach the threshold, then the process jumps to step 1102 to begin the loop execution.
[0193] In one possible implementation, the clustering termination condition includes: the sum of the K center deviations is less than the center deviation threshold; where the center deviation is the square of the difference between the cluster centers before and after the update.
[0194] Optionally, the center deviation threshold can be a fixed value preset in the computer device, or it can be dynamically adjusted according to different images. This application embodiment does not limit this.
[0195] Step 1106: Based on the K classes, obtain K sub-histograms corresponding to the updated K cluster centers.
[0196] Optionally, the computer device may graphically represent each class, resulting in K sub-histograms.
[0197] In summary, the method provided in this embodiment performs cluster analysis on histograms using K-means clustering, which is simple to implement, reduces the complexity of clustering on computer devices, and reduces computational overhead.
[0198] It is understood that the above method embodiments can be implemented individually or in combination, and the embodiments of this application do not impose any restrictions on this.
[0199] The following are device embodiments of this application. For details not described in detail in the device embodiments, please refer to the corresponding descriptions in the above method embodiments. They will not be repeated here.
[0200] Figure 12 A schematic diagram of a brightness adjustment device provided in an exemplary embodiment of this application is shown. This device can be implemented as all or part of a computer device through software, hardware, or a combination of both. The device includes: a histogram acquisition module 1201, a cluster analysis module 1202, a curve fusion module 1203, and a brightness enhancement module 1204.
[0201] The histogram acquisition module 1201 is used to acquire the histogram corresponding to the input image, and the histogram is used to characterize the pixel number distribution of brightness values;
[0202] The clustering analysis module 1202 is used to perform clustering analysis on the histogram related to the number of pixels of brightness value, and obtain K sub-histograms corresponding to K cluster centers. The sub-histograms are used to characterize the distribution of the number of pixels of brightness value belonging to the same class, where K is a positive integer.
[0203] The curve fusion module 1203 is used to fuse the K cumulative probability curves corresponding to the K sub-histograms respectively to obtain the brightness adjustment relationship;
[0204] The brightness enhancement module 1204 is used to enhance the brightness of the input image according to the brightness adjustment relationship.
[0205] In an optional embodiment, the curve fusion module 1203 is used to obtain K cumulative probability curves corresponding to the K sub-histograms and K fusion weights corresponding to the K sub-histograms; and to calculate the brightness adjustment relationship based on the K cumulative probability curves and the K fusion weights.
[0206] In an optional embodiment, the curve fusion module 1203 is used to perform constraint processing on the K sub-histograms respectively to obtain the K sub-histograms after constraint processing; and to calculate the K cumulative probability curves corresponding to the K sub-histograms respectively using the K sub-histograms after constraint processing; wherein, the constraint processing refers to the processing method of truncating the number of pixels in the sub-histograms using a number threshold.
[0207] In an optional embodiment, the curve fusion module 1203 is configured to, for any one of the K sub-historical maps, obtain a number threshold corresponding to the sub-historical map, adjust the target pixel count to the number threshold, wherein the target pixel count is the number of pixels in the sub-historical map that are greater than the number threshold; and evenly distribute the sum of the restricted pixel counts of the sub-historical maps to the pixel counts corresponding to each brightness value of the sub-historical map to obtain the restricted sub-historical map; wherein the sum of the restricted pixel counts is the sum of the pixel counts obtained by subtracting the number threshold from the total number of target pixels in the sub-historical map.
[0208] In an optional embodiment, the brightness adjustment relationship includes a first brightness adjustment relationship and a second brightness adjustment relationship. The device further includes a relationship adjustment module. The relationship adjustment module is used to multiply the first brightness adjustment relationship by a brightening parameter to obtain an adjusted first brightness adjustment relationship; and to combine the adjusted first brightness adjustment relationship and the second brightness adjustment relationship to obtain an adjusted brightness adjustment relationship. The brightness enhancement module 1204 is used to enhance the brightness of the input image according to the adjusted brightness adjustment relationship. The first brightness adjustment relationship corresponds to the portion of the brightness value less than a brightness value threshold, and the second brightness adjustment relationship corresponds to the portion of the brightness value not less than the brightness value threshold.
[0209] In an optional embodiment, the cluster analysis includes: K-means cluster analysis;
[0210] The clustering analysis module 1202 is used to obtain the K cluster centers; for any brightness value in the histogram, calculate K distances between the number of pixels of the brightness value and the K cluster centers; based on the K distances, cluster the brightness value and the number of pixels of the brightness value into the class corresponding to the target cluster center, where the target cluster center is the cluster center corresponding to the shortest distance among the K distances; calculate the updated K cluster centers based on the K classes; and in response to the updated K cluster centers satisfying the clustering termination condition, obtain the K sub-histograms corresponding to the updated K cluster centers based on the K classes.
[0211] In an optional embodiment, the clustering analysis module 1202 is configured to, in response to the updated K cluster centers not satisfying the clustering termination condition and the number of clustering operations being less than a threshold, cyclically execute the calculation of the K distances between the number of pixels of any brightness value in the histogram and the K cluster centers.
[0212] In an optional embodiment, the clustering termination condition includes: the sum of the K center deviations is less than a center deviation threshold; wherein the center deviation is the square of the difference between the cluster centers before the update and the cluster centers after the update.
[0213] In an optional embodiment, the clustering analysis module 1202 is used to calculate the mean number of pixels belonging to any one of the K classes; and use the mean as the cluster center corresponding to the updated class.
[0214] Figure 13This is a schematic diagram of the structure of a computer device provided in one embodiment of this application. Specifically, the computer device 1300 includes a Central Processing Unit (CPU) 1301, a system memory 1304 including Random Access Memory (RAM) 1302 and Read-Only Memory (ROM) 1303, and a system bus 1305 connecting the system memory 1304 and the CPU 1301. The computer device 1300 also includes a basic input / output system (I / O system) 1306 that facilitates the transmission of information between various devices within the computer, and a mass storage device 1307 for storing the operating system 1313, application programs 1314, and other program modules 1315.
[0215] The basic input / output system 1306 includes a display 1308 for displaying information and an input device 1309, such as a mouse or keyboard, for entering information into a user account. Both the display 1308 and the input device 1309 are connected to the central processing unit 1301 via an input / output controller 1310 connected to the system bus 1305. The basic input / output system 1306 may also include the input / output controller 1310 for receiving and processing input from multiple other devices such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1310 also provides output to a display screen, printer, or other types of output devices.
[0216] Mass storage device 1307 is connected to central processing unit 1301 via a mass storage controller (not shown) connected to system bus 1305. Mass storage device 1307 and its associated computer-readable media provide non-volatile storage for computer device 1300. That is, mass storage device 1307 may include computer-readable media (not shown) such as hard disk or compact disc read-only memory (CD-ROM) drive.
[0217] Without loss of generality, computer-readable media can include computer storage media and communication media. Computer storage media includes volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media include RAM, ROM, erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other solid-state storage technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape cassettes, magnetic tape, disk storage, or other magnetic storage devices. Of course, those skilled in the art will recognize that computer storage media are not limited to the above-mentioned types. The system memory 1304 and mass storage device 1307 described above can be collectively referred to as memory.
[0218] According to various embodiments of this application, the computer device 1300 can also be connected to a remote computer on a network, such as the Internet. That is, the computer device 1300 can be connected to the network 1312 via the network interface unit 1311 connected to the system bus 1305, or the network interface unit 1311 can be used to connect to other types of networks or remote computer systems (not shown).
[0219] This application also provides a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set, which is loaded and executed by a processor to implement the brightness adjustment method provided in the above-described method embodiments.
[0220] This application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the brightness adjustment method provided in the above-described optional implementation.
[0221] It should be understood that "multiple" as used in this article refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0222] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware, or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0223] The above are merely optional embodiments of this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A luminance adjustment method characterized by comprising: The method comprises: obtaining a histogram corresponding to an input image, the histogram being used to represent a distribution of pixel numbers of luminance values; performing cluster analysis on the histogram in relation to the pixel numbers of luminance values to obtain K sub-histograms corresponding to K cluster centers, the sub-histograms being used to represent a distribution of pixel numbers of luminance values to which pixel numbers belong to the same class, K being a positive integer; performing limiting processing on the K sub-histograms respectively to obtain the K sub-histograms after limiting processing, the limiting processing referring to a processing mode of truncating the pixel numbers in the sub-histograms using a number threshold; using the K sub-histograms after limiting processing, calculating K cumulative probability curves corresponding to the K sub-histograms respectively; obtaining K fusion weights corresponding to the K sub-histograms respectively; based on the K cumulative probability curves and the K fusion weights, calculating a luminance adjustment relationship; performing luminance enhancement on the input image according to the luminance adjustment relationship.
2. The method of claim 1, wherein, The performing limiting processing on the K sub-histograms respectively to obtain the K sub-histograms after limiting processing comprises: for any one of the K sub-histograms, obtaining a number threshold corresponding to the sub-histogram, adjusting a target pixel number to the number threshold, the target pixel number being a pixel number greater than the number threshold in the sub-histogram; averaging a total of limited pixel numbers of the sub-histogram and distributing the total of limited pixel numbers to pixel numbers corresponding to respective luminance values of the sub-histogram to obtain the sub-histogram after limiting processing; wherein the total of limited pixel numbers is a total of pixel numbers obtained by subtracting the number threshold from all the target pixel numbers in the sub-histogram.
3. The method of claim 2, wherein, The luminance adjustment relationship comprises a first luminance adjustment relationship and a second luminance adjustment relationship, and the method further comprises: multiplying the first luminance adjustment relationship by a brightening parameter to obtain an adjusted first luminance adjustment relationship; combining the adjusted first luminance adjustment relationship and the second luminance adjustment relationship to obtain an adjusted luminance adjustment relationship; The performing luminance enhancement on the input image according to the luminance adjustment relationship comprises: performing luminance enhancement on the input image according to the adjusted luminance adjustment relationship. The first luminance adjustment relationship is a relationship corresponding to a part less than a luminance value threshold, and the second luminance adjustment relationship is a relationship corresponding to a part not less than the luminance value threshold.
4. The method of claim 2, wherein, The cluster analysis comprises K-means clustering. The performing cluster analysis on the histogram in relation to the pixel numbers of luminance values to obtain K sub-histograms corresponding to K cluster centers comprises: obtaining the K cluster centers; for any one of the luminance values in the histogram, calculating K distances between the pixel number of the luminance value and the K cluster centers; according to the K distances, clustering the luminance value and the pixel number of the luminance value into a class corresponding to a target cluster center, the target cluster center being a cluster center corresponding to the shortest distance in the K distances; based on the K classes, calculate updated K cluster centers; in response to the updated K cluster centers satisfying a clustering end condition, based on the K classes, obtain K sub-histograms corresponding to the updated K cluster centers.
5. The method of claim 4, wherein, The method further comprises: in response to the updated K cluster centers not satisfying the clustering end condition and the number of clustering being less than a number threshold, start a loop of calculating K distances between the number of pixels of any one of the luminance values in the histogram and the K cluster centers.
6. The method of claim 5, wherein the clustering end condition comprises: a value obtained by adding K center deviations being less than a center deviation threshold; and wherein the center deviation is a square of a difference between the cluster center before updating and the cluster center after updating. The method further comprises: for any one of the K classes, calculate a mean value of the number of pixels belonging to the class; 7. The method of claim 4, wherein, use the mean value as a cluster center corresponding to the class after updating. The device comprises a histogram obtaining module, a clustering analysis module, a curve fusion module, and a luminance enhancement module. The histogram obtaining module is configured to obtain a histogram corresponding to an input image, the histogram being used to represent a distribution of the number of pixels of luminance values.
8. A luminance adjusting apparatus characterized by comprising: The clustering analysis module is configured to perform clustering analysis on the histogram related to the number of pixels of luminance values, to obtain K sub-histograms corresponding to K cluster centers, the sub-histograms being used to represent a distribution of the number of pixels of luminance values belonging to the same class, and K being a positive integer. The curve fusion module is configured to perform limiting processing on the K sub-histograms respectively, to obtain the K sub-histograms after limiting processing, the limiting processing being a processing manner of truncating the number of pixels in the sub-histograms using a number threshold; calculate K cumulative probability curves corresponding to the K sub-histograms respectively using the K sub-histograms after limiting processing; obtain K fusion weights corresponding to the K sub-histograms respectively; and calculate a luminance adjustment relationship based on the K cumulative probability curves and the K fusion weights. The luminance enhancement module is configured to perform luminance enhancement on the input image according to the luminance adjustment relationship. The computer device comprises a processor and a memory, the memory storing at least one instruction, at least one program, a code set, or an instruction set, the at least one instruction, the at least one program, the code set, or the instruction set being loaded and executed by the processor to implement the luminance adjustment method of any one of claims 1 to 7. The storage medium stores at least one instruction, at least one program, a code set, or an instruction set, the at least one instruction, the at least one program, the code set, or the instruction set being loaded and executed by the processor to implement the luminance adjustment method of any one of claims 1 to 7.
9. A computer device, comprising: 10. A computer-readable storage medium, characterized in that, 11. A computer program product, characterised in that, The computer program product comprises computer instructions stored in a computer readable storage medium, the computer instructions are loaded and executed by a processor from the computer readable storage medium to realize the brightness adjustment method as claimed in any one of claims 1 to 7.
Citation Information
Patent Citations
Image enhancement algorithm based on gauss hybrid model
CN103914811A