A method for adaptive adjustment of uneven illumination images
By using Retinex theory and the single-scale Retinex algorithm (SSR), the illumination invariant is separated and the brightness channel is corrected using a nonlinear exponential function, which solves the problem of uneven illumination in the face recognition system, realizes adaptive image adjustment, and maintains the overall uniformity of the image.
Patent Information
- Application Number
- CN202011622530.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-31
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2040-12-31
AI Technical Summary
When dealing with uneven lighting on faces in facial recognition systems, conventional methods often lead to changes in other details, making it difficult to effectively optimize the uneven lighting while keeping other parts unchanged.
The single-scale Retinex algorithm (SSR) based on Retinex theory is adopted to separate the illumination invariant. By calculating the difference between the reflection component and the image brightness channel, a nonlinear exponential function is used to correct the pixels in the brightness channel, thereby realizing the adaptive adjustment of uneven brightness in the image.
It effectively suppresses or compensates for pixel in the image brightness channel, corrects uneven parts of the image, ensures fine-tuning of other parts, and achieves an overall uniform image effect.
Smart Images

Figure CN114764832B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method for adaptively adjusting an image with uneven illumination. Background Art
[0002] In the face recognition system, the actual image is disturbed by external light sources, resulting in uneven illumination of the face, that is, some parts are bright and some are dark. In order to improve the accuracy of the face recognition system, the image is generally pre-processed (face alignment, filtering and denoising, etc.) to improve the image quality.
[0003] Common terms in the prior art are as follows:
[0004] Retinex theory: The color of an object is determined by its ability to reflect long-wave (red), medium-wave (green), and short-wave (blue) light, rather than by the absolute value of the reflected light intensity. The color of an object is not affected by the non-uniformity of illumination and is consistent, that is, retinex is based on color consistency (color constancy).
[0005] Single Scale Retinex (SSR): A given image S(x,y) can be decomposed into two different images: the reflection image R(x,y) and the incident image (also called the brightness image) L(x,y). The principle is as follows: Figure 1 As shown. Figure 1 As shown in the figure, the image can be regarded as an incident image and a reflected image. The incident light shines on the reflective object, and the reflected light enters the human eye through the reflection of the reflective object. Among them, R(x,y) represents the reflective property of the object, that is, the intrinsic property of the image, which should be retained to the greatest extent; while L(x,y) represents the incident light image, which determines the dynamic range that the image pixels can reach and should be removed as much as possible. Generally, the incident image is estimated as a spatially smoothed image.
[0006] At present, conventional methods such as image brightness enhancement and histogram equalization can improve or reduce the overall brightness of an image. When processing some overly bright areas, other details will also change. This is somewhat inconsistent with the purpose of only optimizing the uneven illumination part of the face while keeping other parts unchanged. Summary of the invention
[0007] In order to solve the above problems, the purpose of this method is: based on the Retinex theory, this application adopts the single-scale Retinex algorithm (SSR) to separate the illumination invariant (i.e., the reflection component), and obtains the uneven illumination part of the face image by calculating the difference between the reflection component and the image brightness channel (Y channel). According to the uneven illumination component, a correction function is proposed to compensate or suppress the pixels of the image brightness channel, thereby realizing adaptive adjustment of the uneven brightness of the image.
[0008] Specifically, the present invention provides a method for adaptively adjusting an image with uneven illumination, the method comprising the following steps:
[0009] S1, find the lighting invariant according to the SSR algorithm:
[0010] If it is a BGR three-channel color image, first perform color space conversion to convert BGR to YUV representation, and the Y channel is the image brightness information;
[0011] According to the Retinex theory, the SSR algorithm is used to obtain the invariant component of Y channel illumination;
[0012] S2, extract uneven illumination map:
[0013] Subtract the Y channel component from the Y channel illumination invariant component obtained in step S1 to obtain an illumination difference value; and normalize the illumination difference value;
[0014] S3, correct the image brightness component:
[0015] A correction function that can compensate or suppress image brightness channel pixels is used to achieve adaptive adjustment of uneven brightness of the image; a negative value of the correction function result indicates that the image brightness is large and a negative correction pixel needs to be added, and a positive value indicates that the image brightness is small and a positive correction pixel needs to be added; correction of uneven parts of the image is achieved through the suppression effect of negative values and the compensation effect of positive values; and the correction function is a nonlinear exponential function, and the larger the difference matrix value, the larger the correction amplitude;
[0016] S4, adding the Y channel component to the correction matrix to obtain the corrected Y component.
[0017] The step S1 further includes, if the image is a grayscale image, treating the grayscale image as a brightness component image, and performing adaptive adjustment on the uneven brightness of the grayscale image.
[0018] In the step S1, the single-scale SSR algorithm is used based on the Retinex theory to separate the illumination invariant, i.e., the reflection component, and the uneven illumination component of the face image is obtained by calculating the difference between the reflection component and the image brightness channel, i.e., the Y channel.
[0019] In step S1, the implementation method of the SSR algorithm is as follows:
[0020] S1.1, read the Y channel of the image. If the original image is a grayscale image, directly read the grayscale image, convert each pixel value from an integer to a floating point number, and then convert it to the logarithmic domain;
[0021] S1.2, estimate the incident component, also called brightness image: estimate the illumination change in the image by calculating the weighted average of the pixel in the image and the pixels in the surrounding area; in actual calculation, the Y channel or grayscale image read by S1.1 can be low-pass filtered using a Gaussian template, and the filtered image is converted to the logarithmic domain;
[0022] S1.3, calculate the illumination invariant component: in the logarithmic domain, subtract the incident component from the image read in S1.1 to obtain the illumination invariant component in the logarithmic domain;
[0023] S1.4, mapping the illumination invariant component result in the logarithmic domain to the real number domain;
[0024] S1.5, output reflection amount.
[0025] In the step S2, the illumination difference is obtained as shown in formula 1, and the illumination difference is normalized according to formula 2;
[0026] △Y=YR Formula 1
[0027]
[0028] Wherein, m = max(△Y), n = min(△Y);
[0029] Among them, Y is the image Y channel component matrix, △Y is the difference matrix between the Y channel component and the reflection component, △Y' is the difference matrix normalization matrix, and R is the reflection component matrix.
[0030] In step S3, the nonlinear brightness correction function is as shown in formula 3, where Represents the correction matrix; the threshold range of the pixel value that can be corrected by this correction function is The negative value in indicates that the image brightness is high and a negative correction pixel needs to be added. The positive value indicates that the image brightness is low and a positive correction pixel needs to be added. The correction of the uneven part of the image is achieved through the suppression effect of negative values and the compensation effect of positive values.
[0031]
[0032] Among them, μ=mean(△Y'), m=max(△Y); σ is the correction coefficient, which is used to adjust the correction pixel amplitude.
[0033] In step S3, σ is preferably set to an empirical value of 1.5.
[0034] In step S4, the corrected Y component is obtained, as shown in formula 4:
[0035]
[0036] in, Represents the corrected Y channel component.
[0037] Therefore, the advantages of the present application are: the present method has a good local suppression effect on the brighter areas in the difference matrix, and while ensuring fine-tuning of other uniform parts, it can adaptively adjust the brightness difference of the non-uniform parts to make the image as a whole tend to be uniform. And the present method proposes a correction function that can compensate or suppress the pixels of the image brightness channel, thereby realizing adaptive adjustment of the non-uniform brightness of the image. The correction of the non-uniform parts of the image is achieved through the suppression effect of negative values and the compensation effect of positive values. Moreover, the correction relationship is a nonlinear exponential function. The larger the difference matrix value, the larger the correction amplitude; the effect of partial fine-tuning and partial large-tuning can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.
[0039] Figure 1 It is a schematic diagram of the principle of reflected image and incident image.
[0040] Figure 2 It is a schematic diagram of the process of implementing this method.
[0041] Figure 3 It is a schematic diagram of the SSR algorithm module process.
[0042] FIG4( a ) is a diagram of the adaptive adjustment result Y of the uniform lena image.
[0043] FIG4( b ) is a diagram of the adaptive adjustment result △Y of the uniform lena image.
[0044] FIG4( c ) is a diagram showing the adaptive adjustment result Y~ of the uniform lena image.
[0045] Figure 5(a) is a diagram of the adaptive adjustment result Y of the non-uniform lena image.
[0046] Figure 5(b) is a diagram of the adaptive adjustment result △Y of the uneven lena image.
[0047] FIG5( c ) is a diagram of the adaptive adjustment result Y~ of the non-uniform lena image.
[0048] Figure 6 is a flow chart of an embodiment of the method. DETAILED DESCRIPTION
[0049] In order to more clearly understand the technical content and advantages of the present invention, the present invention is now further described in detail in conjunction with the accompanying drawings.
[0050] like Figure 6 The present invention relates to a method for adaptively adjusting an image with uneven illumination, the method comprising the following steps:
[0051] S1, find the lighting invariant according to the SSR algorithm:
[0052] If it is a BGR three-channel color image, first perform color space conversion to convert BGR to YUV representation, and the Y channel is the image brightness information;
[0053] According to the Retinex theory, the SSR algorithm is used to obtain the invariant component of Y channel illumination;
[0054] S2, extract uneven illumination map:
[0055] Subtract the Y channel component from the Y channel illumination invariant component obtained in step S1 to obtain an illumination difference value; and normalize the illumination difference value;
[0056] S3, correct the image brightness component:
[0057] A correction function that can compensate or suppress image brightness channel pixels is used to achieve adaptive adjustment of uneven brightness of the image; a negative value of the correction function result indicates that the image brightness is large and a negative correction pixel needs to be added, and a positive value indicates that the image brightness is small and a positive correction pixel needs to be added; correction of uneven parts of the image is achieved through the suppression effect of negative values and the compensation effect of positive values; and the correction function is a nonlinear exponential function, and the larger the difference matrix value, the larger the correction amplitude;
[0058] S4, adding the Y channel component to the correction matrix to obtain the corrected Y component.
[0059] Specifically, Figure 2 The flowchart of the method is shown below. The specific implementation steps of the method are described as follows:
[0060] Note: The capital letters in the formulas in this application represent matrices, and the lowercase letters represent scalar values; 1. Calculate the illumination invariant according to the SSR algorithm
[0061] If the image is a grayscale image, the grayscale image can be regarded as a brightness component image, and the uneven brightness of the grayscale image can be adaptively adjusted; if it is a BGR three-channel color image, the color space conversion is performed first, and the BGR is converted to YUV representation (the Y channel is the image brightness information).
[0062] According to the Retinex theory, the SSR algorithm is used to obtain the Y channel illumination invariant component. The implementation flow chart of the SSR algorithm module is shown in the attached figure. Figure 3 shown.
[0063] 2. Extracting uneven illumination maps
[0064] Subtract the Y channel component from the Y channel illumination invariant component obtained in step 1 (Formula 1) to obtain the illumination difference; and normalize the illumination difference according to Formula 2;
[0065] △Y=YR Formula 1
[0066]
[0067] Among them, m=max(△Y), n=min(△Y).
[0068] Among them, Y is the image Y channel component matrix, △Y is the difference matrix between the Y channel component and the reflection component, △Y' is the difference matrix normalization matrix, and R is the reflection component matrix.
[0069] 3. Correct the image brightness component
[0070] A nonlinear brightness correction function is proposed, as shown in Formula 3, where Represents the correction matrix; the threshold range of the pixel value that can be corrected by this correction function is A negative value in indicates that the image brightness is high and a negative correction pixel needs to be added. A positive value indicates that the image brightness is low and a positive correction pixel needs to be added. The correction of the uneven part of the image is achieved through the suppression effect of negative values and the compensation effect of positive values.
[0071]
[0072] Among them, μ=mean(△Y'), m=max(△Y); when σ takes the empirical value of 1.5, the correction result is better; 4. Get the corrected Y component
[0073]
[0074] in, represents the corrected Y channel component. As shown in Formula 4, the corrected Y component can be obtained by adding the Y channel component to the correction matrix.
[0075] As shown in (b) of Figures 4 and 5, it is the result of visualizing the △Y difference matrix mapped to the interval of 0 to 255; (a) in Figures 4 and 5 are the Y channel component of the original lena image and the Y channel component of the lena image after brightening it by 1.5 times; (c) in Figures 4 and 5 are the adaptive adjustment results of this method.
[0076] In addition, the present application proposes a correction function that can compensate or suppress the image brightness channel pixels, thereby realizing adaptive adjustment of uneven brightness of the image. A negative value of the correction function result indicates that the image brightness is relatively large, and a negative correction pixel needs to be added; a positive value indicates that the image brightness is relatively small, and a positive correction pixel needs to be added; correction of the uneven part of the image is realized through the suppression effect of negative values and the compensation effect of positive values. Moreover, the correction relationship is a nonlinear exponential function, and the larger the difference matrix value, the larger the correction amplitude; the effect of partial fine-tuning and partial major adjustment can be realized.
[0077] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for adaptively adjusting an image with uneven illumination, characterized in that: The method The following steps are involved: S1, find the lighting invariant according to the SSR algorithm: If it is a BGR three-channel color image, first perform color space conversion to convert BGR to YUV representation, and the Y channel is the image brightness information; According to the Retinex theory, the SSR algorithm is used to obtain the invariant component of Y channel illumination; The implementation method of the SSR algorithm is as follows: S1.1, read the Y channel of the image. If the original image is a grayscale image, directly read the grayscale image, convert each pixel value from an integer to a floating point number, and then convert it to the logarithmic domain; S1.2, estimate the incident component, also called brightness image: estimate the illumination change in the image by calculating the weighted average of the pixel in the image and the pixels in the surrounding area; in actual calculation, the Y channel or grayscale image read by S1.1 can be low-pass filtered using a Gaussian template, and the filtered image is converted to the logarithmic domain; S1.3, calculate the illumination invariant component: in the logarithmic domain, subtract the incident component from the image read in S1.1 to obtain the illumination invariant component in the logarithmic domain; S1.4, mapping the illumination invariant component result in the logarithmic domain to the real number domain; S1.5, output reflection component; S2, extract uneven illumination map: Subtract the Y channel component from the Y channel illumination invariant component obtained in step S1 to obtain an illumination difference value; and normalize the illumination difference value; The illumination difference is obtained as shown in Formula 1, and the illumination difference is normalized according to Formula 2; △Y=YR Formula 1 Wherein, m = max(△Y), n = min(△Y); Among them, Y is the image Y channel component matrix, △Y is the difference matrix between the Y channel component and the reflection component, △Y' is the difference matrix normalization matrix, and R is the reflection component matrix; S3, correct the image brightness component: A correction function that can compensate or suppress image brightness channel pixels is used to achieve adaptive adjustment of uneven brightness of the image; a negative value of the correction function result indicates that the image brightness is large and a negative correction pixel needs to be added, and a positive value indicates that the image brightness is small and a positive correction pixel needs to be added; correction of the uneven part of the image is achieved through the suppression effect of negative values and the compensation effect of positive values; and the correction function is a nonlinear exponential function, and the larger the difference matrix value, the larger the correction amplitude; the nonlinear brightness correction function is shown in Formula 3, where Represents the correction matrix; the range of pixel values that can be corrected by this correction function is The negative value in indicates that the image brightness is high and a negative correction pixel needs to be added. The positive value indicates that the image brightness is low and a positive correction pixel needs to be added. The correction of the uneven part of the image is achieved through the suppression effect of negative values and the compensation effect of positive values. Among them, μ = mean (△Y'), m = max (△Y); σ is the correction coefficient, which is used to adjust the correction pixel amplitude; S4, adding the Y channel component to the correction matrix to obtain the corrected Y component.
2. The method for adaptively adjusting an image with uneven illumination according to claim 1, characterized in that: The step S1 further includes, if the image is a grayscale image, treating the grayscale image as a brightness component image, and performing adaptive adjustment on the uneven brightness of the grayscale image.
3. The method for adaptively adjusting an image with uneven illumination according to claim 1, characterized in that: In the step S1, the single-scale SSR algorithm is used based on the Retinex theory to separate the illumination invariant, i.e., the reflection component, and the uneven illumination component of the face image is obtained by calculating the difference between the reflection component and the image brightness channel, i.e., the Y channel.
4. The method for adaptively adjusting an image with uneven illumination according to claim 1, characterized in that: In step S3, σ takes an empirical value of 1.
5.
5. The method for adaptively adjusting an image with uneven illumination according to claim 1, characterized in that: In step S4, the corrected Y component is obtained, as shown in formula 4: in, Represents the corrected Y channel component.
