A method, device, and storage medium for image brightness correction
By backlighting in an industrial camera, L-channel images are generated and histogram distribution statistics are calculated, the brightness data at the beginning and ends are screened out, the brightness average and fitted brightness values of the channel images are calculated, image segmentation is performed, and the backlight target image and background image are generated. The adaptive proportional value factor is calculated based on the image segmentation results and the brightness mean, the correction brightness mean is calculated, and the mapping function is calculated through the statistical distribution function to perform brightness correction. It solves the problem of darker and unclear details in the backlit image taken under backlight conditions, reduces the loss of transition details, and optimizes the accuracy and effect of brightness correction.
Patent Information
- Application Number
- CN202510152503.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-12
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2045-02-12
AI Technical Summary
In the backlight images taken under backlight conditions in the prior art, the main body is darker and the details are not clear, which cannot meet the requirements of comfortable viewing of the human eye, and the transition details of the bright and dark areas are easily lost.
By configuring an industrial camera and lens 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 average and fitted brightness values of the channel image are calculated, image segmentation is performed, and the backlight target image and background image are generated. The adaptive proportional value factor is calculated based on the image segmentation results and the brightness mean, the correction brightness mean is calculated, and the mapping function is calculated through the statistical distribution function to perform brightness correction.
It reduces the problem that transition details are easily lost during the correction process, optimizes the accuracy and effect of brightness correction, making the images taken in backlight clearer and richer details, meeting the requirements of comfortable viewing of human eyes.
Smart Images

Figure CN119624842B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present application relate to the field of sampling 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 to make the industrial cameras adapt to different detection links. During the detection process of the camera, it is necessary to collect various images through the camera, and then detect the original acquisition effect of the camera on the collected images.
[0003] During the process of detecting the acquisition effect of the camera on images, the backlight shooting effect is one of the key detection items of the camera. When the industrial camera takes a backlight photo of a specific object under this backlight condition to obtain backlight images with different degrees, such backlight images usually have a darker main body and unclear details, and cannot meet the requirements of comfortable viewing by the human eye. In the existing detection links, it is necessary to perform brightness correction on the original acquired images to make them reach the normal state, and then compare them with the original acquired images. Therefore, the brightness non-uniformity correction compensation technology came into being. This method is to adjust and repair the brightness of the original acquired images taken by the industrial camera in the backlight environment, so that the original bright and dark non-uniform parts of the original acquired images return to the normal state.
[0004] Current methods mainly process the original acquired images by directly performing histogram equalization on them or compensating them according to a given area directly by spatial position. These methods have great limitations. When the contrast between the bright area and the dark area of the original acquired image is large, the transition details between the bright area and the dark area are easily lost. Summary of the Invention
[0005] The present application discloses a method, device, and storage medium for image brightness correction, which is used to reduce the easy 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:
[0007] Configure the camera and the corresponding lens, and take a backlight photo of the 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;
[0008] Perform histogram distribution statistical calculation on the L-channel image, traverse the brightness values of the image pixels in multiple directions, sort the brightness data and screen out the brightness data at both ends with a preset screening ratio. The brightness data includes brightness values and brightness frequencies;
[0009] Calculate the mean channel image brightness and the fitted brightness value in the remaining L-channel image, where the fitted brightness value is generated based on the maximum brightness value and the minimum brightness value of the L-channel image;
[0010] Use the fitted brightness value as the initial segmentation point to segment the L-channel image, generating a backlight target image and a background image;
[0011] Calculate the adaptive ratio value factor based on the segmented backlight target image and the mean channel image brightness, and calculate the corrected mean brightness based on the adaptive ratio value factor;
[0012] Calculate the statistical distribution functions of the backlight target image and the background image;
[0013] Calculate the mapping functions of the backlight target object and the background object based on the statistical distribution functions of the backlight target image and the background image and the corrected mean brightness;
[0014] Map and merge the background image and the backlight target image through the mapping function to generate an initial brightness correction image;
[0015] Perform an inverse color space conversion on the initial brightness correction image to generate a target brightness correction image.
[0016] Optionally, calculating the adaptive ratio value factor based on the segmented backlight target image and the mean channel image brightness, and calculating the corrected mean brightness based on the adaptive ratio value factor, includes:
[0017] Calculate the adaptive ratio value factor based on the segmented backlight target image and the number of pixels of the L-channel image;
[0018] Calculate the corrected mean brightness based on the adaptive ratio value factor and the mean channel image brightness.
[0019] Optionally, calculating the statistical distribution functions of the backlight target image and the background image, includes:
[0020] Obtain the probability density functions, histogram statistical information, first standard deviation, and second standard deviation of the backlight target image and the background image;
[0021] Generate the sum of the total number of pixels of the backlight target image and the background image based on the histogram statistical information;
[0022] Calculate the upper and lower threshold limits based on the sum of the total number of pixels of the backlight target image and the background image, the histogram statistical function factor, the first standard deviation, and the second standard deviation;
[0023] Segment the probability density function according to the upper and lower threshold limits;
[0024] Generate the statistical distribution function based on the segmented probability density function.
[0025] Optionally, after obtaining the probability density functions, histogram statistical information, first standard deviation, and second standard deviation of the backlight target image and the background image, and before calculating the upper and lower limits of the threshold based on 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, the method further includes:
[0026] Calculating 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.
[0027] Optionally, after configuring the camera and the corresponding lens, performing backlight shooting on the target object through the camera to generate a backlight acquisition image, performing color space conversion on the backlight acquisition image to generate an L-channel image, and then performing histogram distribution statistical calculation on the L-channel image, traversing the brightness values of the image pixels in multiple directions, sorting the brightness data according to the distribution, and screening out the brightness data at both ends with a preset screening ratio, the method further includes:
[0028] Calculating the preset screening ratio according to the image parameters of the backlight acquisition image.
[0029] The second aspect of the present application discloses an image brightness correction device, including:
[0030] A first generation unit, configured to configure the camera and the corresponding lens, perform backlight shooting on the 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;
[0031] A screening unit, configured to perform histogram distribution statistical calculation on the L-channel image, traverse the brightness values of the image pixels in multiple directions, sort the brightness data according to the distribution, and screen out the brightness data at both ends with a preset screening ratio, where the brightness data includes brightness values and brightness frequencies;
[0032] A first calculation unit, configured to calculate the channel image brightness mean value and the fitted brightness value in the remaining L-channel image, where the fitted brightness value is generated according to the brightness maximum value and the brightness minimum value of the L-channel image;
[0033] A second generation unit, configured to perform image segmentation on the L-channel image using the fitted brightness value as the initial segmentation point to generate a backlight target image and a background image;
[0034] A second calculation unit, configured to calculate an adaptive ratio value factor according to the segmented backlight target image and the channel image brightness mean value, and calculate a corrected brightness mean value according to the adaptive ratio value factor;
[0035] A third calculation unit, configured to calculate the statistical distribution functions of the backlight target image and the background image;
[0036] A fourth calculation unit, configured to calculate a mapping function between a backlight target object and a background object according to a statistical distribution function of a backlight target image and a background image and a corrected brightness mean value;
[0037] A third generation unit, configured to map and merge a background image and a backlight target image through the mapping function to generate an initial brightness correction image;
[0038] A fourth generation unit, configured to perform an inverse color space conversion on the initial brightness correction image to generate a target brightness correction image.
[0039] Optionally, the second calculation unit includes:
[0040] Calculating an adaptive ratio value factor according to the number of pixels of the segmented backlight target image and the L-channel image;
[0041] Calculating a corrected brightness mean value according to the adaptive ratio value factor and the channel image brightness mean value.
[0042] Optionally, the third calculation unit includes:
[0043] An acquisition module, configured to acquire a probability density function, histogram statistical information, a first standard deviation, and a second standard deviation of a backlight target image and a background image;
[0044] A first generation module, configured to generate the sum of the total number of pixels of a backlight target image and a background image according to the histogram statistical information;
[0045] A first calculation module, configured to calculate upper and lower threshold limits according to the sum of the total number of pixels of a backlight target image and a background image, a histogram statistical function factor, a first standard deviation, and a second standard deviation;
[0046] A segmentation module, configured to segment the probability density function according to the upper and lower threshold limits;
[0047] A second generation module, configured to generate a statistical distribution function according to the segmented probability density function.
[0048] Optionally, after the acquisition module and before the first calculation module, the fourth calculation unit further includes:
[0049] A second calculation module, configured to calculate a histogram statistical function factor of a backlight target image and a background image according to a first standard deviation and a second standard deviation.
[0050] Optionally, after the first generation unit and before the screening unit, the apparatus further includes:
[0051] A fifth calculation unit, configured to calculate a preset screening ratio according to an image parameter of a backlight acquisition image.
[0052] A third aspect of the present application provides an apparatus for image brightness correction, including:
[0053] A processor, a memory, an input / output unit, and a bus;
[0054] The processor is connected to the memory, the input / output unit, and the bus;
[0055] The memory stores a program, and the processor calls the program to execute the methods as described in the first aspect and any optional methods of the first aspect.
[0056] A fourth aspect of the present application provides a computer-readable storage medium, on which a program is stored, and when the program is executed on a computer, it executes the methods as described in the first aspect and any optional methods of the first aspect.
[0057] From the above technical solutions, it can be seen that the embodiments of the present application have the following advantages:
[0058] In the present application, first, an industrial camera and a corresponding lens are configured. The target object is backlit by the camera to generate a backlit acquisition image, and the color space of the backlit acquisition image is converted to generate an L-channel image. The histogram distribution of the L-channel image is statistically calculated, the pixel brightness values of the image are traversed in multiple directions, the brightness data is sorted according to the distribution and the brightness data at both ends with a preset screening ratio is screened out. The brightness data includes brightness values and brightness frequencies. The brightness data with too large differences is selectively screened out. Next, the channel image brightness mean value and the fitting brightness value in the remaining L-channel image are calculated. Among them, the fitting brightness value is generated according to the brightness maximum value and the brightness minimum value of the L-channel image. The fitting brightness value is used as the initial segmentation point to segment the L-channel image to generate a backlit target image and a background image. Then, an adaptive ratio value factor is calculated according to the segmented backlit target image and the channel image brightness mean value, and the corrected brightness mean value is calculated according to the adaptive ratio value factor. The statistical distribution functions of the backlit target image and the background image are calculated. The mapping functions of the backlit target object and the background object are calculated according to the statistical distribution functions of the backlit target image and the background image and the corrected brightness mean value. The background image and the backlit target image are mapped and merged through the mapping function to generate an initial brightness correction image. The color space inverse conversion is performed on the initial brightness correction image to generate a target brightness correction image.
[0059] By screening the differential brightness data, determining the backlight target image and the background image according to the belonging brightness data, calculating an adaptive ratio value factor suitable for the current image based on the brightness means of the backlight target image and the channel image, calculating a corrected brightness mean according to the adaptive ratio value factor, and using the corrected brightness mean as the correction target. Then, calculating the mapping functions of the backlight target object and the background object according to the statistical distribution functions of the backlight target image and the background image and the corrected brightness mean, and completing the correction and merging according to the mapping functions, finally completing the brightness correction. By calculating the corrected brightness mean according to the adaptive ratio value factor, and compensating the bright area of the background and the dark area of the target at different ratios, the compensation accuracy and effect of the optimization algorithm are improved, and the loss of transition details during the correction process is greatly reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0061] Figure 1 Schematic diagram of an embodiment of the method for image brightness correction of the present application;
[0062] Figure 2 Schematic diagram of an embodiment of the method for calculating the corrected brightness mean of the present application;
[0063] Figure 3 Schematic diagram of an embodiment of the method for generating the statistical distribution function of the present application;
[0064] Figure 4 Schematic diagram of an embodiment of the method for calculating the histogram statistical function factor of the present application;
[0065] Figure 5 Schematic diagram of an embodiment of the method for calculating the preset screening ratio of the present application;
[0066] Figure 6 Schematic diagram of an embodiment of the device for image brightness correction of the present application;
[0067] Figure 7 Schematic diagram of an embodiment of the device for image brightness correction of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0068] In the following description, for purposes of illustration and not limitation, specific details such as specific system architectures, technologies, etc. are set forth in order to provide a thorough understanding of the embodiments of the present application. However, those skilled in the art should understand that the present application can 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 so as not to obscure the description of the present application with unnecessary details.
[0069] It should be understood that when used in the specification and claims of the present application, the term "comprising" indicates the presence of the 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 their combinations.
[0070] It should also be understood that the term "and / or" as used in the specification and claims of the present application refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0071] As used in the specification and claims of the present application, the term "if" can be interpreted, depending on the context, as "when" or "once" or "in response to determining" or "in response to detecting". Similarly, the phrase "if determined" or "if [the described condition or event] is detected" can be interpreted, depending on the context, as meaning "once determined" or "in response to determining" or "once [the described condition or event] is detected" or "in response to detecting [the described condition or event]".
[0072] In addition, in the description of the specification and claims of the present application, the terms "first", "second", "third", etc. are only used for distinguishing descriptions and should not be construed as indicating or implying relative importance.
[0073] Reference to "one embodiment" or "some embodiments" or the like described in the specification of the present application means that a specific feature, structure, or characteristic described in connection with that embodiment is included in one or more embodiments of the present application. Thus, statements such as "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments", etc. that appear in different places in this specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in another way. The terms "comprising", "including", "having", and their variants all mean "including but not limited to", unless otherwise specifically emphasized in another way.
[0074] In the prior art, during the process of detecting the image acquisition effect of a camera, the backlight shooting effect is one of the key detection items of the camera. When an industrial camera takes a backlight photo of a specific object under this backlight condition to obtain backlight images of different degrees, such backlight images usually have a darker main body and unclear details, and cannot meet the requirements for comfortable viewing by the human eye. In the existing detection link, it is necessary to perform brightness correction on the original acquired image to make it reach the normal state, and then compare it with the original acquired image. Therefore, the brightness uneven correction compensation technology came into being. This method is to perform brightness adjustment and repair on the original acquired image taken by the industrial camera under the backlight environment, so that the original bright and dark uneven parts of the original acquired image are restored to the normal state.
[0075] The current methods mainly process by directly performing histogram equalization on the original acquired image or compensating the image directly according to a given area by spatial position. These methods all have great limitations. When the contrast between the bright area and the dark area of the original acquired image is large, the transition details between the bright area and the dark area are easily lost.
[0076] Based on this, the present application discloses a method, device and storage medium for image brightness correction, which is used to reduce the loss of transition details during the correction process.
[0077] Next, the technical solutions in the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present application.
[0078] The method of the present application can be applied to a server, device, terminal or other devices with logical processing capabilities. In this regard, the present application makes no limitation. For the sake of convenience of description, the following description will be made taking the execution entity as a terminal as an example.
[0079] Please refer to Figure 1 , an embodiment of a method for image brightness correction provided by the present application includes:
[0080] 101. Configure the camera and the corresponding lens, take a backlight photo of the 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;
[0081] In this embodiment, an industrial camera takes a backlight photo of the target object to generate a backlight acquisition image. At this time, the captured image (the backlight part is the target object, and the other parts are the background parts) has an unnatural brightness, and some detail information of the main body of the picture is lost, and the image quality is poor.
[0082] It should be noted that in this embodiment, the light source parameters, the position parameters, and the size parameters of the target object can be set for the analysis of the backlight acquisition images under multiple conditions.
[0083] Next, the terminal divides the darker part of the image backlight target and the brighter part of the background. Assume 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. For the obtained backlight acquisition image, the method used in this embodiment is to convert the image from the RGB space to the Lab space to obtain the luminance component information L (L-channel image) of the image.
[0084] 102. Perform histogram distribution statistical calculation on the L-channel image, traverse the luminance values of the image pixels in multiple directions, sort the luminance data and screen out the luminance data at both ends with a preset screening ratio. The luminance data includes luminance values and luminance frequencies.
[0085] In this embodiment, the terminal performs histogram distribution statistical calculation on the converted L-channel image, traverses the luminance values of the image pixels in multiple directions, sorts the size of the luminance values and the luminance frequency distribution, and uses the pre-calculated screening ratio to remove the maximum and minimum luminance values at both ends. For example: remove about 5%-10% of the maximum and minimum luminance values at both ends.
[0086] In this embodiment, the screening ratio can also be adjusted according to the acquisition effect of the currently captured original image.
[0087] 103. Calculate the channel image luminance mean and the fitted luminance value in the remaining L-channel image. The fitted luminance value is generated according to the luminance maximum value and the luminance minimum value of the L-channel image.
[0088] In this embodiment, the terminal calculates the channel image luminance mean and the fitted luminance value in the remaining L-channel image. The fitted luminance value is generated according to the luminance maximum value and the luminance minimum value of the L-channel image.
[0089] 104. Use the fitted luminance value as the initial segmentation point to segment the L-channel image to generate a backlight target image and a background image.
[0090] Specifically, the terminal calculates the luminance maximum value Lmax, the minimum value Lmin, and the mean value Lmean (channel image luminance mean) in the remaining L-channel image.
[0091] The terminal uses the fitted brightness value as the initial segmentation point to perform image segmentation on the L-channel image, generating a backlight target image and a background image. Specifically, the terminal records the average value of the maximum brightness value Lmax and the minimum brightness value Lmin as Lmean_1 (the 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 a brightness value less than Lmean_1 are determined to be elements in the backlight target object, and pixels greater than Lmean_1 are determined to be elements in the background object.
[0092] 105. Calculate the adaptive ratio value factor based on the backlight target image with good image segmentation and the brightness mean value of the channel image, and calculate the corrected brightness mean value according to the adaptive ratio value factor;
[0093] The terminal calculates the adaptive ratio value factor based on the backlight target image with good image segmentation and the brightness mean value of the channel image, and calculates the corrected brightness mean value according to the adaptive ratio value factor. That is, the corrected brightness mean value is calculated according to the ratio of the background image and the backlight target image, that is, the target brightness to be corrected is analyzed.
[0094] 106. Calculate the statistical distribution functions of the backlight target image and the background image;
[0095] 107. Calculate the mapping functions of the backlight target object and the background object according to the statistical distribution functions of the backlight target image and the background image and the corrected brightness mean value;
[0096] The terminal calculates the statistical distribution functions of the backlight target image and the background image. The statistical distribution function is used to analyze the pixel point parameters of the backlight target image and the background image. Then, according to the statistical distribution functions of the backlight target image and the background image and the corrected brightness mean value, the mapping functions of the backlight target object and the background object are calculated, and specifically, two piecewise mapping functions are obtained. The formula is as follows:
[0097]
[0098]
[0099] Where: k represents the brightness value of the image, and the value range is 0 to 100. is the statistical distribution function of the backlight target object. is the statistical distribution function of the background object. is the corrected brightness mean value. and are the mapping functions of the backlight target object and the background object respectively.
[0100] 108. Map and merge the background image and the backlight target image through the mapping function to generate an initial brightness correction image;
[0101] 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 two target image brightness sets for correction compensation, and then merges the two brightness sets to finally obtain the brightness value of the complete corrected and compensated image.
[0102]
[0103] Among them, L is the brightness set after final correction and compensation.
[0104] 109. Perform an inverse color space conversion on the initial brightness correction image to generate a target brightness correction image.
[0105] The terminal performs an inverse color space conversion on the initial brightness correction image to generate a target brightness correction image. Specifically, the finally corrected and compensated image is converted back from the Lab color space to the RGB color space to complete the correction and compensation of the uneven backlight brightness image.
[0106] In this embodiment, first, configure an industrial camera and a corresponding lens, backlight the target object through the camera to generate a backlight acquisition image, perform a color space conversion on the backlight acquisition image to generate an L-channel image. Perform a histogram distribution statistical calculation on the L-channel image, traverse the pixel brightness values of the image in multiple directions, sort the brightness data and screen out the brightness data at both the head and tail ends with a preset screening ratio. The brightness data includes brightness values and brightness frequencies. Selectively screen out the brightness data with too large differences. Next, calculate the channel image brightness mean and the fitted brightness value in the remaining L-channel image. Among them, the fitted brightness value is generated according to the brightness maximum value and the brightness minimum value of the L-channel image. Use the fitted brightness value as the initial segmentation point to segment the L-channel image to generate a backlight target image and a background image. Then calculate the adaptive ratio value factor according to the segmented backlight target image and the channel image brightness mean, and calculate the corrected brightness mean according to the adaptive ratio value factor. Calculate the statistical distribution functions of the backlight target image and the background image. Calculate the mapping function of the backlight target object and the background object according to the statistical distribution functions of the backlight target image and the background image and the corrected brightness mean. Map and merge the background image and the backlight target image through the mapping function to generate an initial brightness correction image. Perform an inverse color space conversion on the initial brightness correction image to generate a target brightness correction image.
[0107] By screening the differential brightness data, determining the backlight target image and the background image according to the belonging brightness data, calculating an adaptive ratio value factor suitable for the current image based on the brightness means of the backlight target image and the channel image, calculating a corrected brightness mean according to the adaptive ratio value factor, and using the corrected brightness mean as the correction target. Then, calculating the mapping functions of the backlight target object and the background object according to the statistical distribution functions of the backlight target image and the background image and the corrected brightness mean, and completing the correction and merging according to the mapping functions, finally completing the brightness correction. By calculating the corrected brightness mean according to the adaptive ratio value factor, and compensating the bright background area and the dark target area at different ratios, the compensation accuracy and effect of the optimization algorithm are improved, and the loss of transition details during the correction process is greatly reduced.
[0108] Please refer to Figure 2 , an embodiment of a method for calculating a corrected brightness mean provided by this application includes:
[0109] 201. Calculate an adaptive ratio value factor according to the number of pixels of the segmented backlight target image and the L-channel image of the image;
[0110] 202. Calculate a corrected brightness mean according to the adaptive ratio value factor and the brightness mean of the channel image.
[0111] This embodiment proposes an adaptive ratio value factor , after the L-channel image is segmented into a backlight target image and a background image, and the ideal brightness mean (corrected brightness mean) to be achieved after image correction compensation is calculated by the ratio value factor algorithm. It can be seen from statistical data analysis that the size of the ideal brightness mean is closely related to the proportion of the backlight target image in the whole image, and generally increases as the proportion of the backlight target in the whole image increases.
[0112] In this embodiment, the terminal calculates an adaptive ratio value factor according to the number of pixels of the segmented backlight target image and the L-channel image of the image. The formula is as follows:
[0113]
[0114] represents the adaptive parameter of the proportion of the segmented backlight target image in the whole image backlight in this embodiment, k represents the brightness value of the input image, g(k) represents the sum of all pixels with the brightness value of k, M*N is the total number of all pixels in the image, and Lmean_1 is the fitted brightness value calculated in the previous step.
[0115] Next, the terminal calculates a corrected brightness mean according to the adaptive ratio value factor and the brightness mean of the channel image. The formula is as follows:
[0116]
[0117] is the average brightness to be achieved after the final correction, is the average brightness of the channel image. Through the above method, the calculated backlight ratio adaptive parameter is as close as possible to the actual situation of the image, and the generated corrected average brightness is more in line with the target brightness of the detection, enabling better backlight analysis.
[0118] Please refer to Figure 3 , this application provides an embodiment of a method for generating a statistical distribution function, including:
[0119] 301. Obtain the probability density function, histogram statistical information, first standard deviation, and second standard deviation of the backlight target image and the background image;
[0120] 302. Generate the sum of the total pixels of the backlight target image and the background image according to the histogram statistical information;
[0121] 303. 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;
[0122] 304. Segment the probability density function according to the upper and lower limits of the threshold;
[0123] 305. Generate a statistical distribution function according to the segmented probability density function.
[0124] In this embodiment, after the terminal divides the image into a backlight 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 clear, for this part of the image, only the contrast needs to be appropriately increased, and no additional brightness compensation correction is required, otherwise it is easier to cause overexposure of the image. For the backlight target image part, because the image itself is relatively dark, and at the same time, the transition edge between it and the background image and many image details inside itself are also blurred, so for this part, a fine algorithm compensation needs to be performed for correction to make the overall image brightness look more uniform.
[0125] Specifically, the terminal obtains the probability density function, histogram statistical information, first standard deviation, and second standard deviation of the backlight target image and the background image.
[0126] The terminal first calculates the probability density functions of the backlight target image and the background image, obtains the histogram statistical information, as well as the respective first standard deviation Lstd_1 and second standard deviation Lstd_2, and sets the upper and lower limit thresholds for the probability density functions of the corresponding two parts of the image.
[0127] The terminal generates the sum of the total pixels of the backlight target image and the background image according to the histogram statistical information, and the formula is as follows:
[0128]
[0129] Among them: ∑ is the summation accumulation symbol, g(k) represents the sum of all pixels with a brightness value of k, Z1 is the sum of the total pixels of the backlight 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 steps, which is used as the new segmentation threshold for the algorithm in this step.
[0130] 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 segmented images, the probability density function is limited, and the upper and lower limits of the threshold are obtained. It is mainly set through the histogram factor and the total pixels of the two parts of the image, and the formula is as follows:
[0131]
[0132]
[0133]
[0134]
[0135] Among them, m1 is the histogram statistical function factor of the backlight target object. Changing the size of m1 will cause a corresponding change in the degree of histogram equalization of the image brightness; m2 is the histogram statistical function factor of the background object. Changing the size of m2 will cause a corresponding change in the degree of histogram equalization of the image brightness; 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 small, the values of m1 and m2 also decrease accordingly, and the ranges of m1 and m2 are 0 to ∞; Q1 and Q2 are the upper and lower limit thresholds of the calculated backlight target image respectively, and Q3 and Q4 are the upper and lower limit thresholds of the calculated background image respectively.
[0136] The terminal segments the probability density function according to the upper and lower limits of the threshold, and generates a statistical distribution function according to the segmented probability density function. By setting the thresholds Q1, Q2, Q3, and Q4 for the probability density functions of the backlight target image and the background image, a segmented probability density function can be obtained. Then, a statistical distribution function is generated according to the segmented probability density function. The segmented probability density function calculated in this way is more in line with the real situation of the preset target object and light source, making the generated statistical distribution function more accurate.
[0137] Please refer to Figure 4, an embodiment of a method for calculating a histogram statistical function factor provided by this application includes:
[0138] 401. Calculate the histogram statistical function factors of the backlight target image and the background image according to the first standard deviation and the second standard deviation.
[0139] In this embodiment, m1 is the histogram statistical function factor of the backlight target object, m2 is the histogram statistical function factor of the background object, and 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 according to the first gray mean value of the backlight target image , the second gray mean value of the background image . The formula is as follows:
[0140]
[0141]
[0142] Among them, is the brightness mean value of the backlight acquisition image. In this embodiment, while 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 value of the backlight target image affected by image segmentation fluctuations and the second brightness mean value of the background image are also introduced, and combined with the original brightness mean value 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, improving the accuracy of subsequent calculations.
[0143] Please refer to Figure 5 , an embodiment of a method for calculating a preset screening ratio provided by this application includes:
[0144] 501. Calculate the preset screening ratio according to the image parameters of the backlight acquisition image.
[0145] In this embodiment, the terminal calculates the preset screening ratio according to the image parameters of the backlight acquisition image. Specifically, it is necessary to calculate through the brightness mean value of the original acquisition image (backlight acquisition image) and the brightness set by the light source. The formula is as follows:
[0146]
[0147] Among them, The brightness set for the light source is used to obtain the screening ratio by presetting the brightness of the light source. Relative to the range to be screened determined in advance by combining the set brightness parameter and the brightness parameter of the acquired image, the accuracy of subsequent calculations is improved.
[0148] Please refer to Figure 6 , an embodiment of an image brightness correction device provided by this application includes:
[0149] The first generation unit 601 is used to configure the camera and the corresponding lens, perform backlight shooting on the target object through the camera, generate a backlight acquisition image, and perform color space conversion on the backlight acquisition image to generate an L-channel image;
[0150] The fifth calculation unit 602 is used to calculate a preset screening ratio according to the image parameters of the backlight acquisition image;
[0151] The screening unit 603 is used to perform histogram distribution statistical calculation on the L-channel image, traverse the brightness values of image pixels in multiple directions, sort the brightness data according to the distribution, and screen out the brightness data at both ends with a preset screening ratio. The brightness data includes brightness values and brightness frequencies;
[0152] The first calculation unit 604 is used to calculate the channel image brightness mean value and the fitting brightness value in the remaining L-channel image. The fitting brightness value is generated according to the brightness maximum value and the brightness minimum value of the L-channel image;
[0153] The second generation unit 605 is used to perform image segmentation on the L-channel image with the fitting brightness value as the initial segmentation point to generate a backlight target image and a background image;
[0154] The second calculation unit 606 is used to calculate an adaptive ratio value factor according to the segmented backlight target image and the channel image brightness mean value, and calculate the corrected brightness mean value according to the adaptive ratio value factor;
[0155] Optionally, the second calculation unit 606 includes:
[0156] Calculate the adaptive ratio value factor according to the segmented backlight target image and the number of pixels of the L-channel image;
[0157] Calculate the corrected brightness mean value according to the adaptive ratio value factor and the channel image brightness mean value.
[0158] The third calculation unit 607 is used to calculate the statistical distribution functions of the backlight target image and the background image;
[0159] Optionally, the third calculation unit 607 includes:
[0160] An acquisition module 6071, configured to acquire the probability density functions, histogram statistical information, first standard deviation, and second standard deviation of the backlight target image and the background image;
[0161] A second calculation module 6072, configured 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;
[0162] A first generation module 6073, configured to generate the sum of the total pixels of the backlight target image and the background image according to the histogram statistical information;
[0163] A first calculation module 6074, configured 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;
[0164] A segmentation module 6075, configured to segment the probability density function according to the upper and lower limits of the threshold;
[0165] A second generation module 6076, configured to generate a statistical distribution function according to the segmented probability density function;
[0166] A fourth calculation unit 608, configured to calculate the mapping function of the backlight target object and the background object according to the statistical distribution functions of the backlight target image and the background image and the corrected brightness mean value;
[0167] A third generation unit 609, configured to map and merge the background image and the backlight target image through the mapping function to generate an initial brightness correction image;
[0168] A fourth generation unit 610, configured to perform inverse color space conversion on the initial brightness correction image to generate a target brightness correction image.
[0169] Please refer to Figure 7 , this application provides an image brightness correction device, including:
[0170] A processor 701, a memory 702, an input / output unit 703, and a bus 704.
[0171] The processor 701 is connected to the memory 702, the input / output unit 703, and the bus 704.
[0172] The memory 702 stores a program, and the processor 701 calls the program to execute the methods as described in Figure 1 , Figure 2 and Figure 3 , Figure 4 and Figure 5 in.
[0173] This application provides a computer-readable storage medium with a program stored thereon. When the program is executed on a computer, it executes the methods in Figure 1 , Figure 2 and Figure 3 , Figure 4 and Figure 5 .
[0174] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the above-described systems, devices, and units can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.
[0175] In several embodiments provided by this 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 merely illustrative. For example, the division of the units is only a logical function division, and there can be other division methods in actual implementation. For example, 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 displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces, and the indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.
[0176] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0177] In addition, in each embodiment of this application, the functional units can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0178] When 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, in essence, 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 and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, read-only memory), random access memories (RAM, random access memory), magnetic disks, or optical discs that can store program codes.
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 processing apparatus and method with contrast correction.
EP2073170A1