Illumination non-uniform image shadow correction method and system based on residual analysis and pixel resetting, and medium

CN122929149APending Publication Date: 2026-10-16HANGZHOU HUIDA HIGH PRECISION EQUIPMENT TECHNOLOGY CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610792551.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-03
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

大多数传统方法(如多项式拟合)严格基于光照分量的物理模型(如余弦四次方定律),但当实际光照环境复杂(如包含多个光源、反射光、散射光)时,简化的数学模型难以精确描述真实的光照分布

Benefits of technology

[0057]As can be seen from the above, the method, system, and medium for correcting shadows in an image with uneven illumination based on residual analysis and pixel resetting provided in this application embodiment involve acquiring the original image to be corrected. If the original image to be corrected is a color image, it is converted from the RGB color space to the HSV color space, and the luminance component V, chrominance component H, and saturation component S are extracted. The original image to be corrected is logarithmically processed, decomposing it into an additive model of illumination and reflection components to generate an illumination-reflection model. Adaptive mean filtering is applied to the illumination and reflection components according to the illumination-reflection model, and a residual image is obtained. Pixel resetting processing is performed on the residual image according to the residual statistical data to obtain the corrected logarithmic reflection component. The corrected logarithmic reflection component is subjected to exponential transformation processing to obtain the corrected reflection image. The corrected reflection image is converted to the RGB color space to obtain the final color-corrected image. By converting the image to the HSV space, shadow correction is performed only on the luminance component V, while keeping the hue component H and saturation component S unchanged. Finally, it is converted back to the RGB space to ensure the color fidelity of the corrected image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122929149A_ABST
    Figure CN122929149A_ABST
Patent Text Reader

Abstract

The application provides a light non-uniform image shadow correction method and system based on residual analysis and pixel resetting, and a medium, the method comprising: obtaining an original image to be corrected; if the original image to be corrected is a color image, converting to an HSV color space, extracting a brightness component V, a chroma component H and a saturation component S; taking logarithmic processing on the original image to be corrected, generating an illumination-reflection model, performing adaptive mean filtering, and obtaining a residual image; performing pixel resetting processing on the residual image according to residual statistical rule data, obtaining a corrected logarithmic reflection component, performing exponential transformation processing, converting the corrected reflection image to an RGB color space, and obtaining a final color corrected image; and converting the image to an HSV space, performing shadow correction only on the brightness component V, and converting back to the RGB space to ensure the color fidelity of the corrected image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of machine vision and image processing technology, and more specifically, to a method, system, and medium for correcting shadows in images with uneven illumination based on residual analysis and pixel resetting. Background Technology

[0002] In machine vision applications, the quality of acquired images directly determines the accuracy and robustness of subsequent advanced processing tasks such as image segmentation, feature extraction, and object recognition. However, in complex environments such as industrial online inspection, outdoor monitoring, and medical imaging, acquired images often exhibit uneven illumination due to factors such as uneven light source illumination, complex object surface geometry, lens shading effects, or ambient light interference. This means that some areas of the image are too bright while others are too dark. This uneven illumination typically manifests in the image as a slowly varying background brightness component superimposed on the actual object reflection component. From a frequency domain perspective, the illumination component is mainly present in the low-frequency range, while the details, edges, and textures of the object surface correspond to the high-frequency components.

[0003] Uneven lighting or shadowing poses a significant challenge to machine vision systems. For example, in surface defect detection, uneven lighting can cause defects in dark areas to fail to be detected by the algorithm due to low contrast, while false textures in bright areas may be misidentified as defects. Traditional solutions, such as thresholding, often fail on images with uneven lighting because a single threshold cannot adapt to changes in brightness across the entire image. Therefore, designing an effective shadow correction algorithm to estimate and compensate for the illumination components in the image, restoring the object's original reflective properties, is a crucial prerequisite for improving the performance of machine vision systems.

[0004] Existing methods are overly dependent on filtering parameters and lack adaptability. This is especially true for spatial filtering methods (such as mean filtering and Gaussian filtering), where the kernel size is a crucial hyperparameter. For an image with uneven illumination, the gradient rate of change in shadow regions may differ at different locations. A fixed kernel size cannot simultaneously adapt to both gently changing shadow regions and steep edge regions. If the kernel size is small, while it can better estimate illumination changes near object edges, it easily misinterprets texture details (high-frequency information) as illumination components (low-frequency information), resulting in a weakening of the true texture of objects in the corrected image—a phenomenon known as "overcorrection." Conversely, if the kernel size is large, the filtered background image becomes too smooth, failing to accurately describe rapid brightness changes at shadow boundaries, leading to noticeable brightness jumps at shadow boundaries even after correction—a phenomenon known as "undercorrection." Existing solutions typically rely on manual trial and error to adjust this parameter, which is inefficient and makes it difficult to guarantee consistency in batch processing.

[0005] Secondly, the processing methods for image residuals are simplistic and fail to uncover the statistical patterns within them. Both homomorphic filtering and the Retinex algorithm typically employ direct addition, subtraction, or simple division when processing image residuals (i.e., the difference between the original image and the estimated background image). This approach treats all information in the residuals (including true target details, noise, and residual shadow components due to inaccurate background estimation) equally. However, from a signal analysis perspective, brightness deviations caused by uneven illumination often exhibit certain statistical distribution patterns in the residual image (e.g., in local regions, gray values ​​deviating from the background often show a symmetrical distribution or possess specific peak characteristics), while noise and target details have different statistical properties. Existing techniques fail to utilize these statistical patterns for refined processing of the residuals, resulting in a decreased signal-to-noise ratio in the corrected image or residual shadows.

[0006] Secondly, the integration of physical models and data-driven approaches is insufficient. Most traditional methods (such as polynomial fitting) are strictly based on physical models of illumination components (such as the fourth cosine law). However, when the actual lighting environment is complex (such as containing multiple light sources, reflected light, and scattered light), simplified mathematical models struggle to accurately describe the true illumination distribution. Purely data-driven methods (such as CLAHE) completely deviate from physical models, potentially compromising the physical realism of the image. Currently, there is a lack of a method that organically combines physical models (for quickly estimating illumination trends through mean filtering) with statistical data characteristics (for pixel resetting by analyzing residual distribution).

[0007] Finally, existing methods often process each channel independently when handling color images, leading to color distortion. Simple channel-by-channel correction strategies disrupt the proportional relationships between channels in the original image, causing tone shifts, which is fatal for machine vision tasks that rely on color features for recognition (such as drug sorting and printed material inspection). Summary of the Invention

[0008] The purpose of this application is to provide a method, system, and medium for correcting shadows in images with uneven illumination based on residual analysis and pixel resetting. By converting the image to HSV space, shadow correction is performed only on the luminance component V, while keeping the hue component H and saturation component S unchanged. Finally, the image is converted back to RGB space to ensure the color fidelity of the corrected image.

[0009] This application embodiment also provides a method for correcting shadows in an image with uneven illumination based on residual analysis and pixel resetting, including: acquiring the original image to be corrected; if the original image to be corrected is a color image, converting the original image to be corrected from the RGB color space to the HSV color space, and extracting the luminance component V, chrominance component H and saturation component S.

[0010] The original image to be corrected is logarithmically processed, and then decomposed into an additive model of illumination and reflection components to generate an illumination-reflection model.

[0011] Adaptive mean filtering is applied to the illumination and reflection components based on the illumination-reflection model, and the residual image is obtained.

[0012] The residual image is pixel-reset based on the residual statistical data to obtain the corrected logarithmic reflectance component.

[0013] The corrected logarithmic reflectance component is subjected to an exponential transform to obtain the corrected reflectance image. The corrected reflectance image is then converted to the RGB color space to obtain the final color-corrected image.

[0014] Optionally, in the image shadow correction method based on residual analysis and pixel resetting for uneven illumination described in the embodiments of this application, the illumination-reflection model will... For lighting components With reflection component The product of:

[0015]

[0016] in, Represents the coordinates of image pixels. , M and N are the width and height of the image, respectively. , lighting component With reflection component Take the logarithm, the formula is as follows:

[0017] .

[0018] Optionally, in the illumination non-uniformity image shadow correction method based on residual analysis and pixel resetting described in the embodiments of this application, the logarithmic image is calculated. gradient magnitude :

[0019] ;

[0020] in, and These represent the partial derivatives of the image in the x and y directions, respectively;

[0021] Define pixel Adaptive filter kernel size at the location for:

[0022] ;

[0023] In the formula, and These are the preset minimum and maximum filter kernel sizes, respectively. This represents the maximum value of the image gradient. It is a positive number. This indicates rounding down to the nearest integer.

[0024] Optionally, in the image shadow correction method based on residual analysis and pixel resetting for uneven illumination described in this application embodiment, an adaptive weight matrix is ​​constructed based on the adaptive kernel size calculated for each pixel, and a weighted average is performed on the pixels in the local neighborhood to obtain the logarithmic illumination component after adaptive mean filtering. The formula is as follows:

[0025] ;

[0026] in, , It is a weighting function;

[0027] Weighting function Using a two-dimensional Gaussian function, the formula is as follows:

[0028] ;

[0029] It is the standard deviation of the spatial domain. ;

[0030] Logarithmic illumination components are obtained using an adaptive weighted average algorithm. ;

[0031] Calculate the logarithmic residual image The formula is as follows:

[0032] .

[0033] Optionally, in the illumination non-uniformity image shadow correction method based on residual analysis and pixel resetting described in the embodiments of this application, the residual image is subjected to pixel resetting processing according to the residual statistical law data to obtain the corrected logarithmic reflectance component, specifically including:

[0034] Divide the residual image into multiple local windows and calculate the mode and mean of the residual values ​​in each local window;

[0035] Calculate the local window lighting deviation value based on the mode and mean of the residual values ​​within the local window;

[0036] The residual value of the center pixel is reset based on the illumination deviation value to obtain the corrected logarithmic reflection component.

[0037] Optionally, in the illumination non-uniformity image shadow correction method based on residual analysis and pixel resetting described in the embodiments of this application, the logarithmic reflectance component The formula for exponential transformation is as follows:

[0038]

[0039] This is the corrected reflection image.

[0040] Secondly, embodiments of this application provide a shadow correction system for uneven illumination images based on residual analysis and pixel resetting. The system includes a memory and a processor. The memory includes a program for a shadow correction method for uneven illumination images based on residual analysis and pixel resetting. When the program for the shadow correction method for uneven illumination images based on residual analysis and pixel resetting is executed by the processor, it performs the following steps:

[0041] Obtain the original image to be corrected. If the original image to be corrected is a color image, convert the original image to be corrected from the RGB color space to the HSV color space and extract the luminance component V, chrominance component H and saturation component S.

[0042] The original image to be corrected is logarithmically processed, and then decomposed into an additive model of illumination and reflection components to generate an illumination-reflection model.

[0043] Adaptive mean filtering is applied to the illumination and reflection components based on the illumination-reflection model, and the residual image is obtained.

[0044] The residual image is pixel-reset based on the residual statistical data to obtain the corrected logarithmic reflectance component.

[0045] The corrected logarithmic reflectance component is subjected to an exponential transform to obtain the corrected reflectance image. The corrected reflectance image is then converted to the RGB color space to obtain the final color-corrected image.

[0046] Optionally, in the illumination non-uniformity image shadow correction system based on residual analysis and pixel resetting described in this application embodiment, the illumination-reflection model will... For lighting components With reflection component The product of:

[0047]

[0048] in, Represents the coordinates of image pixels. , M and N are the width and height of the image, respectively. , lighting component With reflection component Take the logarithm, the formula is as follows:

[0049] .

[0050] Optionally, in the illumination non-uniformity image shadow correction system based on residual analysis and pixel resetting described in the embodiments of this application, the logarithmic image is calculated. gradient magnitude :

[0051] ;

[0052] in, and These represent the partial derivatives of the image in the x and y directions, respectively;

[0053] Define pixel Adaptive filter kernel size at the location for:

[0054] ;

[0055] In the formula, and These are the preset minimum and maximum filter kernel sizes, respectively. This represents the maximum value of the image gradient. It is a positive number. This indicates rounding down to the nearest integer.

[0056] Thirdly, embodiments of this application also provide a computer-readable storage medium, which includes a program for a method of correcting shadows of an image with uneven illumination based on residual analysis and pixel resetting. When the program for correcting shadows of an image with uneven illumination based on residual analysis and pixel resetting is executed by a processor, it implements the steps of the method for correcting shadows of an image with uneven illumination based on residual analysis and pixel resetting as described in any of the preceding claims.

[0057] As can be seen from the above, the method, system, and medium for correcting shadows in an image with uneven illumination based on residual analysis and pixel resetting provided in this application embodiment involve acquiring the original image to be corrected. If the original image to be corrected is a color image, it is converted from the RGB color space to the HSV color space, and the luminance component V, chrominance component H, and saturation component S are extracted. The original image to be corrected is logarithmically processed, decomposing it into an additive model of illumination and reflection components to generate an illumination-reflection model. Adaptive mean filtering is applied to the illumination and reflection components according to the illumination-reflection model, and a residual image is obtained. Pixel resetting processing is performed on the residual image according to the residual statistical data to obtain the corrected logarithmic reflection component. The corrected logarithmic reflection component is subjected to exponential transformation processing to obtain the corrected reflection image. The corrected reflection image is converted to the RGB color space to obtain the final color-corrected image. By converting the image to the HSV space, shadow correction is performed only on the luminance component V, while keeping the hue component H and saturation component S unchanged. Finally, it is converted back to the RGB space to ensure the color fidelity of the corrected image. Attached Figure Description

[0058] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0059] Figure 1 A flowchart of the illumination non-uniformity image shadow correction method based on residual analysis and pixel resetting provided in the embodiments of this application;

[0060] Figure 2 This is a flowchart illustrating the image shadow correction process in a specific embodiment of this application.

[0061] Figure 3 Image correction scene diagram provided for embodiments of this application. Detailed Implementation

[0062] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0063] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, the terms "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0064] Please refer to Figures 1-3 As shown, the method for correcting shadows in images with uneven illumination based on residual analysis and pixel resetting is used in a terminal device. This method includes the following steps:

[0065] S101, Obtain the original image to be corrected. If the original image to be corrected is a color image, convert the original image to be corrected from the RGB color space to the HSV color space and extract the luminance component V, chrominance component H and saturation component S.

[0066] S102, take the logarithm of the original image to be corrected, decompose the original image to be corrected into an additive model of illumination component and reflection component, and generate illumination-reflection model;

[0067] S103, Adaptive mean filtering is performed on the illumination and reflection components according to the illumination-reflection model, and the residual image is obtained;

[0068] S104, The residual image is pixel-reset according to the residual statistical law data to obtain the corrected logarithmic reflectance component;

[0069] S105, the corrected logarithmic reflectance component is subjected to exponential transformation to obtain the corrected reflectance image, and the corrected reflectance image is converted to the RGB color space to obtain the final color-corrected image.

[0070] According to an embodiment of the present invention, the illumination-reflection model will display the image. For lighting components With reflection component The product of:

[0071]

[0072] in, Represents the coordinates of image pixels. , M and N represent the width and height of the image, respectively. Illumination components. Describes the light intensity distribution of a scene, which varies slowly in space, is mainly concentrated in the low-frequency range, and satisfies... Reflection component Describing an object's surface's ability to reflect light, it is determined by the object's material and texture, contains high-frequency detail information of the image, and theoretically... To convert the multiplication model into an addition model that is easier for signal processing, the logarithm of both sides of equation (1) is usually taken:

[0073]

[0074] The core of this invention lies in the logarithmic image In this process, the logarithmic illumination component is adaptively estimated. And by analyzing the logarithmic residuals By analyzing the distribution pattern of pixels, the pixels are reset, ultimately restoring the true reflection components. .

[0075] According to an embodiment of the present invention, the logarithmic image is calculated. gradient magnitude :

[0076] ;

[0077] in, and These represent the partial derivatives of the image in the x and y directions, respectively;

[0078] Define pixel Adaptive filter kernel size at the location for:

[0079] ;

[0080] In the formula, and These are the preset minimum and maximum filter kernel sizes, respectively. This represents the maximum value of the image gradient. It is a positive number. This indicates rounding down to the nearest integer.

[0081] It should be noted that the size of the filter kernel should be related to the flatness of the local area: in flat areas of the image (small gradient), the illumination component changes very slowly, and a large kernel should be used to fully smooth noise and avoid introducing texture; in image edges or textured areas (large gradient), a small kernel should be used to protect details in order not to mistake sharp edges for illumination components.

[0082] According to an embodiment of the present invention, an adaptive weight matrix is ​​constructed based on the adaptive kernel size calculated for each pixel, and a weighted average is performed on the pixels in the local neighborhood to obtain the logarithmic illumination component after adaptive mean filtering. The formula is as follows:

[0083] ;

[0084] in, , It is a weighting function;

[0085] Weighting function Using a two-dimensional Gaussian function, the formula is as follows:

[0086] ;

[0087] It is the standard deviation of the spatial domain. ;

[0088] Logarithmic illumination components are obtained using an adaptive weighted average algorithm. ;

[0089] Calculate the logarithmic residual image The formula is as follows:

[0090] .

[0091] According to an embodiment of the present invention, the residual image is pixel-reset based on residual statistical data to obtain the corrected logarithmic reflectance component, specifically including:

[0092] Divide the residual image into multiple local windows and calculate the mode and mean of the residual values ​​in each local window;

[0093] Calculate the local window lighting deviation value based on the mode and mean of the residual values ​​within the local window;

[0094] The residual value of the center pixel is reset based on the illumination deviation value to obtain the corrected logarithmic reflection component.

[0095] It should be noted that the present invention performs a reset process on the residual image based on local statistical regularities to further filter out residual low-frequency interference.

[0096] The residual image is divided into a series of local windows (the window size can be a fixed value). ,For example For each window, analyze the residual values ​​of all pixels within the window. The statistical properties. Assuming the reflectivity of an object's surface is within a sufficiently small local window. It should fluctuate around a central value, and its statistical histogram should have a unimodal or approximately symmetrical characteristic, while the residual illumination component will cause the mean of the entire window to shift.

[0097] Based on this, the present invention proposes a pixel resetting method based on "mode-guided mean adjustment". First, the mode (Mode) of the residual values ​​within the local window is calculated. :

[0098]

[0099] in, Indicated by A local window centered on the center. This is the grayscale histogram of the window. The mode represents the most frequently occurring residual value within the window. Since the texture details of an object's surface are typically sparse, the residual values ​​in most areas of the window (background or smooth areas) should be close to the true mean of the reflectance components. Therefore, the mode is a robust estimate of the true reflectance component level within the window.

[0100] Next, calculate the mean of the residuals within the window. :

[0101]

[0102] Window mean Because all pixels are affected, if the window contains residual low-frequency shadow components, the mean will deviate from the true reflection center value. This invention defines the deviation between the mean and the mode. For residual illumination component error:

[0103]

[0104] Assumption bias The variation is slow in a localized area, representing a systematic bias within that area due to inaccurate lighting estimation. To eliminate this bias, the center pixel... The residual values ​​are reset to obtain the corrected logarithmic reflection component. :

[0105]

[0106] In the formula, It is an adjustment factor between 0 and 1, used to control the correction strength. By subtracting... The deviation of several times effectively pulls the residual distribution center of the local window back to near the mode, that is, closer to the true reflection component. This step is the core of the innovation of this invention. It uses the statistical law of the residual signal (the mode represents the true center) to compensate for the mean drift (representing residual illumination).

[0107] According to an embodiment of the present invention, the logarithmic reflection component The formula for exponential transformation is as follows:

[0108]

[0109] This is the corrected reflection image.

[0110] It should be noted that for color images, directly applying the above steps to each of the three RGB channels independently can easily disrupt the proportional relationship between the channels, leading to hue shift. Therefore, this invention proposes processing in the luminance-chrominance space. Specifically, the original color image is converted from the RGB space to the HSV (hue, saturation, luminance) color space. Since the human eye is most sensitive to luminance details, and uneven illumination mainly affects the luminance component V channel, this invention applies the above-mentioned shadow correction method based on residual analysis and pixel resetting only to the V channel to obtain the corrected luminance component. For the hue component (H) and saturation component (S), which primarily carry color information, they are relatively less affected by uneven lighting. To maintain the authenticity of the original colors, no processing is done on H and S, and their original values ​​are preserved. and Finally, , and The three components are combined and then converted back to the RGB color space to obtain the final color-corrected image. This process ensures that while effectively correcting uneven lighting, the color information of the original image is perfectly preserved.

[0111] According to embodiments of the present invention, a nonlinear function can be used to map the relationship between the gradient and the kernel size, such as an exponential decay function or a sigmoid function, to adapt to application scenarios with gradients varying under different illumination conditions. Furthermore, a weighting function is used for smoothing. Besides using the Gaussian function, a bilateral filter kernel function can also be used, which considers both spatial distance and the similarity of pixel grayscale values. Replace with the product of the spatial domain kernel and the range kernel:

[0112]

[0113] in Using the range standard deviation can better prevent smoothing across edges, making the estimation of lighting components more accurate, but the computational cost is relatively large.

[0114] According to embodiments of the present invention, the HSV color space is used for luminance-chrominance separation. Other color spaces with luminance-chrominance separation characteristics, such as the Lab color space or the YCbCr color space, can also be used. In the Lab space, the L channel represents luminance, and the a and b channels represent the opposite dimensions of color. In the YCbCr space, the Y channel represents luminance, and Cb and Cr represent chrominance. Similarly, by performing the shading correction of the present invention only on the luminance channel L or Y, while keeping the a and b or Cb and Cr channels unchanged, and finally converting back to the RGB space, the purpose of preserving color can also be achieved. Choosing different color spaces may have a slight impact on the fidelity of the final color; the choice can be made according to the specific image acquisition device and application requirements.

[0115] In summary, the present invention has the following significant beneficial effects and advantages:

[0116] First, it achieves adaptive parameter selection, significantly improving the robustness of the algorithm. By defining an adaptive filter kernel size mechanism based on local gradient information, this invention completely eliminates the dependence on manually setting the filter kernel size in traditional methods. It automatically uses a small kernel to protect details in areas with complex image textures and a large kernel to smooth the background in flat areas. This dynamically balances the contradiction between "smoothing illumination" and "preserving texture" during the estimation of illumination components, effectively avoiding the problems of "overcorrection" or "undercorrection" caused by traditional fixed kernel filtering.

[0117] Second, by deeply mining and utilizing the statistical regularities of the residual signal, pixel-level fine correction was achieved. Existing technologies typically use residual... It is directly considered as a reflection component. This invention creatively proposes a "mode-guided mean adjustment" pixel resetting strategy. This method, based on the statistical distribution characteristics of the residuals within a local window, identifies and compensates for systematic biases caused by inaccurate estimation of the illumination components. This mechanism is equivalent to "purifying" the initially estimated reflection components, further filtering out residual low-frequency illumination interference, while protecting the residual fluctuations that represent true details, resulting in a more natural contrast and clearer details in the final restored image.

[0118] Third, by organically combining physical model estimation with data statistical driving, the correction effect is closer to physical reality. This invention first employs logarithmic transformation and adaptive mean filtering based on the illumination-reflection physical model (physics / model driving) to quickly estimate the general trend of illumination; subsequently, it utilizes the local statistical characteristics of the residual image (data / statistics driving) to refine the estimation result. This two-stage cascaded architecture leverages both the computational efficiency and interpretability of the physical model and the advantages of data statistical methods in correcting model errors, resulting in a corrected image that conforms to physical laws (uniform illumination) and possesses good visual fidelity.

[0119] Fourth, a luminance channel-independent correction scheme based on the HSV color space is proposed for color images, perfectly preserving color information. For color images, this invention does not employ simple channel-by-channel processing, but cleverly utilizes the HSV color space to separate luminance and color information. By correcting only the V channel and then merging it with the original H and S channels after correction, this invention completely solves the problem of uneven illumination while ensuring the absolute invariance of the original image's hue and saturation. This completely resolves the common hue shift problem in color correction, which is crucial for machine vision applications requiring high-precision color detection.

[0120] Secondly, embodiments of this application provide a shadow correction system for uneven illumination images based on residual analysis and pixel resetting. The system includes a memory and a processor. The memory includes a program for a shadow correction method for uneven illumination images based on residual analysis and pixel resetting. When the program for the shadow correction method for uneven illumination images based on residual analysis and pixel resetting is executed by the processor, it performs the following steps:

[0121] Obtain the original image to be corrected. If the original image to be corrected is a color image, convert the original image to be corrected from the RGB color space to the HSV color space and extract the luminance component V, chrominance component H and saturation component S.

[0122] The original image to be corrected is logarithmically processed, and then decomposed into an additive model of illumination and reflection components to generate an illumination-reflection model.

[0123] Adaptive mean filtering is applied to the illumination and reflection components based on the illumination-reflection model, and the residual image is obtained.

[0124] The residual image is pixel-reset based on the residual statistical data to obtain the corrected logarithmic reflectance component.

[0125] The corrected logarithmic reflectance component is subjected to an exponential transform to obtain the corrected reflectance image. The corrected reflectance image is then converted to the RGB color space to obtain the final color-corrected image.

[0126] According to an embodiment of the present invention, the illumination-reflection model will display the image. For lighting components With reflection component The product of:

[0127]

[0128] in, Represents the coordinates of image pixels. , M and N are the width and height of the image, respectively. , lighting component With reflection component Take the logarithm, the formula is as follows:

[0129] .

[0130] According to an embodiment of the present invention, the logarithmic image is calculated. gradient magnitude :

[0131] ;

[0132] in, and These represent the partial derivatives of the image in the x and y directions, respectively;

[0133] Define pixel Adaptive filter kernel size at the location for:

[0134] ;

[0135] In the formula, and These are the preset minimum and maximum filter kernel sizes, respectively. This represents the maximum value of the image gradient. It is a positive number. This indicates rounding down to the nearest integer.

[0136] A third aspect of the present invention provides a computer-readable storage medium including a program for a method of correcting shadows of an image with uneven illumination based on residual analysis and pixel resetting. When the program is executed by a processor, it implements the steps of the method of correcting shadows of an image with uneven illumination based on residual analysis and pixel resetting as described above.

[0137] This invention discloses a method, system, and medium for correcting shadows in images with uneven illumination based on residual analysis and pixel resetting. The method involves acquiring the original image to be corrected. If the original image is a color image, it is converted from the RGB color space to the HSV color space, and the luminance component (V), chrominance component (H), and saturation component (S) are extracted. The original image is then logarithmically processed, decomposing it into an additive model of illumination and reflection components to generate an illumination-reflection model. Adaptive mean filtering is applied to the illumination and reflection components according to the illumination-reflection model, and a residual image is obtained. Pixel resetting is performed on the residual image based on the residual statistical data to obtain the corrected logarithmic reflection component. The corrected logarithmic reflection component is then subjected to exponential transformation to obtain the corrected reflection image. This reflection image is converted to the RGB color space to obtain the final color-corrected image. By converting the image to the HSV space, shadow correction is performed only on the luminance component (V), while keeping the hue component (H) and saturation component (S) unchanged. Finally, the image is converted back to the RGB space to ensure the color fidelity of the corrected image.

[0138] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.

[0139] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.

[0140] In addition, in the various embodiments of the present invention, each functional unit can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.

[0141] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0142] Alternatively, if the integrated units of the present invention are implemented as software functional modules and sold or used as independent products, they can also be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.

Claims

1. A method for correcting shadows in images with uneven illumination based on residual analysis and pixel resetting, characterized in that, include: Obtain the original image to be corrected. If the original image to be corrected is a color image, convert the original image to be corrected from the RGB color space to the HSV color space and extract the luminance component V, chrominance component H and saturation component S. The original image to be corrected is logarithmically processed, and then decomposed into an additive model of illumination and reflection components to generate an illumination-reflection model. Adaptive mean filtering is applied to the illumination and reflection components based on the illumination-reflection model, and the residual image is obtained. The residual image is pixel-reset based on the residual statistical data to obtain the corrected logarithmic reflectance component. The corrected logarithmic reflectance component is subjected to an exponential transform to obtain the corrected reflectance image. The corrected reflectance image is then converted to the RGB color space to obtain the final color-corrected image.

2. The method for correcting shadows in images with uneven illumination based on residual analysis and pixel resetting according to claim 1, characterized in that, The illumination-reflection model will display the image. For lighting components With reflection component The product of: ; in, Represents the coordinates of image pixels. , M and N are the width and height of the image, respectively. , lighting component With reflection component Take the logarithm, the formula is as follows: 。 3. The method for correcting shadows in images with uneven illumination based on residual analysis and pixel resetting according to claim 2, characterized in that, Calculate the logarithmic graph gradient magnitude : ; in, and These represent the partial derivatives of the image in the x and y directions, respectively; Define pixel Adaptive filter kernel size at the location for: ; In the formula, and These are the preset minimum and maximum filter kernel sizes, respectively. This represents the maximum value of the image gradient. It is a positive number. This indicates rounding down to the nearest integer.

4. The method for correcting shadows in images with uneven illumination based on residual analysis and pixel resetting according to claim 3, characterized in that, Based on the adaptive kernel size calculated for each pixel, a size-adaptive weight matrix is ​​constructed. A weighted average is then applied to the pixels within the local neighborhood to obtain the logarithmic illumination component after adaptive mean filtering. The formula is as follows: ; in, , It is a weighting function; Weighting function Using a two-dimensional Gaussian function, the formula is as follows: ; It is the standard deviation of the spatial domain. ; Logarithmic illumination components are obtained using an adaptive weighted average algorithm. ; Calculate the logarithmic residual image The formula is as follows: 。 5. The method for correcting shadows in images with uneven illumination based on residual analysis and pixel resetting according to claim 3, characterized in that, Based on the statistical regularity data of the residual image, pixel resetting processing is performed to obtain the corrected logarithmic reflectance component, which specifically includes: Divide the residual image into multiple local windows and calculate the mode and mean of the residual values ​​in each local window; Calculate the local window lighting deviation value based on the mode and mean of the residual values ​​within the local window; The residual value of the center pixel is reset based on the illumination deviation value to obtain the corrected logarithmic reflection component.

6. The method for correcting shadows in images with uneven illumination based on residual analysis and pixel resetting according to claim 5, characterized in that, Logarithmic reflection component The formula for exponential transformation is as follows: ; This is the corrected reflection image.

7. A system for correcting shadows in images with uneven illumination based on residual analysis and pixel resetting, characterized in that, The system includes a memory and a processor. The memory contains a program for a method of correcting shadows in images with uneven illumination based on residual analysis and pixel resetting. When the program for correcting shadows in images with uneven illumination based on residual analysis and pixel resetting is executed by the processor, it performs the following steps: Obtain the original image to be corrected. If the original image to be corrected is a color image, convert the original image to be corrected from the RGB color space to the HSV color space and extract the luminance component V, chrominance component H and saturation component S. The original image to be corrected is logarithmically processed, and decomposed into an additive model of illumination and reflection components. Adaptive mean filtering is applied to the illumination and reflection components based on the additive model of the illumination and reflection components, and the residual image is obtained. The residual image is pixel-reset based on the residual statistical data to obtain the corrected logarithmic reflectance component. The corrected logarithmic reflectance component is subjected to an exponential transform to obtain the corrected reflectance image. The corrected reflectance image is then converted to the RGB color space to obtain the final color-corrected image.

8. The illumination non-uniformity image shadow correction system based on residual analysis and pixel resetting according to claim 7, characterized in that, The illumination-reflection model will display the image. For lighting components With reflection component The product of: ; in, Represents the coordinates of image pixels. , M and N are the width and height of the image, respectively. , lighting component With reflection component Take the logarithm, the formula is as follows: 。 9. The illumination non-uniformity image shadow correction system based on residual analysis and pixel resetting according to claim 8, characterized in that, Calculate the logarithmic graph gradient magnitude : ; in, and These represent the partial derivatives of the image in the x and y directions, respectively; Define pixel Adaptive filter kernel size at the location for: ; In the formula, and These are the preset minimum and maximum filter kernel sizes, respectively. This represents the maximum value of the image gradient. It is a positive number. This indicates rounding down to the nearest integer.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a method program for correcting the shadow of an image with uneven illumination based on residual analysis and pixel resetting. When the method program is executed by a processor, it implements the steps of the method for correcting the shadow of an image with uneven illumination based on residual analysis and pixel resetting as described in any one of claims 1 to 6.