Image brightness adjusting method and device, electronic equipment and medium
By analyzing the texture regularity and edge sharpness features of images, and using the gray-level co-occurrence matrix energy value and Laplacian variance to determine the brightness adjustment strategy, the problem of distinguishing between dark images and low-light images is solved, achieving accurate brightness adjustment and avoiding erroneous adjustments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-19
- Publication Date
- 2026-03-27
AI Technical Summary
Existing technology cannot effectively distinguish between dark images under normal lighting and normal images under low lighting, leading to incorrect brightness adjustments.
By analyzing the texture regularity and edge sharpness features of the image, the image brightness adjustment strategy is determined using the gray-level co-occurrence matrix energy value and Laplacian variance, including enhancing or keeping the image brightness unchanged.
It achieves precise brightness adjustment in different low-light scenes, avoids erroneous brightness adjustments, and ensures the artistic expression and recognition effect of the image.
Smart Images

Figure CN121746262A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to an image brightness adjustment method, apparatus, electronic device, and medium. Background Technology
[0002] With the development of artificial intelligence technology, intelligent terminal devices such as picture book robots and intelligent vision terminals are increasingly acquiring information through built-in image acquisition units to achieve functions such as content recognition and human-computer interaction. To ensure the effectiveness of subsequent applications, preprocessing the acquired images, especially ensuring they have appropriate brightness, is a crucial prerequisite for realizing these functions.
[0003] Currently, a standard automatic adjustment scheme based on brightness thresholds is commonly used. After acquiring an input image, a smart terminal detects a low brightness value and determines that the current environment is low-light, automatically performing brightness enhancement processing on the image. However, in real-world applications, some images are predominantly dark in tone. Even under normal lighting conditions, these dark images will result in a low detected brightness value. Because existing automatic adjustment schemes based on brightness thresholds cannot effectively distinguish these dark images, incorrect brightness adjustments can occur. Summary of the Invention
[0004] This invention provides an image brightness adjustment method, apparatus, electronic device, and medium to solve the problem in the prior art that it is impossible to effectively distinguish between dark images under normal lighting and normal images under low lighting, thus leading to incorrect brightness adjustment.
[0005] This invention provides an image brightness adjustment method, the method comprising: Acquire an input image and determine the average brightness of the input image; If the average brightness of the image is detected to be less than the lower limit of brightness, the texture regularity features and edge sharpness features of the input image are determined. Based on the texture regularity features and the edge sharpness features, an image brightness adjustment strategy for the input image is determined, and the image brightness of the input image is adjusted according to the image brightness adjustment strategy.
[0006] According to an image brightness adjustment method provided by the present invention, determining the texture regularity features and edge sharpness features of the input image includes: Determine the gray-level co-occurrence matrix energy value of the input image, and use the gray-level co-occurrence matrix energy value as the texture regularity feature of the input image; The Laplacian variance of the input image is determined, and the Laplacian variance is used as the edge sharpness feature of the input image.
[0007] According to an image brightness adjustment method provided by the present invention, the step of determining the image brightness adjustment strategy of the input image based on the texture regularity features and the edge sharpness features includes: If the energy value of the gray-level co-occurrence matrix is less than the first energy threshold and the Laplacian variance is less than the first variance threshold, the image brightness adjustment strategy of the input image is determined to be image brightness enhancement. If the energy value of the gray-level co-occurrence matrix is less than the first energy threshold, but the Laplacian variance is greater than the first variance threshold, the image brightness adjustment strategy for the input image is determined to be to keep the image brightness unchanged. When the gray-level co-occurrence matrix energy value is greater than a first energy threshold, but the Laplacian variance is less than a first variance threshold, the image brightness adjustment strategy of the input image is determined based on the gray-level co-occurrence matrix energy value and a second energy threshold; wherein, the second energy threshold is greater than the first energy threshold. If the energy value of the gray-level co-occurrence matrix is greater than the first energy threshold and the Laplacian variance is greater than the first variance threshold, the image brightness adjustment strategy for the input image is determined to be to keep the image brightness unchanged.
[0008] According to an image brightness adjustment method provided by the present invention, when the gray-level co-occurrence matrix energy value is greater than a first energy threshold, but the Laplacian variance is less than a first variance threshold, determining an image brightness adjustment strategy for the input image based on the gray-level co-occurrence matrix energy value and a second energy threshold includes: If the energy value of the gray-level co-occurrence matrix is greater than the first energy threshold, but the Laplace variance is less than the first variance threshold, determine whether the energy value of the gray-level co-occurrence matrix is greater than the second energy threshold. If the energy value of the gray-level co-occurrence matrix is greater than the second energy threshold, the image brightness adjustment strategy for the input image is determined to be to keep the image brightness unchanged. If the energy value of the gray-level co-occurrence matrix is not greater than the second energy threshold, the image brightness adjustment strategy of the input image is determined to be image brightness enhancement.
[0009] According to an image brightness adjustment method provided by the present invention, when the image brightness adjustment strategy of the input image is image brightness enhancement, the step of adjusting the image brightness of the input image according to the image brightness adjustment strategy includes: Determine the deviation between the lower limit of brightness and the average brightness of the image, and determine the compensation coefficient corresponding to the input image; Based on the deviation and the compensation coefficient, the compensated brightness is determined, and the target brightness is determined based on the compensated brightness and the average brightness of the image. The gamma value is determined based on the target brightness and the average brightness of the image; The input image is then enhanced in brightness based on the gamma value.
[0010] According to an image brightness adjustment method provided by the present invention, determining the gray-level co-occurrence matrix energy value of the input image includes: Determine the gray-level co-occurrence matrix of the input image; The gray-level co-occurrence matrix energy value of the input image is determined based on the sum of squares of all element values in the gray-level co-occurrence matrix.
[0011] According to an image brightness adjustment method provided by the present invention, determining the Laplacian variance of the input image includes: The input image is convolved using the Laplacian operator to generate a response image; The Laplacian variance of the input image is determined based on the variance of all pixel values in the response image.
[0012] The present invention also provides an image brightness adjustment device, the device comprising: An image acquisition module is used to acquire an input image and determine the average brightness of the input image; A brightness detection module is used to determine the ambient light intensity of the input image when the average brightness of the image is detected to be less than a lower brightness limit; the ambient light intensity is determined based on the illumination component separated from the input image. A brightness adjustment module is used to determine the image brightness adjustment strategy of the input image when the ambient light intensity is less than a second threshold.
[0013] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the image brightness adjustment method as described above.
[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the image brightness adjustment method as described above.
[0015] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the image brightness adjustment method as described above.
[0016] The image brightness adjustment method provided by this invention does not immediately perform brightness adjustment when the average brightness of the image is detected to be low. Instead, it further analyzes the texture regularity features and edge sharpness features of the image. These two features can reflect the essential attributes of the image. By combining the analysis of these two dimensions of features, the reasons for the low average brightness of the image can be effectively distinguished. In this way, a targeted image brightness adjustment strategy can be formulated to achieve image brightness adjustment for different low brightness scenes, effectively avoiding erroneous brightness adjustment. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0018] Figure 1 This is one of the flowcharts illustrating the image brightness adjustment method provided in this embodiment of the invention.
[0019] Figure 2 This is the second flowchart illustrating the image brightness adjustment method provided in this embodiment of the invention.
[0020] Figure 3 This is the third flowchart illustrating the image brightness adjustment method provided in this embodiment of the invention.
[0021] Figure 4 This is the fourth flowchart of the image brightness adjustment method provided in the embodiments of the present invention.
[0022] Figure 5 This is a schematic diagram of the image brightness adjustment device provided in an embodiment of the present invention.
[0023] Figure 6 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0025] Most existing smart terminal devices are equipped with image acquisition units, such as cameras or webcams, to enable data input and facilitate the development of subsequent application functions. Compared to traditional keyboard or manual input, image acquisition units allow smart terminal devices to collect data in more ways, thereby enriching their application functions and expanding their application scope.
[0026] In practical applications of intelligent terminal devices such as picture book robots and intelligent vision terminals, distinguishing between dark images under normal lighting and normal images under low lighting is a current technical challenge. Because the average brightness values of both normal images under low lighting and dark images under normal lighting are relatively low, they cannot be easily distinguished, making it impossible to determine whether the image truly needs brightness enhancement. Enhancing the brightness of dark images under normal lighting would disrupt the original design atmosphere, leading to distorted artistic expression and color deviations from the original settings; conversely, if normal images under low lighting are not enhanced in time, they will fail to be recognized due to hidden details and insufficient contrast, directly affecting the use of picture book reading, content interaction, and other functions.
[0027] Based on this, this invention proposes an image brightness adjustment method. Through in-depth analysis of image content, it achieves intelligent adjustment of low-brightness images, avoids incorrect brightness adjustment of dark images, and also ensures that normal images that are blurry due to insufficient ambient light can be adjusted in a timely and effective manner.
[0028] Figure 1 This is one of the flowcharts illustrating the image brightness adjustment method provided by the present invention, such as... Figure 1 As shown, the method includes the following steps 110, 120 and 130.
[0029] Step 110: Acquire the input image and determine the average brightness of the input image.
[0030] In this embodiment, the input image to be processed is first acquired. Here, the input image can be acquired in real time by an image acquisition device, or it can be a pre-stored image read from a local storage device or a cloud server. The format of the input image can be RGB, YUV, RAW, etc., and there are no restrictions on this.
[0031] After acquiring the input image, the overall brightness of the image is calculated, i.e., the average brightness of the image is determined. Specifically, the average brightness of the image can be obtained by calculating the arithmetic mean of the brightness values of all pixels in the image.
[0032] In one example, if the input image is a color image, such as in RGB format, it can be converted to grayscale first, and then the average grayscale value of all pixels can be calculated. In another example, the average grayscale value of all pixels can also be calculated in other color spaces, such as YUV, for example, by directly extracting and calculating the average value of all pixel values of the luminance component or lightness component, thus obtaining the average image luminance that characterizes the overall image brightness level.
[0033] Step 120: If the average brightness of the image is detected to be less than the lower limit of brightness, determine the texture regularity features and edge sharpness features of the input image.
[0034] In this embodiment, a lower limit value for brightness is preset to distinguish whether the image is in a low-light state. The lower limit value for brightness can be a fixed value set based on experience, for example, within a brightness range of 0-255, it can be set to 60, 70 or 80, etc., or it can be an adaptive value that can be customized by the user according to needs or dynamically adjusted according to different application scenarios.
[0035] When the average brightness of the image is detected to be less than the lower limit of brightness, it indicates that the input image is currently in a dark state and further image analysis is needed based on texture regularity features and edge sharpness features. If the average brightness of the image is not less than the lower limit of brightness, it indicates that the image brightness is within an acceptable range and no adjustment is needed, thereby effectively avoiding unnecessary calculations for images with normal brightness and saving system resources.
[0036] Here, texture regularity features are used to describe the orderliness and repetition of pixel arrangement and grayscale distribution in an image, which characterizes the structural regularity of the image content.
[0037] In one example, a 3×3 or 5×5 neighborhood can be selected centered on each pixel in the image. The gray value of each pixel in the neighborhood is compared with the gray value of the center pixel. If the gray value is greater than the center pixel, it is recorded as 1; otherwise, it is recorded as 0, forming a binary LBP code. Finally, the frequency of different LBP codes in the entire image is counted to form an LBP histogram, thus obtaining the texture regularity features of the input image. Typically, in normal images under low light, the LBP codes of stroke edges and character outlines have obvious repetitive patterns, and the histogram will show concentrated peaks; while the LBP codes of dark images under normal lighting conditions are dispersed and have no obvious peaks.
[0038] In one example, a gray-level co-occurrence matrix can be constructed by statistically analyzing the frequency of gray-level value combinations of adjacent pixels at a certain distance or angle in an image. Then, quantitative indicators reflecting regularity can be extracted from the gray-level co-occurrence matrix, such as energy and correlation. Energy reflects the uniformity of gray-level distribution; the higher the regularity of the image, the higher the energy value. Correlation reflects the degree of gray-level association between adjacent pixels; the character arrangement and stroke distribution of text have strong correlation, and the correlation index is more significant, thus obtaining the texture regularity features of the input image.
[0039] Here, edge sharpness features are used to describe the sharpness and contrast of the boundaries between different regions in an image, which characterizes the recognizability of image detail contours.
[0040] In one example, the sharpness of edges can be quantified by calculating the gradient values of pixel grayscale; the larger the gradient value, the sharper the edge. For instance, gradient operators such as Sobel, Prewitt, and Canny can be used to perform convolution operations on the grayscale input image, and the average gradient magnitude or edge pixel proportion of the entire image can be statistically analyzed to obtain the edge sharpness features of the input image. Typically, normal images under low light conditions have low gradient values due to insufficient illumination, but the edge pixel proportion is usually within the normal range; while dark images under normal lighting conditions will exhibit low average gradient values and dispersed edge pixel proportions, lacking continuous high gradient regions.
[0041] In one example, the Laplacian operator can be applied to a grayscale image to obtain a Laplacian response image. The variance of the response image can then be calculated to obtain the edge sharpness features of the input image. Generally, images with sharp edges, such as those under normal lighting, have a larger variance in their Laplacian response values; images under low lighting have a smaller variance.
[0042] Step 130: Determine the image brightness adjustment strategy for the input image based on the texture regularity feature and the edge sharpness feature, and adjust the image brightness of the input image according to the image brightness adjustment strategy.
[0043] After obtaining the texture regularity features and edge sharpness features of the input image, the reasons for the low average brightness of the input image are further analyzed based on these features. After analyzing the reasons for the low average brightness of the image, the matching image brightness adjustment strategy is then executed.
[0044] For example, if the input image has both low texture regularity and low edge sharpness, the low average brightness of the input image may be due to poor real lighting conditions, and the determined brightness adjustment strategy should be to enhance the image brightness; if the input image has low average brightness but high texture regularity and high edge sharpness, the low average brightness of the input image may be due to the image design itself, such as an image with a dark style, and the brightness adjustment strategy should be to keep the image brightness unchanged.
[0045] After determining the image brightness adjustment strategy, the input image is adjusted accordingly. For example, if the strategy is to keep the image brightness unchanged, the original input image is directly output. If the strategy is to enhance the image brightness, the corresponding image processing algorithm is called to improve the brightness. For example, brightness enhancement can be achieved through linear pixel value mapping, non-linear gamma correction, or histogram equalization. The specific method can be determined based on application requirements and is not limited thereto.
[0046] The image brightness adjustment method provided in this invention does not immediately perform brightness adjustment when the average brightness of the image is detected to be low. Instead, it further analyzes the texture regularity features and edge sharpness features of the image. These two features can reflect the essential attributes of the image. By combining the analysis of these two dimensions of features, the reasons for the low average brightness of the image can be effectively distinguished. In this way, a targeted image brightness adjustment strategy can be formulated to achieve image brightness adjustment for different low brightness scenes, effectively avoiding erroneous brightness adjustment.
[0047] In some embodiments, reference Figure 2 , Figure 2 This is a second schematic flowchart of the image brightness adjustment method provided in this embodiment of the invention, as shown below. Figure 2 As shown, the method includes the following steps 210 and 220.
[0048] Step 210: Determine the gray-level co-occurrence matrix energy value of the input image, and use the gray-level co-occurrence matrix energy value as the texture regularity feature of the input image; It should be understood that the Gray Level Co-occurrence Matrix (GLCM) is a matrix used to describe the texture features of an image. It quantifies the texture regularity features of an image by statistically analyzing the distribution of gray values of pixel pairs with specific spatial relationships in the image.
[0049] The gray-level co-occurrence matrix energy value is a texture index calculated based on the gray-level co-occurrence matrix, reflecting the uniformity of the gray-level distribution and the coarseness of the texture in an image.
[0050] It should be noted that the energy value of the gray-level co-occurrence matrix is positively correlated with the concentration of texture distribution. If the image texture is regular and the pixel gray-level values are concentrated, the gray-level co-occurrence matrix will exhibit the characteristic of a few elements having large values and most elements being close to 0, thus the energy value of the gray-level co-occurrence matrix will be high. If the image texture is messy and the gray-level values are scattered, the element values in the gray-level co-occurrence matrix will be evenly distributed and relatively small, thus the energy value of the gray-level co-occurrence matrix will be low.
[0051] In some embodiments, determining the gray-level co-occurrence matrix energy value of the input image includes: Determine the gray-level co-occurrence matrix of the input image; The gray-level co-occurrence matrix energy value of the input image is determined based on the sum of squares of all element values in the gray-level co-occurrence matrix.
[0052] Specifically, based on the pixel gray levels of the input image, the probability of two pixel gray values appearing simultaneously at a specific direction and distance is statistically analyzed to construct a gray-level co-occurrence matrix (GLCM). This GLCM reflects comprehensive information about the image's gray levels regarding direction, adjacent spacing, and variation amplitude. Next, the value of each element in the GLCM is squared, and all squared values are summed to obtain the GLCM energy value of the image.
[0053] Step 220: Determine the Laplacian variance of the input image and use the Laplacian variance as the edge sharpness feature of the input image.
[0054] In this embodiment, in order to detect whether an image contains clear edge information, the Laplacian operator is used to calculate the Laplacian variance of the input image. The Laplacian operator is an image edge detection operator that responds to the edges and details in the image by calculating the second derivative of the gray value of the image pixels.
[0055] Here, the Laplacian variance is used to statistically analyze the dispersion of edge response values. If the image is clear, the response values in the edge region are large and concentrated, while the response values in the non-edge region are close to 0, and the difference between the two is significant, resulting in a high variance value. If the image is blurry, the edge response values are generally small and evenly distributed, and the difference between them and the non-edge region is not obvious, resulting in a low variance value.
[0056] Specifically, by utilizing the sharpness representation capability of Laplacian variance, we can distinguish between dark images under normal lighting and normal images under low lighting. Although dark images under normal lighting have low overall brightness, their edges are still sharp, resulting in a higher Laplacian variance value. In contrast, normal images under low lighting suffer from insufficient light, leading to the loss of edge details and smooth grayscale transitions, resulting in a lower Laplacian variance value.
[0057] In some embodiments, determining the Laplacian variance of the input image includes: The input image is convolved using the Laplacian operator to generate a response image; The Laplacian variance of the input image is determined based on the variance of all pixel values in the response image.
[0058] Specifically, a predefined Laplacian operator is used to perform a convolution operation on the input image, and the convolved image is used as the response image. The Laplacian operator is a two-dimensional matrix, such as a 3×3 two-dimensional matrix. The convolution operation slides this Laplacian operator across the input image. At each position, the value in the Laplacian operator is multiplied by the corresponding pixel value in the image, and the sum is obtained to obtain the pixel value at that position in the response image.
[0059] Here, the pixel value of each pixel in the response image numerically represents the second derivative of the gray level of the corresponding pixel in the original input image, thus reflecting the degree of drastic change in the gray level value at that point.
[0060] After generating the response image, the total number of all pixels in the response image is counted first, and the average value of all pixel response values is calculated. Then, the squared difference between each pixel response value and the average value is calculated in turn. Finally, the average of all squared differences is calculated, which is the Laplacian variance. This Laplacian variance is the quantized edge sharpness feature.
[0061] The image brightness adjustment method provided in this embodiment of the invention uses the gray-level co-occurrence matrix energy value as a texture regularity feature and the Laplacian variance as an edge sharpness feature, providing specific quantitative indicators for the accurate determination of subsequent brightness adjustment strategies, thereby improving the accuracy and robustness of brightness adjustment.
[0062] In some embodiments, reference Figure 3 , Figure 3 This is the third flowchart illustrating the image brightness adjustment method provided in this embodiment of the invention, as shown below. Figure 3 As shown, the method includes the following steps 310, 320, 330 and 340.
[0063] Step 310: If the energy value of the gray-level co-occurrence matrix is less than the first energy threshold and the Laplacian variance is less than the first variance threshold, determine that the image brightness adjustment strategy of the input image is image brightness enhancement.
[0064] Here, the first energy threshold is a pre-set threshold, which can be a fixed threshold or dynamically set according to the text font size of the input image.
[0065] In one example, sample images containing normal images under low light and dark images under normal light can be pre-constructed. After converting all sample images to grayscale, the gray-level co-occurrence matrix energy value is calculated according to a preset pixel spacing and a preset angle. The distribution patterns of the gray-level co-occurrence matrix energy values of normal images under low light and dark images under normal light are statistically derived. Then, the upper limit of the intersection of the distribution intervals of the gray-level co-occurrence matrix energy values of the two types of sample images is selected as the initial energy threshold. Afterwards, through confusion matrix verification, if the misclassification ratio of normal images under low light is too high, the initial energy threshold is lowered; if the misclassification ratio of dark images under normal light is too high, the initial energy threshold is raised. Finally, a first energy threshold with accurate segmentation is obtained.
[0066] In one example, a preset energy threshold for matching text font size can be pre-set based on historical experience. After receiving the input image, the size of the text font in the input image is determined. If the text font size of the input image is smaller than the preset text font size, the gray-level co-occurrence matrix energy value of the small-font text will be lower than that of the large-font text because the strokes are finer and the pixel ratio is lower. Therefore, the threshold is lowered based on the preset energy threshold, and the adjusted energy threshold is used as the first energy threshold corresponding to the input image. Similarly, if the text font size of the input image is larger than the preset text font size, the energy value of the large-font text will be higher than that of the small-font text because the strokes are thicker and the structure is more regular. Therefore, the threshold is higher based on the preset energy threshold, and the adjusted energy threshold is used as the first energy threshold corresponding to the input image.
[0067] Here, the first variance threshold is a pre-set threshold, which can be a fixed threshold or dynamically set according to the image resolution of the input image.
[0068] In one example, sample images containing normal images under low light and dark images under normal light can be pre-constructed. After converting all sample images to grayscale, convolution operations are performed on the grayscale sample images according to the Laplacian operator. After normalization, the Laplacian variance is calculated, and the Laplacian variance distribution patterns of normal images under low light and dark images under normal light are statistically obtained. Then, the upper limit of the intersection of the distribution intervals of the Laplacian variances of the two types of sample images is selected as the initial variance threshold. Afterwards, the confusion matrix is used for verification. If the misclassification ratio of normal images under low light is too high, the initial variance threshold is lowered; if the misclassification ratio of dark images under normal light is too high, the initial variance threshold is raised. Finally, the first variance threshold with accurate segmentation is obtained.
[0069] In one example, a preset variance threshold matching a preset image resolution can be pre-set based on historical experience. After receiving the input image, the image resolution of the input image is determined. If the image resolution of the input image is less than the preset image resolution, the Laplacian variance is lower because the low-resolution image has fewer pixel details and edge information is easily compressed. In this case, the threshold is lowered based on the preset variance threshold, and the adjusted Laplacian variance is used as the first variance threshold corresponding to the input image. Similarly, if the image resolution of the input image is greater than the preset image resolution, the Laplacian variance is relatively higher because the high-resolution image has more pixel details and more complete edge information. In this case, the threshold is higher based on the preset variance threshold, and the adjusted Laplacian variance is used as the first variance threshold corresponding to the input image.
[0070] In this embodiment, after determining the gray-level co-occurrence matrix energy, Laplacian variance, and corresponding threshold of the input image, if the gray-level co-occurrence matrix energy value of the input image is less than the first energy threshold and the Laplacian variance is less than the first variance threshold, it indicates that the input image has messy texture and unclear edges. That is, the input image is dark and blurry, and the texture complexity is high. Therefore, it is characterized as a normal image under low light. Thus, the corresponding image brightness adjustment strategy is image brightness enhancement.
[0071] Step 320: If the gray-level co-occurrence matrix energy value is less than the first energy threshold, but the Laplacian variance is greater than the first variance threshold, determine that the image brightness adjustment strategy for the input image is to keep the image brightness unchanged.
[0072] If the gray-level co-occurrence matrix energy value of the input image is less than the first energy threshold, but the Laplacian variance is greater than the first variance threshold, it indicates that although the input image has messy texture, there are obvious sharp edges in the image. Images under low light usually have blurred edges. Therefore, it means that this input image is a dark image with irregular texture but clear edges under normal lighting. If the image content is a forest, seabed, etc., then in this case, the input image does not need to be enhanced in brightness, and the image brightness can be kept unchanged.
[0073] Step 330: If the gray-level co-occurrence matrix energy value is greater than the first energy threshold, but the Laplacian variance is less than the first variance threshold, determine the image brightness adjustment strategy of the input image based on the gray-level co-occurrence matrix energy value and the second energy threshold; wherein the second energy threshold is greater than the first energy threshold.
[0074] If the gray-level co-occurrence matrix energy value of the input image is detected to be greater than the first energy threshold, but the Laplacian variance is less than the first variance threshold, it indicates that although the input image has regular texture, the image edges are blurred. In this case, the blurred image edges may be due to the image design itself or insufficient lighting. Therefore, in this embodiment, a second energy threshold is further used for secondary judgment.
[0075] Here, the second energy threshold is a higher threshold than the first energy threshold, used for differentiation.
[0076] In one example, sample images containing sharp edges under low light and blurred edges under normal light can be pre-constructed. After converting all sample images to grayscale, the gray-level co-occurrence matrix (GLCM) energy value is calculated according to a preset pixel spacing and preset angle. The distribution patterns of GLCM energy values for sharp edges under low light and blurred edges under normal light are statistically derived. Generally, the GLCM energy value of sharp edges under low light is higher than that of sharp edges under normal light. Therefore, the critical segmentation point between the distribution ranges of GLCM energy values of the two types of sample images is selected as the initial energy threshold. Then, through confusion matrix verification, if the misclassification ratio of sharp edges under low light is too high, the initial energy threshold is increased; if the misclassification ratio of blurred edges under normal light is too high, the initial energy threshold is decreased, finally obtaining a second energy threshold with accurate segmentation.
[0077] Step 340: If the gray-level co-occurrence matrix energy value is greater than the first energy threshold and the Laplacian variance is greater than the first variance threshold, determine that the image brightness adjustment strategy of the input image is to keep the image brightness unchanged.
[0078] If the gray-level co-occurrence matrix energy value of the input image is detected to be greater than the first energy threshold and the Chelatv variance is greater than the first variance threshold, it indicates that the input image has clear texture and obvious sharp edges. Therefore, it means that the input image is a dark image with regular texture and clear edges under normal lighting. In this case, there is no need to enhance the brightness of the input image; it is sufficient to keep the image brightness unchanged.
[0079] The image brightness adjustment method provided in this invention achieves accurate decision-making on whether the input image needs brightness adjustment by using a dual threshold combination of gray-level co-occurrence matrix energy value and Laplacian variance.
[0080] In some embodiments, reference Figure 4 , Figure 4 This is the fourth flowchart illustrating the image brightness adjustment method provided in this embodiment of the invention, as shown below. Figure 4As shown, the method includes the following steps 410, 420 and 430.
[0081] Step 410: If the gray-level co-occurrence matrix energy value is greater than the first energy threshold, but the Laplace variance is less than the first variance threshold, determine whether the gray-level co-occurrence matrix energy value is greater than the second energy threshold.
[0082] Step 420: If the energy value of the gray-level co-occurrence matrix is greater than the second energy threshold, determine that the image brightness adjustment strategy of the input image is to keep the image brightness unchanged.
[0083] Step 430: If the energy value of the gray-level co-occurrence matrix is not greater than the second energy threshold, determine that the image brightness adjustment strategy of the input image is image brightness enhancement.
[0084] In this embodiment, when the energy value of the gray-level co-occurrence matrix is greater than the first energy threshold, but the Laplace variance is less than the first variance threshold, the energy value of the gray-level co-occurrence matrix is judged a second time by the second energy threshold.
[0085] Specifically, if the gray-level co-occurrence matrix energy value of the input image exceeds a higher second energy threshold, even if the edges are blurred, it indicates that the image is under normal lighting conditions. In this case, the blurred edges are due to the image's design itself, such as a dark image with regular texture but unclear edges. Therefore, there is no need to enhance the brightness of the input image; simply keep the brightness unchanged. If the gray-level co-occurrence matrix energy value of the input image exceeds the first energy threshold but does not exceed the higher second energy threshold, it indicates that the blurred edges may be due to a low-light environment. Therefore, it is necessary to enhance the brightness of the input image to improve its clarity.
[0086] The image brightness adjustment method provided in this embodiment of the invention, for input images with regular textures but blurry edges, introduces a higher second energy threshold for secondary judgment, so as to accurately distinguish between dark images with regular textures but unclear edges under normal lighting and normal images under low lighting, thereby avoiding incorrect brightness adjustment of dark images, and also ensuring that normal images that are blurry due to insufficient ambient light can be adjusted in a timely and effective manner.
[0087] In some embodiments, when the image brightness adjustment strategy of the input image is image brightness enhancement, adjusting the image brightness of the input image according to the image brightness adjustment strategy includes: Determine the deviation between the lower limit of brightness and the average brightness of the image, and determine the compensation coefficient corresponding to the input image; Based on the deviation and the compensation coefficient, the compensated brightness is determined, and the target brightness is determined based on the compensated brightness and the average brightness of the image. The gamma value is determined based on the target brightness and the average brightness of the image; The input image is then enhanced in brightness based on the gamma value.
[0088] In this embodiment, the deviation between the lower limit of brightness and the average brightness of the image is first calculated. This deviation reflects the degree to which the image needs to be brightened. Then, the compensation coefficient corresponding to this input image is determined. Here, the compensation coefficient can be a fixed value that has been set in advance, or it can be flexibly adjusted according to other image features, such as the brightness variance of the image. There is no restriction on this.
[0089] After determining the deviation and compensation coefficient of the input image, the deviation and compensation coefficient are multiplied to obtain the compensated brightness. Then, the compensated brightness and the average brightness of the image are added together to obtain the target brightness.
[0090] After obtaining the target brightness, the target brightness value and the average image brightness are normalized. Then, based on the ratio between the normalized target brightness value and the average image brightness, the gamma value is determined, such as... γ =log( Lavg ) / log( Ltarget ),in, Lavg This represents the normalized average brightness of the image. Ltarget This represents the normalized target brightness value. Finally, a non-linear transformation is applied to the brightness value of each pixel in the input image using gamma values to enhance brightness.
[0091] It should be understood that the formula for gamma correction is: I trans (x,y)= I norm (x,y) γ ; Therefore, when the normalized average brightness of the image is less than the normalized target brightness value, the gamma value... γ Less than 1, and I norm (x, y) represents the normalized pixel value, which is between 0 and 1, therefore the gamma value γ The smaller the value, the better the calculation result. I trans The larger (x,y) is, the brighter the input image will be.
[0092] The image brightness adjustment method provided in this invention determines the target brightness by combining the image brightness deviation and the feature compensation coefficient, then calculates the gamma value and performs a nonlinear transformation to achieve adaptive brightness enhancement of the image, thereby improving the overall brightness while avoiding overexposure in bright areas and loss of detail in dark areas.
[0093] Based on any of the above embodiments, the present invention also provides an image brightness adjustment device, with reference to... Figure 5 The device includes: Image acquisition module 510 is used to acquire an input image and determine the average brightness of the input image; The brightness detection module 520 is used to determine the ambient light intensity of the input image when the average brightness of the image is detected to be less than the lower limit of brightness; the ambient light intensity is determined based on the illumination component separated from the input image. The brightness adjustment module 530 is used to determine the image brightness adjustment strategy of the input image when the ambient light intensity is less than a second threshold.
[0094] The image brightness adjustment device provided in this embodiment of the invention does not immediately perform brightness adjustment when the average brightness of the image is detected to be low. Instead, it further analyzes the texture regularity features and edge sharpness features of the image. These two features can reflect the essential attributes of the image. By combining the analysis of these two dimensions of features, the reasons for the low average brightness of the image can be effectively distinguished. In this way, a targeted image brightness adjustment strategy can be formulated to achieve image brightness adjustment for different low brightness scenes, effectively avoiding erroneous brightness adjustment.
[0095] Figure 6 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 6 As shown, the electronic device may include: a processor 610, a communications interface 620, a memory 630, and a communication bus 640, wherein the processor 610, the communications interface 620, and the memory 630 communicate with each other via the communication bus 640. The processor 610 can call logical instructions in the memory 630 to execute an image brightness adjustment method, the method including: Acquire an input image and determine the average brightness of the input image; If the average brightness of the image is detected to be less than the lower limit of brightness, the texture regularity features and edge sharpness features of the input image are determined. Based on the texture regularity features and the edge sharpness features, an image brightness adjustment strategy for the input image is determined, and the image brightness of the input image is adjusted according to the image brightness adjustment strategy.
[0096] Furthermore, the logical instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0097] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program that can be stored on a non-transitory computer-readable storage medium, wherein when the computer program is executed by a processor, the computer is capable of executing the image brightness adjustment methods provided by the above methods, the method comprising: Acquire an input image and determine the average brightness of the input image; If the average brightness of the image is detected to be less than the lower limit of brightness, the texture regularity features and edge sharpness features of the input image are determined. Based on the texture regularity features and the edge sharpness features, an image brightness adjustment strategy for the input image is determined, and the image brightness of the input image is adjusted according to the image brightness adjustment strategy.
[0098] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the image brightness adjustment method provided by the methods described above, the method comprising: Acquire an input image and determine the average brightness of the input image; If the average brightness of the image is detected to be less than the lower limit of brightness, the texture regularity features and edge sharpness features of the input image are determined. Based on the texture regularity features and the edge sharpness features, an image brightness adjustment strategy for the input image is determined, and the image brightness of the input image is adjusted according to the image brightness adjustment strategy.
[0099] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0100] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0101] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An image brightness adjustment method, characterized in that, The method includes: Acquire an input image and determine the average brightness of the input image; If the average brightness of the image is detected to be less than the lower limit of brightness, the texture regularity features and edge sharpness features of the input image are determined. Based on the texture regularity features and the edge sharpness features, an image brightness adjustment strategy for the input image is determined, and the image brightness of the input image is adjusted according to the image brightness adjustment strategy.
2. The image brightness adjustment method according to claim 1, characterized in that, The determination of the texture regularity features and edge sharpness features of the input image includes: Determine the gray-level co-occurrence matrix energy value of the input image, and use the gray-level co-occurrence matrix energy value as the texture regularity feature of the input image; The Laplacian variance of the input image is determined, and the Laplacian variance is used as the edge sharpness feature of the input image.
3. The image brightness adjustment method according to claim 2, characterized in that, The step of determining the image brightness adjustment strategy for the input image based on the texture regularity features and the edge sharpness features includes: If the energy value of the gray-level co-occurrence matrix is less than the first energy threshold and the Laplacian variance is less than the first variance threshold, the image brightness adjustment strategy of the input image is determined to be image brightness enhancement. If the energy value of the gray-level co-occurrence matrix is less than the first energy threshold, but the Laplacian variance is greater than the first variance threshold, the image brightness adjustment strategy for the input image is determined to be to keep the image brightness unchanged. When the gray-level co-occurrence matrix energy value is greater than a first energy threshold, but the Laplacian variance is less than a first variance threshold, the image brightness adjustment strategy of the input image is determined based on the gray-level co-occurrence matrix energy value and a second energy threshold; wherein, the second energy threshold is greater than the first energy threshold. If the energy value of the gray-level co-occurrence matrix is greater than the first energy threshold and the Laplacian variance is greater than the first variance threshold, the image brightness adjustment strategy for the input image is determined to be to keep the image brightness unchanged.
4. The image brightness adjustment method according to claim 3, characterized in that, When the gray-level co-occurrence matrix energy value is greater than a first energy threshold, but the Laplacian variance is less than a first variance threshold, determining the image brightness adjustment strategy for the input image based on the gray-level co-occurrence matrix energy value and a second energy threshold includes: If the energy value of the gray-level co-occurrence matrix is greater than the first energy threshold, but the Laplace variance is less than the first variance threshold, determine whether the energy value of the gray-level co-occurrence matrix is greater than the second energy threshold. If the energy value of the gray-level co-occurrence matrix is greater than the second energy threshold, the image brightness adjustment strategy for the input image is determined to be to keep the image brightness unchanged. If the energy value of the gray-level co-occurrence matrix is not greater than the second energy threshold, the image brightness adjustment strategy of the input image is determined to be image brightness enhancement.
5. The image brightness adjustment method according to claim 3 or 4, characterized in that, When the image brightness adjustment strategy for the input image is image brightness enhancement, adjusting the image brightness of the input image according to the image brightness adjustment strategy includes: Determine the deviation between the lower limit of brightness and the average brightness of the image, and determine the compensation coefficient corresponding to the input image; Based on the deviation and the compensation coefficient, the compensated brightness is determined, and the target brightness is determined based on the compensated brightness and the average brightness of the image. The gamma value is determined based on the target brightness and the average brightness of the image; The input image is then enhanced in brightness based on the gamma value.
6. The image brightness adjustment method according to claim 2, characterized in that, Determining the gray-level co-occurrence matrix energy value of the input image includes: Determine the gray-level co-occurrence matrix of the input image; The gray-level co-occurrence matrix energy value of the input image is determined based on the sum of squares of all element values in the gray-level co-occurrence matrix.
7. The image brightness adjustment method according to claim 2, characterized in that, Determining the Laplacian variance of the input image includes: The input image is convolved using the Laplacian operator to generate a response image; The Laplacian variance of the input image is determined based on the variance of all pixel values in the response image.
8. An image brightness adjustment device, characterized in that, include: An image acquisition module is used to acquire an input image and determine the average brightness of the input image; A brightness detection module is used to determine the ambient light intensity of the input image when the average brightness of the image is detected to be less than the lower limit of brightness. The ambient light intensity is determined based on the illumination components separated from the input image; A brightness adjustment module is used to determine the image brightness adjustment strategy of the input image when the ambient light intensity is less than a second threshold.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the image brightness adjustment method as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the image brightness adjustment method as described in any one of claims 1 to 7.