Image brightness correction method and device and storage medium
By performing backlight shooting and image segmentation processing in industrial cameras, combining adaptive proportional value factors and statistical distribution functions, efficient brightness correction of images under backlight conditions is achieved, solving the problems of uneven brightness and transition details in the prior art, and improving image quality.
Patent Information
- Application Number
- CN202510152503.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-12
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2045-02-12
AI Technical Summary
The brightness of the images captured by the prior art under backlight conditions is uneven, resulting in darker subjects and unclear details, which cannot meet the requirements of comfortable viewing of human eyes. The existing brightness correction methods are highly limited, and transition details are easily lost.
By configuring industrial cameras and lenses for backlight shooting, L-channel images are generated, and histogram distribution statistics are performed, the brightness data at the beginning and ends are screened out, the brightness mean value of the channel image and the fitted brightness value are calculated, the image segmentation is performed to generate target and background images, the adaptive proportional value factor and corrected brightness mean are calculated, the statistical distribution function and mapping function are generated, the brightness correction and merging process is performed, and the target brightness correction image is finally generated through the inverse conversion of color space.
It effectively reduces the loss of transition details during the correction process, optimizes the accuracy and effect of brightness correction, makes the image brightness more uniform, and meets the requirements of comfortable viewing of human eyes.
Smart Images

Figure CN119624842A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of sampled image processing, and in particular to a method, device and storage medium for image brightness correction. Background Art
[0002] Existing industrial cameras are composed of different cameras and different lenses, so that industrial cameras can adapt to different detection links. During the camera detection process, it is necessary to collect multiple images through the camera, and then the collected images are tested to see the original acquisition effect of the camera.
[0003] In the process of testing the image acquisition effect of the camera, the backlight shooting effect is one of the key items to be tested by the camera. Under the backlight condition, the industrial camera shoots backlight images of specific objects to obtain backlight images of different degrees. Such backlight images usually have dark subjects and unclear details, which cannot meet the requirements of comfortable viewing for the human eye. In the existing detection process, it is necessary to perform brightness correction on the original acquired image to make it reach a normal state, and then compare it with the original acquired image. Therefore, the brightness unevenness correction and compensation technology came into being. This method technology is to adjust and repair the brightness of the original acquired image taken by the industrial camera in a backlight environment, so that the original uneven brightness and darkness of the original acquired image is restored to a normal state.
[0004] The current methods mainly process the original acquired image by directly performing histogram equalization or directly compensating the image according to a given area according to the spatial position. These methods have great limitations. When the contrast between the bright and dark areas of the original acquired image is large, the transition details between the bright and dark areas are easily lost. Summary of the invention
[0005] The present application discloses a method, device and storage medium for image brightness correction, which are used to reduce the loss of transition details during the correction process.
[0006] The first aspect of the present application discloses a method, device and storage medium for image brightness correction, including: Configure the camera and the corresponding lens, use the camera to shoot the target object in the backlight, generate a backlight acquisition image, perform color space conversion on the backlight acquisition image, and generate an L channel image; Perform histogram distribution statistics calculation on the L channel image, traverse the brightness values of the image pixels in multiple directions, sort the distribution of the brightness data and filter out the brightness data with a preset filter ratio at both ends. The brightness data includes brightness value and brightness frequency; Calculate the channel image brightness mean and fitted brightness value in the remaining L channel image, where the fitted brightness value is generated according to the brightness maximum and brightness minimum of the L channel image; The L channel image is segmented using the fitted brightness value as the initial segmentation point to generate a backlit target image and a background image; Calculate the adaptive proportional value factor according to the brightness mean of the backlight target image and the channel image after image segmentation, and calculate the corrected brightness mean according to the adaptive proportional value factor; Calculate the statistical distribution function of the backlit target image and the background image; Calculate the mapping function of the backlit target object and the background object according to the statistical distribution function and the corrected brightness mean of the backlit target image and the background image; The background image and the backlight target image are mapped and merged by a mapping function to generate an initial brightness correction image; The initial brightness-corrected image is inversely transformed into color space to generate the target brightness-corrected image.
[0007] Optionally, an adaptive proportional value factor is calculated according to the brightness mean of the backlight target image and the channel image after image segmentation, and a corrected brightness mean is calculated according to the adaptive proportional value factor, including: Calculate the adaptive scale factor according to the number of pixels of the backlit target image and the L channel image after image segmentation; The corrected brightness mean is calculated based on the adaptive scale factor and the channel image brightness mean.
[0008] Optionally, a statistical distribution function of the backlit target image and the background image is calculated, including: Obtaining probability density function, histogram statistical information, first standard deviation and second standard deviation of the backlit target image and the background image; Generate the sum of total pixels of the backlit target image and the background image according to histogram statistics; Calculate the upper and lower limits of the threshold according to the sum of the total pixels of the backlit target image and the background image, the histogram statistical function factor, the first standard deviation and the second standard deviation; The probability density function is segmented according to the upper and lower thresholds; Generates a statistical distribution function from a piecewise probability density function.
[0009] Optionally, after obtaining the probability density function, histogram statistical information, first standard deviation and second standard deviation of the backlit target image and the background image, and before calculating the upper and lower limits of the threshold according to the sum of the total pixels of the backlit target image and the background image, the histogram statistical function factor, the first standard deviation and the second standard deviation, the method further includes: The histogram statistical function factors of the backlight target image and the background image are calculated according to the first standard deviation and the second standard deviation.
[0010] Optionally, after configuring the camera and the corresponding lens, shooting the target object in the backlight through the camera to generate a backlight collection image, performing color space conversion on the backlight collection image to generate an L channel image, performing histogram distribution statistical calculation on the L channel image, traversing the brightness values of the image pixels in multiple directions, sorting the distribution of the brightness data and filtering out the brightness data with a preset screening ratio at both ends, the method further includes: The preset screening ratio is calculated according to the image parameters of the backlight acquisition image.
[0011] The second aspect of the present application discloses a device for image brightness correction, comprising: The first generating unit is used to configure a camera and a corresponding lens, shoot a target object in backlight through the camera to generate a backlight captured image, and perform color space conversion on the backlight captured image to generate an L channel image; A screening unit is used to perform histogram distribution statistics calculation on the L channel image, traverse the brightness values of the image pixels in multiple directions, sort the distribution of the brightness data and screen out the brightness data with a preset screening ratio at both ends, and the brightness data includes brightness value and brightness frequency; A first calculation unit is used to calculate the channel image brightness mean and the fitted brightness value in the remaining L channel image, where the fitted brightness value is generated according to the brightness maximum and brightness minimum of the L channel image; The second generating unit is used to perform image segmentation on the L channel image by taking the fitted brightness value as the initial segmentation point to generate a backlight target image and a background image; The second calculation unit is used to calculate the adaptive proportional value factor according to the brightness mean of the backlight target image and the channel image after the image segmentation, and calculate the corrected brightness mean according to the adaptive proportional value factor; A third calculation unit, used for calculating the statistical distribution function of the backlit target image and the background image; a fourth calculation unit, configured to calculate a mapping function of a backlight target object and a background object according to a statistical distribution function and a corrected brightness mean of the backlight target image and the background image; A third generating unit is used to map and merge the background image and the backlight target image through a mapping function to generate an initial brightness correction image; The fourth generating unit is used to perform color space inverse conversion on the initial brightness-corrected image to generate a target brightness-corrected image.
[0012] Optionally, the second computing unit includes: Calculate the adaptive scale factor according to the number of pixels of the backlit target image and the L channel image after image segmentation; The corrected brightness mean is calculated based on the adaptive scale factor and the channel image brightness mean.
[0013] Optionally, the third computing unit includes: An acquisition module, used to acquire the probability density function, histogram statistical information, first standard deviation and second standard deviation of the backlit target image and the background image; A first generating module, used for generating the sum of total pixels of the backlit target image and the background image according to the histogram statistical information; A first calculation module, used for calculating the upper and lower limits of the threshold according to the sum of the total pixels of the backlight target image and the background image, the histogram statistical function factor, the first standard deviation and the second standard deviation; A segmentation module, used to segment the probability density function according to the upper and lower limits of the threshold; The second generating module is used to generate a statistical distribution function according to the segmented probability density function.
[0014] Optionally, after the acquisition module and before the first calculation module, the fourth calculation unit further includes: The second calculation module is used to calculate the histogram statistical function factor of the backlight target image and the background image according to the first standard deviation and the second standard deviation.
[0015] Optionally, after the first generating unit and before the screening unit, the device further includes: The fifth calculation unit is used to calculate a preset screening ratio according to image parameters of the backlight captured image.
[0016] A third aspect of the present application provides a device for image brightness correction, comprising: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, and the processor calls the program to execute the first aspect and any optional method of the first aspect.
[0017] A fourth aspect of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the program executes the first aspect and any optional method of the first aspect.
[0018] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages: In the present application, an industrial camera and a corresponding lens are first configured, and the target object is photographed in the backlight by the camera to generate a backlight acquisition image, and the backlight acquisition image is converted into a color space to generate an L channel image. The L channel image is statistically calculated for histogram distribution, the brightness values of the image pixels are traversed in multiple directions, the brightness data is distributed and sorted, and the brightness data with a preset screening ratio at both ends are screened out, and the brightness data includes brightness value and brightness frequency. The brightness data with too large a difference is selectively screened out. Next, the channel image brightness mean and the fitted brightness value in the remaining L channel image are calculated, wherein the fitted brightness value is generated according to the brightness maximum and brightness minimum of the L channel image. The L channel image is segmented using the fitted brightness value as the initial segmentation point to generate a backlight target image and a background image. Then, an adaptive proportional value factor is calculated based on the brightness mean of the backlight target image and the channel image after the image segmentation, and the corrected brightness mean is calculated based on the adaptive proportional value factor. The statistical distribution function of the backlight target image and the background image is calculated. The mapping function of the backlight target object and the background object is calculated based on the statistical distribution function and the corrected brightness mean of the backlight target image and the background image. The background image and the backlight target image are mapped and merged through a mapping function to generate an initial brightness correction image. The initial brightness correction image is inversely transformed in color space to generate a target brightness correction image.
[0019] By screening the difference brightness data, the backlight target image and the background image are determined according to the brightness data, and the adaptive proportional value factor suitable for the current image is calculated according to the brightness mean of the backlight target image and the channel image, and the corrected brightness mean is calculated according to the adaptive proportional value factor, and the corrected brightness mean is used as the correction target. Then, the mapping function of the backlight target object and the background object is calculated according to the statistical distribution function of the backlight target image and the background image and the corrected brightness mean, and the correction and merging are completed according to the mapping function, and finally the brightness correction is completed. By calculating the corrected brightness mean according to the adaptive proportional value factor, and compensating the background bright area and the target dark area according to different proportions, the compensation accuracy and effect of the algorithm are optimized, and the transition details in the correction process are greatly reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0021] Figure 1 A schematic diagram of an embodiment of the method for image brightness correction of the present application; Figure 2A schematic diagram of an embodiment of a method for calculating a corrected brightness mean value in the present application; Figure 3 A schematic diagram of an embodiment of a method for generating a statistical distribution function for the present application; Figure 4 A schematic diagram of an embodiment of a method for calculating a histogram statistical function factor of the present application; Figure 5 A schematic diagram of an embodiment of a method for calculating a preset screening ratio for the present application; Figure 6 A schematic diagram of an embodiment of a device for image brightness correction of the present application; Figure 7 A schematic diagram of an embodiment of a device for image brightness correction of the present application. DETAILED DESCRIPTION
[0022] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0023] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0024] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0025] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0026] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0027] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0028] In the prior art, in the process of testing the image acquisition effect of the camera, the backlight shooting effect is one of the key detection items of the camera. Under the backlight condition, the industrial camera performs backlight shooting of a specific object to obtain backlight images of different degrees. Such backlight images usually have a dark main body and unclear details, which cannot meet the requirements of comfortable viewing for the human eye. In the existing detection link, it is necessary to perform brightness correction on the original acquired image to make it reach a normal state, and then compare it with the original acquired image. Therefore, the brightness unevenness correction and compensation technology came into being. This method technology is to adjust and repair the brightness of the original acquired image taken by the industrial camera in a backlight environment, so that the original uneven brightness and darkness of the original acquired image is restored to a normal state.
[0029] The current methods mainly process the original acquired image by directly performing histogram equalization or directly compensating the image according to a given area according to the spatial position. These methods have great limitations. When the contrast between the bright and dark areas of the original acquired image is large, the transition details between the bright and dark areas are easily lost.
[0030] Based on this, the present application discloses a method, device and storage medium for image brightness correction, which are used to reduce the loss of transition details during the correction process.
[0031] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0032] The method of the present application can be applied to a server, a device, a terminal or other devices with logic processing capabilities, and the present application does not limit this. For the convenience of description, the following description is made by taking the execution subject as an example of a terminal.
[0033] See also Figure 1The present application provides an embodiment of a method for image brightness correction, comprising: 101. Configure a camera and a corresponding lens, use the camera to shoot a backlight image of the target object to generate a backlight collection image, perform color space conversion on the backlight collection image to generate an L channel image; In this embodiment, an industrial camera is used to photograph a target object in backlighting to generate a backlight acquisition image. At this time, the captured image (the backlight part is the target object, and the other part is the background) has unnatural brightness and loses some detail information of the main body of the picture, resulting in poor image quality.
[0034] It should be noted that, in this embodiment, light source parameters and position parameters and size parameters of the target object can be set for analysis of backlight acquisition images under multiple conditions.
[0035] Next, the terminal divides the darker part of the backlight target and the brighter part of the background of the image, and assumes that the size of the captured image is M*N. Specifically, the terminal first performs color space conversion on the backlight acquisition image to generate an L channel image. The obtained backlight acquisition image is converted into a color space. The method used in this embodiment is to convert the image from the RGB space to the Lab space to obtain the brightness component information L (L channel image) of the image.
[0036] 102. Perform a histogram distribution statistical calculation on the L channel image, traverse the brightness values of the image pixels in multiple directions, sort the distribution of the brightness data, and filter out the brightness data with a preset filtering ratio at both ends, the brightness data includes the brightness value and the brightness frequency; In this embodiment, the terminal performs histogram distribution statistics calculation on the converted L channel image, traverses the brightness values of the image pixels in multiple directions, sorts the brightness values and the brightness frequency distribution, and uses a pre-calculated screening ratio to remove the maximum and minimum brightness values at the beginning and end, for example: remove about 5%-10% of the maximum and minimum brightness values at the beginning and end.
[0037] In this embodiment, the screening ratio may also be adjusted according to the acquisition effect of the current original image.
[0038] 103. Calculate the channel image brightness mean and the fitted brightness value in the remaining L channel image, where the fitted brightness value is generated according to the brightness maximum and brightness minimum of the L channel image; In this embodiment, the terminal calculates the channel image brightness mean and the fitting brightness value in the remaining L channel image, and the fitting brightness value is generated according to the brightness maximum value and brightness minimum value of the L channel image.
[0039] 104. Using the fitted brightness value as an initial segmentation point to perform image segmentation on the L channel image, and generate a backlit target image and a background image; Specifically, the terminal calculates the brightness maximum Lmax, minimum Lmin and mean Lmean (channel image brightness mean) in the remaining L channel image.
[0040] The terminal uses the fitted brightness value as the initial segmentation point to segment the L channel image and generate the backlight target image and the background image. Specifically, the terminal records the average value of the maximum brightness value Lmax and the minimum brightness value Lmin as Lmean_1 (fitted brightness value), and uses Lmean_1 as the initial segmentation point between the backlight target area and the background area of the image. Pixels with brightness values less than Lmean_1 are determined as elements in the backlight target object, and pixels with brightness values greater than Lmean_1 are determined as elements in the background object.
[0041] 105. Calculate an adaptive proportional value factor according to the brightness mean of the backlight target image and the channel image after image segmentation, and calculate a corrected brightness mean according to the adaptive proportional value factor; The terminal calculates the adaptive proportional value factor according to the brightness mean of the backlight target image and the channel image after image segmentation, and calculates the corrected brightness mean according to the adaptive proportional value factor. That is, the corrected brightness mean is calculated according to the ratio of the background image and the backlight target image, and the corrected target brightness is analyzed.
[0042] 106. Calculate the statistical distribution function of the backlit target image and the background image; 107. Calculate a mapping function of the backlit target object and the background object according to the statistical distribution function and the corrected brightness mean of the backlit target image and the background image; The terminal calculates the statistical distribution function of the backlit target image and the background image, and the statistical distribution function is used to analyze the pixel parameters of the backlit target image and the background image. Then, the mapping function of the backlit target object and the background object is calculated based on the statistical distribution function of the backlit target image and the background image and the corrected brightness mean, and the specific calculation obtains the mapping function of two segments. The formula is as follows:
[0043]
[0044] Where: k represents the brightness value of the image, ranging from 0 to 100, is the statistical distribution function of the backlit target object, is the statistical distribution function of the background object, is the corrected brightness mean, and They are the mapping functions for backlit target objects and background objects respectively.
[0045] 108. Mapping and merging the background image and the backlight target image through a mapping function to generate an initial brightness correction image; The terminal maps and merges the background image and the backlight target image through a mapping function to generate an initial brightness correction image. Specifically, the terminal maps the background image and the backlight target image through the above function to obtain the brightness sets of the two target images for correction compensation, and then merges the brightness sets of the two to finally obtain the brightness value of the complete corrected and compensated image.
[0046]
[0047] Among them, L is the final corrected and compensated brightness set.
[0048] 109. Perform color space inverse conversion on the initial brightness-corrected image to generate a target brightness-corrected image.
[0049] The terminal performs a color space inverse conversion on the initial brightness correction image to generate a target brightness correction image. Specifically, the final corrected and compensated image is converted from the Lab color space back to the RGB color space to complete the correction compensation of the backlit uneven brightness image.
[0050] In this embodiment, firstly, an industrial camera and a corresponding lens are configured, and the target object is photographed in the backlight by the camera to generate a backlight collection image, and the backlight collection image is converted into a color space to generate an L channel image. The L channel image is subjected to a histogram distribution statistical calculation, and the brightness values of the image pixels are traversed in multiple directions. The brightness data is distributed and sorted, and the brightness data with a preset screening ratio at both ends are screened out, and the brightness data includes a brightness value and a brightness frequency. The brightness data with too large a difference is selectively screened out. Next, the channel image brightness mean and the fitted brightness value in the remaining L channel image are calculated, wherein the fitted brightness value is generated according to the brightness maximum and brightness minimum of the L channel image. The L channel image is segmented using the fitted brightness value as the initial segmentation point to generate a backlight target image and a background image. Then, an adaptive proportional value factor is calculated according to the brightness mean of the backlight target image and the channel image after the image segmentation, and a corrected brightness mean is calculated according to the adaptive proportional value factor. The statistical distribution function of the backlight target image and the background image is calculated. The mapping function of the backlight target object and the background object is calculated according to the statistical distribution function and the corrected brightness mean of the backlight target image and the background image. The background image and the backlight target image are mapped and merged through a mapping function to generate an initial brightness correction image. The initial brightness correction image is inversely transformed in color space to generate a target brightness correction image.
[0051] By screening the difference brightness data, the backlight target image and the background image are determined according to the brightness data, and the adaptive proportional value factor suitable for the current image is calculated according to the brightness mean of the backlight target image and the channel image, and the corrected brightness mean is calculated according to the adaptive proportional value factor, and the corrected brightness mean is used as the correction target. Then, the mapping function of the backlight target object and the background object is calculated according to the statistical distribution function of the backlight target image and the background image and the corrected brightness mean, and the correction and merging are completed according to the mapping function, and finally the brightness correction is completed. By calculating the corrected brightness mean according to the adaptive proportional value factor, and compensating the background bright area and the target dark area according to different proportions, the compensation accuracy and effect of the algorithm are optimized, and the transition details in the correction process are greatly reduced.
[0052] See also Figure 2 The present application provides an embodiment of a method for calculating a corrected brightness mean, comprising: 201. Calculate the adaptive proportional value factor according to the number of pixels of the backlit target image and the L channel image obtained by image segmentation; 202. Calculate a corrected brightness mean value according to the adaptive scale value factor and the channel image brightness mean value.
[0053] This embodiment proposes an adaptive proportional value factor , after dividing the L channel image into the backlit target image and the background image, the ideal brightness mean (corrected brightness mean) that needs to be achieved after image correction compensation is calculated through the proportional value factor algorithm. From the statistical data analysis, it can be seen that the size of the ideal brightness mean is closely related to the proportion of the backlit target image to the entire image, and generally increases as the backlit target occupies an increasing proportion of the entire image. In this embodiment, the terminal calculates the adaptive proportional value factor according to the number of pixels of the backlight target image and the L channel image after image segmentation, and the formula is as follows:
[0054] represents the adaptive parameter of the backlight ratio of the segmented backlight target image to the whole image in this embodiment, k represents the brightness value of the input image, g(k) represents the sum of all pixels with brightness value k, M*N is the sum of all pixels in the image, and Lmean_1 is the fitted brightness value calculated in the above steps.
[0055] Next, the terminal calculates the corrected brightness mean based on the adaptive scale factor and the channel image brightness mean. The formula is as follows:
[0056] is the average brightness value to be achieved after the final correction. is the channel image brightness mean. Through the above method, the calculated backlight ratio adaptive parameter is as close to the actual situation of the image as possible, and the generated corrected brightness mean is more consistent with the detected target brightness, which can better perform backlight analysis.
[0057] See also Figure 3 The present application provides an embodiment of a method for generating a statistical distribution function, comprising: 301. Obtain a probability density function, histogram statistical information, a first standard deviation, and a second standard deviation of a backlit target image and a background image; 302. Generate a sum of total pixels of the backlit target image and the background image according to the histogram statistical information; 303. Calculate the upper and lower limits of the threshold according to the sum of the total pixels of the backlit target image and the background image, the histogram statistical function factor, the first standard deviation, and the second standard deviation; 304. Segment the probability density function according to the upper and lower limits of the threshold; 305. Generate a statistical distribution function based on the segmented probability density function.
[0058] In this embodiment, after the terminal divides the image into a backlit target image and a background image, it is necessary to perform brightness correction compensation on the two parts of the image respectively. Through data analysis, since the brightness of the background part itself is relatively high and the image details are also clear, it is only necessary to increase the contrast appropriately for this part of the image, and no additional brightness compensation correction is required, otherwise it is easy to cause overexposure of the image. As for the backlit target image part, because the image itself is relatively dark, and the transition edge between it and the background image and many image details within it are also blurred, this part needs to be corrected by fine algorithm compensation to make the overall image brightness look more uniform.
[0059] Specifically, the terminal obtains the probability density function, histogram statistical information, the first standard deviation and the second standard deviation of the backlight target image and the background image.
[0060] The terminal first calculates the probability density functions of the backlight target image and the background image, obtains histogram statistical information and the respective first standard deviation Lstd_1 and second standard deviation Lstd_2, and sets upper and lower limit thresholds for the probability density functions of the corresponding two parts of the image.
[0061] The terminal generates the sum of the total pixels of the backlit target image and the background image based on the histogram statistics. The formula is as follows:
[0062] Where: ∑ is the summation symbol, g(k) represents the sum of all pixels with brightness value k, Z1 is the sum of the total pixels of the backlit target image, Z2 is the sum of the total pixels of the background image, and Lmean_1 is the average value calculated in the above step, which serves as the new segmentation threshold of the algorithm in this step.
[0063] The terminal calculates the upper and lower limits of the threshold according to the sum of the total pixels of the backlight target image and the background image, the histogram statistical function factor, the first standard deviation and the second standard deviation. After summing the pixels of the two divided images, the probability density function is limited to obtain the upper and lower limits of the threshold, which are mainly set by the histogram factor and the total pixels of the two images. The formula is as follows:
[0064]
[0065]
[0066]
[0067] Among them, m1 is the histogram statistical function factor of the backlight target object. Changing the size of m1 will change the degree of image brightness histogram equalization accordingly; m2 is the histogram statistical function factor of the background object. Changing the size of m2 will change the degree of image brightness histogram equalization accordingly; the sizes of m1 and m2 can be adjusted accordingly according to the fluctuations of the first standard deviation Lstd_1 and the second standard deviation Lstd_2 in the above steps. When the standard deviation Lstd is relatively small, the values of m1 and m2 are also reduced accordingly, and the range of m1 and m2 is 0~∞; Q1 and Q2 are the upper and lower limit thresholds of the calculated backlight target image, and Q3 and Q4 are the upper and lower limit thresholds of the calculated background image, respectively.
[0068] The terminal segments the probability density function according to the upper and lower limits of the threshold, and generates a statistical distribution function based on the segmented probability density function. By setting the thresholds Q1, Q2, Q3, and Q4 limits on the probability density functions of the backlit target image and the background image, a segmented probability density function can be obtained. A statistical distribution function is then generated based on the segmented probability density function. The segmented probability density function calculated in this way is more consistent with the actual situation of the preset target object and light source, making the generated statistical distribution function more accurate.
[0069] See also Figure 4 The present application provides an embodiment of a method for calculating a histogram statistical function factor, comprising: 401. Calculate a histogram statistical function factor of a backlit target image and a background image according to a first standard deviation and a second standard deviation.
[0070] In this embodiment, m1 is the histogram statistical function factor of the backlight target object, and m2 is the histogram statistical function factor of the background object. The terminal calculates the histogram statistical function factors m1 and m2 of the backlight target image and the background image according to the first standard deviation Lstd_1 of the backlight target image and the second standard deviation Lstd_2 of the background image. Specifically, it is also necessary to calculate the histogram statistical function factors m1 and m2 of the backlight target image according to the first grayscale mean value Lstd_1 of the backlight target image and the second grayscale mean value Lstd_2 of the background image. , the second grayscale mean of the background image The formula is as follows:
[0071]
[0072] in, is the brightness mean of the backlight captured image. In this embodiment, by introducing the first standard deviation Lstd_1 of the backlight target image and the second standard deviation Lstd_2 of the background image, the first brightness mean of the backlight target image affected by the image segmentation fluctuation is also introduced. , the second brightness mean of the background image , and combined with the original brightness mean of the original backlight acquisition image, the generated histogram statistical function factors m1 and m2 are fixed by the original image while fluctuating, so that they will not deviate too much from the ideal range, thereby improving the accuracy of subsequent calculations.
[0073] See also Figure 5 The present application provides an embodiment of a method for calculating a preset screening ratio, comprising: 501. Calculate a preset screening ratio according to image parameters of the backlight captured image.
[0074] In this embodiment, the terminal calculates the preset screening ratio according to the image parameters of the backlight collected image, which specifically needs to be calculated by the brightness mean of the original collected image (backlight collected image). , and the brightness of the light source setting. The formula is as follows:
[0075] in, The brightness set for the light source is used to obtain the screening ratio through the preset brightness of the light source. Compared with determining the range to be screened in advance through the set brightness parameters combined with the brightness parameters of the captured image, the accuracy of subsequent calculations is improved.
[0076] See also Figure 6 The present application provides an embodiment of a device for image brightness correction, comprising: The first generating unit 601 is used to configure a camera and a corresponding lens, shoot a target object in backlight through the camera to generate a backlight captured image, and perform color space conversion on the backlight captured image to generate an L channel image; A fifth calculation unit 602, configured to calculate a preset screening ratio according to image parameters of the backlight captured image; The screening unit 603 is used to perform histogram distribution statistics calculation on the L channel image, traverse the brightness values of the image pixels in multiple directions, sort the distribution of the brightness data and screen out the brightness data with a preset screening ratio at both ends, and the brightness data includes brightness value and brightness frequency; A first calculation unit 604 is used to calculate the channel image brightness mean and the fitting brightness value in the remaining L channel image, where the fitting brightness value is generated according to the brightness maximum and brightness minimum of the L channel image; The second generating unit 605 is used to perform image segmentation on the L channel image by using the fitted brightness value as an initial segmentation point to generate a backlight target image and a background image; The second calculation unit 606 is used to calculate the adaptive proportional value factor according to the backlight target image and the brightness mean of the channel image after the image segmentation, and calculate the corrected brightness mean according to the adaptive proportional value factor; Optionally, the second computing unit 606 includes: Calculate the adaptive scale factor according to the number of pixels of the backlit target image and the L channel image after image segmentation; The corrected brightness mean is calculated based on the adaptive scale factor and the channel image brightness mean.
[0077] The third calculation unit 607 is used to calculate the statistical distribution function of the backlit target image and the background image; Optionally, the third computing unit 607 includes: An acquisition module 6071 is used to acquire a probability density function, histogram statistical information, a first standard deviation and a second standard deviation of a backlit target image and a background image; A second calculation module 6072, used to calculate a histogram statistical function factor of the backlit target image and the background image according to the first standard deviation and the second standard deviation; A first generating module 6073, used to generate the sum of total pixels of the backlit target image and the background image according to the histogram statistical information; A first calculation module 6074, used to calculate the upper and lower limits of the threshold according to the sum of the total pixels of the backlight target image and the background image, the histogram statistical function factor, the first standard deviation and the second standard deviation; Segmentation module 6075, for segmenting the probability density function according to the upper and lower thresholds; The second generating module 6076 is used to generate a statistical distribution function according to the segmented probability density function.
[0078] A fourth calculation unit 608, configured to calculate a mapping function of a backlight target object and a background object according to a statistical distribution function and a corrected brightness mean of the backlight target image and the background image; The third generating unit 609 is used to map and merge the background image and the backlight target image through a mapping function to generate an initial brightness correction image; The fourth generating unit 610 is used to perform color space inverse conversion on the initial brightness-corrected image to generate a target brightness-corrected image.
[0079] See also Figure 7 , the present application provides a device for image brightness correction, comprising: Processor 701 , memory 702 , input / output unit 703 , and bus 704 .
[0080] The processor 701 is connected to the memory 702 , the input and output unit 703 , and the bus 704 .
[0081] The memory 702 stores a program, and the processor 701 calls the program to execute the following steps: Figure 1 , Figure 2 and Figure 3 , Figure 4 and Figure 5 The method in .
[0082] The present application provides a computer-readable storage medium, on which a program is stored, and when the program is executed on a computer, the program performs the following steps: Figure 1 , Figure 2 and Figure 3 , Figure 4 and Figure 5 The method in .
[0083] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0084] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0085] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0086] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0087] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.
Claims
1. A method for image brightness correction, characterized in that: include: Configure a camera and a corresponding lens, use the camera to shoot a backlight image of the target object to generate a backlight acquisition image, perform color space conversion on the backlight acquisition image to generate an L channel image; Perform histogram distribution statistics calculation on the L channel image, traverse the brightness values of the image pixels in multiple directions, sort the brightness data, and filter out the brightness data with a preset filtering ratio at both ends, wherein the brightness data includes brightness value and brightness frequency; Calculating the channel image brightness mean and the fitted brightness value in the remaining L channel image, wherein the fitted brightness value is generated according to the brightness maximum and brightness minimum of the L channel image; Using the fitted brightness value as an initial segmentation point to perform image segmentation on the L channel image to generate a backlit target image and a background image; Calculate an adaptive proportional value factor according to the brightness mean of the backlight target image and the channel image after image segmentation, and calculate a corrected brightness mean according to the adaptive proportional value factor; Calculating the statistical distribution function of the backlit target image and the background image; Calculating a mapping function of a backlight target object and a background object according to a statistical distribution function of the backlight target image and the background image and the corrected brightness mean; The background image and the backlight target image are mapped and merged by a mapping function to generate an initial brightness correction image; The initial brightness-corrected image is inversely converted in color space to generate a target brightness-corrected image.
2. The method according to claim 1, characterized in that Calculating an adaptive proportional value factor according to the brightness mean of the backlight target image and the channel image after image segmentation, and calculating a corrected brightness mean according to the adaptive proportional value factor, including: Calculate the adaptive proportional value factor according to the number of pixels of the backlight target image and the L channel image after image segmentation; A corrected brightness mean is calculated according to the adaptive scale value factor and the channel image brightness mean.
3. The method according to claim 1, characterized in that Calculating the statistical distribution function of the backlit target image and the background image, comprising: Obtaining a probability density function, histogram statistical information, a first standard deviation, and a second standard deviation of the backlit target image and the background image; Generating a sum of total pixels of the backlit target image and the background image according to the histogram statistical information; Calculate the upper and lower limits of the threshold according to the sum of the total pixels of the backlight target image and the background image, the histogram statistical function factor, the first standard deviation and the second standard deviation; Segmenting the probability density function according to the upper and lower thresholds; A statistical distribution function is generated based on the probability density function of the segment.
4. The method according to claim 3, characterized in that After obtaining the probability density function, histogram statistical information, first standard deviation and second standard deviation of the backlit target image and the background image, and before calculating the upper and lower limits of the threshold according to the sum of the total pixels of the backlit target image and the background image, the histogram statistical function factor, the first standard deviation and the second standard deviation, the method further includes: A histogram statistical function factor of the backlight target image and the background image is calculated according to the first standard deviation and the second standard deviation.
5. The method according to any one of claims 1 to 4, characterized in that After configuring a camera and a corresponding lens, shooting a target object in backlight by the camera to generate a backlight collection image, performing color space conversion on the backlight collection image to generate an L channel image, performing histogram distribution statistics calculation on the L channel image, traversing the brightness values of image pixels in multiple directions, sorting the brightness data in distribution and filtering out the brightness data with a preset screening ratio at both ends, the method further includes: A preset screening ratio is calculated according to the image parameters of the backlight captured image.
6. A device for image brightness correction, characterized in that: include: A first generating unit is used to configure a camera and a corresponding lens, perform backlight shooting of a target object through the camera to generate a backlight acquisition image, and perform color space conversion on the backlight acquisition image to generate an L channel image; A screening unit is used to perform histogram distribution statistics calculation on the L channel image, traverse the brightness values of image pixels in multiple directions, sort the brightness data and screen out the brightness data with a preset screening ratio at both ends, wherein the brightness data includes brightness value and brightness frequency; A first calculation unit is used to calculate a channel image brightness mean and a fitting brightness value in the remaining L channel image, wherein the fitting brightness value is generated according to a brightness maximum value and a brightness minimum value of the L channel image; A second generating unit is used to perform image segmentation on the L channel image by using the fitted brightness value as an initial segmentation point to generate a backlight target image and a background image; A second calculation unit is used to calculate an adaptive proportional value factor according to the backlight target image and the brightness mean of the channel image after image segmentation, and calculate a corrected brightness mean according to the adaptive proportional value factor; A third calculation unit, used for calculating the statistical distribution function of the backlit target image and the background image; a fourth calculation unit, configured to calculate a mapping function of a backlight target object and a background object according to a statistical distribution function of the backlight target image and the background image and the corrected brightness mean; A third generating unit is used to map and merge the background image and the backlight target image through a mapping function to generate an initial brightness correction image; The fourth generating unit is used to perform color space inverse conversion on the initial brightness-corrected image to generate a target brightness-corrected image.
7. The device according to claim 6, characterized in that The second computing unit comprises: Calculate the adaptive proportional value factor according to the number of pixels of the backlight target image and the L channel image after image segmentation; A corrected brightness mean is calculated according to the adaptive scale value factor and the channel image brightness mean.
8. The device according to claim 6, characterized in that The third computing unit includes: An acquisition module, used for acquiring a probability density function, histogram statistical information, a first standard deviation and a second standard deviation of the backlit target image and the background image; A first generating module, configured to generate a sum of total pixels of the backlit target image and the background image according to the histogram statistical information; A first calculation module, used for calculating the upper and lower limits of the threshold according to the sum of the total pixels of the backlight target image and the background image, the histogram statistical function factor, the first standard deviation and the second standard deviation; A segmentation module, used for segmenting the probability density function according to the upper and lower limits of the threshold; The second generating module is used to generate a statistical distribution function according to the segmented probability density function.
9. A device for image brightness correction, characterized in that: include: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, and the processor calls the program to execute the method according to any one of claims 1 to 5.
10. A computer-readable storage medium having a program stored thereon, wherein the program, when executed on a computer, performs the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method and device for adjusting sunlight readable effect of display screen
CN115063317A
Image threshold segmentation method, system and device for defect detection of display screen and storage medium
CN119027444A
Image processing apparatus and method with contrast correction.
EP2073170A1
Method and system for image dehazing using single scale image fusion
KR102261532B1
Cited By
Screen brightness correction extraction method and device and storage medium
CN119942149A
A method, device and storage medium for screen brightness correction extraction
CN119942149B