Image shadow removal method and device, equipment, storage medium and program product

By detecting image brightness in HSV space and combining multi-scale Gaussian filtering and CLAHE processing, the accuracy and stability of shadow area processing in the image are solved, and shadow removal and image quality improvement are achieved.

CN120219186APending Publication Date: 2025-06-27CHINA MOBILE M2M +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510328779.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-19
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

The prior art is difficult to effectively distinguish and process shadowed and non-shaded areas in images under complex and variable lighting and environmental conditions, resulting in insufficient accuracy and stability.

Method used

By converting the grayscale image to the HSV space, the brightness components in the HSV image are detected to determine the shadowed area, and the shadowed area is subjected to multi-scale Gaussian filtering and contrast-limited adaptive histogram equalization CLAHE processing, and finally the multi-scale CLAHE processing results are fused to remove shadows.

Benefits of technology

Effectively distinguish between shadowed areas and non-shaded areas, improve the brightness and contrast of shadowed areas, maintain the naturalness of non-shaded areas, and thus improve the overall processing effect and visual quality of the image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120219186A_ABST
    Figure CN120219186A_ABST
Patent Text Reader

Abstract

The invention provides an image shadow removal method and device, equipment, a storage medium and a program product, and relates to the technical field of image processing, and the method comprises the steps: converting a grayscale image into an HSV space, and obtaining an HSV image; detecting a brightness component in the HSV image to determine a shadow region; performing multi-scale Gaussian filtering on the shadow region, and performing CLAHE processing on the filtered shadow region on each scale; and fusing the multi-scale CLAHE processing results to obtain an enhanced image after shadow removal. According to the invention, the brightness and contrast of the shadow area can be improved, the naturalness of the non-shadow area is maintained, and the overall processing effect and visual quality of the image are improved. Meanwhile, shadow areas and non-shadow areas can be effectively distinguished based on brightness component detection in the HSV image, different shadows in different areas can be effectively processed through multi-scale fusion, and a good effect is integrally presented.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular, to an image shadow removal method, apparatus, device, storage medium, and program product. Background Art

[0002] In the fields of image processing and computer vision, object detection and counting technologies have been widely applied. Traditional methods usually rely on the following several technologies: image preprocessing, CLAHE (Contrast Limited Adaptive Histogram Equalization), morphological operations, and Gaussian filtering, etc. Although these technologies can meet the requirements of shadow removal to a certain extent, their accuracy and stability still face challenges under complex and changeable lighting and environmental conditions. Therefore, how to effectively distinguish and process the shadow area and non-shadow area in an image has become an urgent problem to be solved. Summary of the Invention

[0003] The present invention provides an image shadow removal method, apparatus, device, storage medium, and program product, to solve the defect in the prior art of how to effectively distinguish and process the shadow area and non-shadow area in an image, and to achieve effective distinction between the shadow area and non-shadow area based on the luminance component detection in the HSV image. At the same time, through multi-scale fusion, different shadows in different regions can be effectively processed.

[0004] The present invention provides an image shadow removal method, including the following steps: Convert the grayscale image to the HSV space to obtain the HSV image; Detect the luminance component in the HSV image to determine the shadow area; Perform multi-scale Gaussian filtering on the shadow area, and perform Contrast Limited Adaptive Histogram Equalization (CLAHE) processing on the filtered shadow area at each scale; each scale in the multi-scale corresponds to a filter kernel with a different variance value; Fuse the results of multi-scale CLAHE processing to obtain an enhanced image with shadows removed.

[0005] According to the image shadow removal method provided by the present invention, the performing multi-scale Gaussian filtering on the shadow area includes: Generate a plurality of the filter kernels based on the Gaussian function; Perform a convolution operation on each of the filter kernels and the shadow area to perform multi-scale Gaussian filtering on the shadow area; Among them, the Gaussian function is provided with a gain term and a bias term. The gain term is used to adjust the intensity of the filter, and the bias term is used to adjust the baseline of the filter.

[0006] According to an image shadow removal method provided by the present invention, the contrast-limited adaptive histogram equalization (CLAHE) processing of the filtered shadow region at each scale includes: At each scale, the filtered shadow region is divided into a plurality of grid regions; Histogram equalization is performed on each of the grid regions to enhance the local contrast; The grid regions that have undergone histogram equalization are recombined to obtain the CLAHE processing result.

[0007] According to an image shadow removal method provided by the present invention, the detection of the luminance component in the HSV image to determine the shadow region includes: Each pixel in the HSV image is traversed, and the luminance value of each pixel is compared with a preset luminance threshold; The region where the luminance value is less than the preset luminance threshold is determined as the shadow region.

[0008] According to an image shadow removal method provided by the present invention, the fusion of the multi-scale CLAHE processing results to obtain the enhanced image after shadow removal includes: Determine the weight of each scale; According to the weight of each scale, the multi-scale CLAHE processing results are weighted and fused to obtain the enhanced image after shadow removal.

[0009] According to an image shadow removal method provided by the present invention, the grayscale image is generated based on the following method: Extract the R value, G value, and B value of each pixel from the color image to be processed; Perform weighted summation on the R value, G value, and B value of each pixel to obtain the grayscale value of each pixel; Generate the grayscale image according to the grayscale value of each pixel.

[0010] The present invention also provides an image shadow removal device, including the following modules: A conversion module, configured to convert the grayscale image to the HSV space to obtain an HSV image; A shadow region determination module, configured to detect the luminance component in the HSV image to determine the shadow region; The CLAHE processing module is used to perform multi-scale Gaussian filtering on the shadow area, and perform contrast-limited adaptive histogram equalization (CLAHE) processing on the filtered shadow area at each scale; each scale in the multi-scale corresponds to a filter kernel with a different variance value; The image shadow removal module is used to fuse the results of multi-scale CLAHE processing to obtain an enhanced image with shadows removed.

[0011] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the image shadow removal method described in any one of the above is implemented.

[0012] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the image shadow removal method described in any one of the above is implemented.

[0013] The present invention also provides a computer program product, including a computer program. When the computer program is executed by a processor, the image shadow removal method described in any one of the above is implemented.

[0014] The image shadow removal method, device, equipment, storage medium, and program product provided by the present invention convert a grayscale image to the HSV space to obtain an HSV image; detect the brightness component in the HSV image to determine the shadow area; perform multi-scale Gaussian filtering on the shadow area, and perform contrast-limited adaptive histogram equalization (CLAHE) processing on the filtered shadow area at each scale; fuse the results of multi-scale CLAHE processing to obtain an enhanced image with shadows removed. The present invention can improve the brightness and contrast of the shadow area and maintain the naturalness of the non-shadow area, thereby improving the overall processing effect and visual quality of the image. At the same time, based on the detection of the brightness component in the HSV image, the shadow area and the non-shadow area can be effectively distinguished. Through multi-scale fusion, different shadows in different areas can be effectively processed, and finally the shadows can be effectively removed, presenting a good overall effect. Description of the Drawings

[0015] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0016] Figure 1 It is a flowchart of the image shadow removal method provided by the present invention.

[0017] Figure 2 It is a schematic flow chart of the grayscale image shadow removal method provided by the present invention.

[0018] Figure 3 It is a schematic diagram of the original image provided by the present invention.

[0019] Figure 4 It is a schematic diagram of the original image processed by CLAHE provided by the present invention.

[0020] Figure 5 It is a schematic diagram of the original image processed by using the image shadow removal method provided by the present invention.

[0021] Figure 6 It is a schematic structural diagram of the image shadow removal device provided by the present invention.

[0022] Figure 7 It is a schematic structural diagram of the electronic device provided by the present invention. Detailed implementation manners

[0023] To make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below with reference to the accompanying drawings in the present invention. Apparently, the described embodiments are some but not all of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art without making creative efforts based on the embodiments in the present invention belong to the scope of protection of the present invention.

[0024] In the related art, for the convolution kernel generated by using the Gaussian function, in order to keep the brightness of the filtered image unchanged, the sum of the weights in the kernel is equal to 1, which is not good for removing shadows. In addition, although CLAHE can enhance the contrast of the image, in the case where the contrast difference between the shadow area and the non-shadow area is large, CLAHE may not be able to effectively distinguish shadows and actual objects, resulting in loss or misunderstanding of image details. In addition, in the shadow and low-brightness areas, CLAHE may amplify noise, resulting in a decrease in image quality. And for different lighting and different shadow conditions, its response effect is relatively single.

[0025] The present invention mainly solves the problem in the related art that the shadow area and the non-shadow area in the image cannot be effectively distinguished and processed. By detecting and specifically processing the shadow area, combining the multi-scale improved Gaussian filtering and the local contrast enhancement technology, this method can improve the brightness and contrast of the shadow area while maintaining the naturalness of the non-shadow area, thereby improving the overall processing effect and visual quality of the image. Through weighted multi-scale fusion, different shadows in different areas can be effectively processed, and finally the shadows are effectively removed, presenting a good overall effect.

[0026] The following will combine with Figures 1-7 describe the image shadow removal method, device, equipment, storage medium and program product of the present invention.

[0027] Figure 1 is a schematic flowchart of the image shadow removal method provided by the present invention. As Figure 1 shown, the method includes the following: Step 101, convert the grayscale image to the HSV space to obtain an HSV image.

[0028] It should be noted that the grayscale image refers to the grayscale image corresponding to the color image to be processed, and the color image to be processed refers to the color image with a shadow area.

[0029] In one embodiment, the grayscale image can be generated based on the following method: extract the R value, G value, and B value of each pixel from the color image to be processed; perform weighted summation on the R value, G value, and B value of each pixel to obtain the grayscale value of each pixel; generate a grayscale image according to the grayscale value of each pixel.

[0030] Specifically, generating a grayscale image by linearly combining RGB components means adding the three components of red (R), green (G), and blue (B) of each pixel in the color image according to certain weights to generate a grayscale value. Among them, the method of generating a grayscale image by linearly combining RGB components may include the following steps: 1) Obtain the color image: Read the color image to be processed, which is composed of three color channels of red (R), green (G), and blue (B).

[0031] 2) Extract RGB components: For each pixel in the color image, extract its red component R, green component G, and blue component B respectively.

[0032] 3) Calculate the grayscale value: According to the characteristics of the human eye's sensitivity to different colors, use the following formula to calculate the grayscale value: Y = 0.299R + 0.587G + 0.114B; where Y is the generated grayscale value; R, G, and B are the values of the red, green, and blue components respectively; the weights 0.299, 0.587, and 0.114 are set according to the human eye's sensitivity to different colors, and these weights ensure that the grayscale image can retain the visual information of the original color image as much as possible.

[0033] 4) Generate the grayscale image: Assign the calculated grayscale value to the corresponding pixel in the grayscale image to generate the final grayscale image.

[0034] Generating a grayscale image by linearly combining RGB components fully considers the differences in the sensitivity of the human eye to different colors and can generate a grayscale image that is more natural visually.

[0035] Further, the grayscale image is converted to the HSV space to obtain an HSV image. Specifically, each pixel in the grayscale image is converted from the RGB color space to the HSV color space. The three components of the HSV space: H (hue) represents the type of color, with a range of [0, 360) degrees; S (saturation) represents the purity of the color, with a range of [0, 1]; V (value) represents the brightness of the color, with a range of [0, 1]. Among them, the conversion method for converting the grayscale image to the HSV space is as follows: 1) Calculate the maximum value and the minimum value: maximum value = max(R, G, B), that is, the maximum value is the maximum of the R value, G value, and B value of the pixel; minimum value = min(R, G, B), that is, the minimum value is the minimum of the R value, G value, and B value of the pixel; 2) Calculate the hue H: If the maximum value is equal to the minimum value, then the hue H = 0; if the maximum value is equal to R, then H = 60 degrees × ((G - B) / (maximum value - minimum value)); if the maximum value is equal to G, then H = 60 degrees × (2 + (B - R) / (maximum value - minimum value)); if the maximum value is equal to B, then H = 60 degrees × (4 + (R - G) / (maximum value - minimum value)); if H < 0, then H = H + 360; 3) Calculate the saturation S: S = (maximum value - minimum value) / maximum value; 4) Calculate the brightness V: V = maximum value; 5) Generate an HSV image, and each pixel contains three components: H, S, and V.

[0036] Step 102, detect the brightness component in the HSV image to determine the shadow area.

[0037] In the HSV image, the brightness component (Value channel) is used to represent the light and dark information of the image. By detecting the brightness component, the shadow area in the image can be effectively identified.

[0038] In one embodiment, traverse each pixel in the HSV image, compare the brightness value of each pixel with a preset brightness threshold; determine the area where the brightness value is less than the preset brightness threshold as the shadow area. Specifically, the brightness component (V channel) directly reflects the light and dark information of the image, so the shadow area can be detected by analyzing the V channel. The brightness value of the shadow area is usually low because the shadow is caused by the light being blocked or weakened. Among them, the steps for detecting the shadow area can include: Step 1, Extract the luminance component (V channel): Extract the luminance value (i.e., the V channel) of each pixel from the HSV image; Step 2, Set the luminance threshold: Set a luminance threshold according to the characteristics of the shadow area.

[0039] Step 3, Shadow area determination: Traverse each pixel in the HSV image, compare the luminance value with the luminance threshold. If the luminance value is less than the luminance threshold, mark this pixel as the shadow area; Step 4, Generate a shadow mask: Generate a binary mask through threshold segmentation to mark the shadow area; for example, in the mask, the pixel value of the shadow area is 1 (or 255), and the pixel value of the non - shadow area is 0.

[0040] Optionally, the saturation of the shadow area is also relatively low because shadows usually make colors dull. Based on this, if more accurate detection is required, the saturation (S channel) information can be combined to further screen the shadow area. For example, set a saturation threshold, mark the pixels in the S channel that are lower than this saturation threshold as the shadow area, and then combine the luminance threshold and the saturation threshold to generate a more accurate shadow mask.

[0041] In the embodiment of the present invention, by traversing each pixel of the HSV image and comparing the luminance value with the preset luminance threshold, the shadow area can be effectively detected.

[0042] Step 103, Perform multi - scale Gaussian filtering on the shadow area, and perform contrast - limited adaptive histogram equalization (CLAHE) processing on the filtered shadow area at each scale.

[0043] Among them, each scale in the multi - scale corresponds to a filter kernel with a different variance value. Specifically, in multi - scale analysis, by setting different variance values for the filter kernel, multiple filter kernels with different scales are generated, and each kernel corresponds to a specific spatial range, so as to capture the features of the signal or image at different scales.

[0044] Specifically, perform multi - scale Gaussian filtering on the shadow area to generate smoothed results at different scales. Among them, Gaussian filtering can remove noise and provide a smoother basis for subsequent CLAHE processing. Further, apply CLAHE to the filtered shadow area at each scale to enhance the local contrast. CLAHE is particularly suitable for processing shadow areas because it can effectively enhance the details of low - contrast areas.

[0045] Step 104, Fuse the results of multi - scale CLAHE processing to obtain an enhanced image after removing the shadow.

[0046] It can be understood that the core of the multi-scale CLAHE processing result fusion is to apply CLAHE at different scales and then fuse the processing results, so as to remove shadows while preserving image details. Since a single-scale CLAHE cannot handle both global and local details in an image at the same time, by applying CLAHE at different scales, features of different sizes in the image can be captured, thus enhancing the image more comprehensively. At the same time, by fusing the CLAHE processing results of different scales, the global and local enhancement effects can be combined to obtain a more natural enhanced image.

[0047] In one embodiment, the weight of each scale is determined; according to the weight of each scale, the multi-scale CLAHE processing results are weighted and fused to obtain an enhanced image after removing shadows. Specifically, CLAHE is applied at different scales to generate multiple enhancement results, and the results of each scale capture features of different sizes in the image (such as global contrast, local details). A weight is assigned to the result of each scale. For example, the weight parameters at three scales are 0.2, 0.5, and 0.3 respectively. The size of the weight determines the contribution of this scale to the final result. For example, a larger weight can be used to emphasize local details, and a smaller weight can be used to preserve global contrast. Multiply the CLAHE processing result of each scale by its corresponding weight and then sum to obtain an enhanced image after removing shadows.

[0048] The multi-scale CLAHE processing and weighted fusion proposed in the embodiments of the present invention can more finely control the enhancement effect by assigning weights to the results of each scale; remove shadows and enhance details while preserving the naturalness of the image; at the same time, by adjusting the scale and weight, the enhancement effect can be optimized according to specific task requirements.

[0049] The image shadow removal method provided by the embodiments of the present invention includes: converting a grayscale image to the HSV space to obtain an HSV image; detecting the brightness component in the HSV image to determine the shadow area; performing multi-scale Gaussian filtering on the shadow area, and performing contrast-limited adaptive histogram equalization (CLAHE) processing on the filtered shadow area at each scale; fusing the multi-scale CLAHE processing results to obtain an enhanced image after removing shadows. The present invention can improve the brightness and contrast of the shadow area, maintain the naturalness of the non-shadow area, thereby improving the overall processing effect and visual quality of the image. At the same time, based on the detection of the brightness component in the HSV image, the shadow area and the non-shadow area can be effectively distinguished. Through multi-scale fusion, different shadows in different areas can be effectively processed, and finally the shadows can be effectively removed, presenting a good overall effect.

[0050] Based on the above embodiments, the performing multi-scale Gaussian filtering on the shadow area includes: Step 1031: Generate multiple of the filter kernels based on the Gaussian function; Step 1032: Convolve each of the filter kernels with the shadow region to perform multi-scale Gaussian filtering on the shadow region; wherein, the Gaussian function is provided with a gain term and a bias term, the gain term is used to adjust the intensity of the filter, and the bias term is used to adjust the baseline of the filter.

[0051] Improve the Gaussian filtering by removing the normalization process and adding a gain term and a bias term to the Gaussian function, so that the sum of the weights in the convolution kernel is greater than 1, thereby enhancing the image brightness. Use the convolution kernel to convolve the image, the size of the convolution kernel is 3×3, and its formula is as follows: ; wherein, represents the gain term, usually takes values from 5 to 15; represents the bias term, usually takes values from 0.1 to 1; represents the standard deviation, represents the variance, ; represents the pixel coordinates. For example, process the shadow region using the improved Gaussian filter, that is = 10, = 1, and process the shadow part of the image respectively under the conditions of the parameter = 0.01, 0.1, and 1. It should be understood that the convolution kernel in the Gaussian function refers to the filter kernel.

[0052] Generate multiple filter kernels by setting three different variances, each filter kernel corresponds to a different scale, and is respectively applicable to different features of the shadow region, so as to process the shadow at multiple scales.

[0053] The embodiment of the present invention improves the Gaussian filter, which is mainly reflected in removing the normalization process of the Gaussian filter and adding a gain term and a bias term, thereby enhancing the processing effect on the shadow region. Under multi-scale conditions, the image is hierarchically processed for different scales, and different filter parameters are respectively adopted for the shadow and non-shadow regions. These improvements not only enhance the effect of shadow removal, but also ensure the retention of image details.

[0054] In one embodiment, perform contrast-limited adaptive histogram equalization (CLAHE) processing on the filtered shadow region at each scale, including: at each scale, divide the filtered shadow region into multiple grid regions; perform histogram equalization on each grid region to enhance the local contrast; recombine the grid regions that have undergone histogram equalization to obtain the CLAHE processing result.

[0055] It is understandable that CLAHE is an improved histogram equalization method. By dividing the image into multiple small grid regions and performing histogram equalization independently within each grid region, the local contrast is enhanced. Compared with global histogram equalization, CLAHE can better handle local details in the image while avoiding over-enhancing noise.

[0056] Specifically, the shadow region of the image is divided into several small grid regions, and histogram equalization is performed on each grid region to enhance the local contrast. The degree of contrast enhancement of histogram equalization is restricted to prevent noise from being over-enhanced. The processed grid regions are recombined into a complete image, thereby enhancing the local contrast of the image while suppressing noise.

[0057] For example, CLAHE processing can be achieved through the following steps: (1) Divide the grid regions: The filtered shadow region is divided into grid regions of the same size (such as 8×8 or 16×16). Each grid region is a local sub-region of the image. Among them, the smaller the grid, the more obvious the effect of enhancing local contrast, but it may cause blocky artifacts. The larger the grid, the smoother the enhancement effect, but local details may be lost.

[0058] (2) Perform histogram equalization on each grid region: Calculate the grayscale histogram of each grid region. To avoid over-enhancing noise, CLAHE will clip the histogram and limit the number of pixels at each gray level. The clipped histogram will be redistributed to ensure that the total number of pixels remains unchanged. According to the clipped histogram, histogram equalization is performed on each grid region to enhance the local contrast.

[0059] (3) Recombine the grid regions: Since each grid region is processed independently, directly combining them may cause discontinuities at the grid boundaries. To solve this problem, CLAHE uses bilinear interpolation to smooth the grid boundaries. The processed grid regions are recombined to obtain the complete CLAHE processing result.

[0060] In the embodiment of the present invention, CLAHE enhances the local contrast by dividing the image into multiple grid regions and performing histogram equalization independently within each grid region. By adjusting the grid size and contrast limit, the enhancement effect can be flexibly controlled, and the details of low-contrast regions can be effectively enhanced.

[0061] To further analyze and explain the image shadow removal method proposed by the present invention, refer to the following embodiments.

[0062] Refer to Figure 2, embodiments of the present invention specifically propose a method for removing shadows in grayscale images, mainly including the following steps: 1. Load a color image from a specified path and convert it into a grayscale image. Specifically, a grayscale image is generated by linearly combining RGB components, where the calculation formula for the grayscale value is Y = 0.299R + 0.587G + 0.114B.

[0063] 2. Convert the grayscale image to the HSV space to obtain an HSV image. Use the brightness channel (V channel) in the HSV image for detection, and set a brightness threshold (such as 0.5). Traverse each pixel in the HSV image, compare its brightness value with the brightness threshold, and mark the area below the brightness threshold as the shadow area to generate a shadow mask.

[0064] 3. For the shadow area in step 2, define multi-scale Gaussian filter parameters and improve the Gaussian filter kernel using different variances. Apply different filter kernels for convolution processing according to the detected shadow area.

[0065] 4. For the Gaussian filtering result obtained in step 3, apply the CLAHE method to the shadow area at each scale respectively to enhance the local contrast of the image, thereby further reducing the influence of shadows.

[0066] 5. Fuse the results of different scales that have been processed by CLAHE in step 4. By performing weighted fusion on the processing results of different scales, obtain the final enhanced image to effectively reduce the influence of shadows.

[0067] Further, in step 3, use the defined improved Gaussian filter, remove the normalization process and add a gain term and a bias term to the Gaussian function, so that the sum of the weights in the convolution kernel is greater than 1. Use the convolution kernel to perform convolution on the image, and the size of the convolution kernel is 3×3, and its formula is as follows: ; where, represents the gain term, represents the bias term, represents the standard deviation, represents the variance, , represents the pixel coordinates.

[0068] Generate multiple filter kernels by setting three different variances. Each filter kernel corresponds to a different scale and is respectively applicable to different features of the shadow area, so as to process shadows at multiple scales.

[0069] Further, in step 4, by performing weighted fusion on the filtering results of different scales and using predefined weights, the filtering results of different scales are combined into a final fused image to ensure that while removing shadows, the detailed information of the image is retained.

[0070] The method for removing shadows in a grayscale image provided by the embodiments of the present invention simplifies the traditional complex image preprocessing process by directly reading a color image and converting it into a grayscale image, and then performing detection and discrimination processing on the shadow area. Further, through the improved Gaussian filtering method at multiple scales, targeted processing is performed on the shadow area at different scales, taking into account the image details and overall brightness changes at different scales, so as to more accurately smooth the shadow area while maintaining the original characteristics of the non-shadow area. In addition, by further combining the CLAHE technology, the contrast is enhanced only for the shadow area, avoiding the problem of over-enhancement of the non-shadow area. Through the weighted fusion of the processing results at different scales, the overall visual effect of the image is effectively improved, and for shadows in different regions, the processing differences caused by different shadow degrees are avoided. The embodiments of the present invention not only simplify the processing flow of shadow removal, reduce the dependence on parameter adjustment, but also retain the important detailed information in the image while improving the processing speed. This method can process shadows more precisely, especially in the case of uneven illumination or complex shadows, and can remove shadows more accurately, thereby improving the overall quality of image processing.

[0071] In one embodiment, refer to Figures 3-5 , wherein, Figure 3 is a schematic diagram of the original image provided by the present invention, and there is a shadow area in this original image. Figure 4 is a schematic diagram of the original image provided by the present invention after CLAHE processing. As can be seen from Figure 4 , although the shadow part becomes visible after being processed by the CLAHE method, there are significant differences in contrast, and the results for different shadows are not good. Figure 5 is a schematic diagram of the original image processed by the image shadow removal method provided by the present invention. As can be seen from Figure 5 , after being processed by the image shadow removal method, the shadow part becomes visible, and at the same time, the image details are retained.

[0072] The image shadow removal device provided by the present invention will be described below. The image shadow removal device described below can be correspondingly referred to the image shadow removal method described above.

[0073] Refer to Figure 6 , the image shadow removal device provided by the present invention includes a conversion module 601, a shadow area determination module 602, a CLAHE processing module 603, and an image shadow removal module 604.

[0074] A conversion module 601, configured to convert a grayscale image into the HSV space to obtain an HSV image; A shadow area determination module 602, configured to detect a luminance component in the HSV image to determine a shadow area; A CLAHE processing module 603, configured to perform multi-scale Gaussian filtering on the shadow area, and perform contrast-limited adaptive histogram equalization (CLAHE) processing on the filtered shadow area at each scale; each scale in the multi-scale corresponds to a filter kernel with a different variance value; An image shadow removal module 604, configured to fuse the results of the multi-scale CLAHE processing to obtain an enhanced image with shadows removed.

[0075] The image shadow removal device provided by an embodiment of the present invention converts a grayscale image into the HSV space to obtain an HSV image; detects a luminance component in the HSV image to determine a shadow area; performs multi-scale Gaussian filtering on the shadow area, and performs contrast-limited adaptive histogram equalization (CLAHE) processing on the filtered shadow area at each scale; fuses the results of the multi-scale CLAHE processing to obtain an enhanced image with shadows removed. The present invention can improve the luminance and contrast of the shadow area, maintain the naturalness of the non-shadow area, thereby improving the overall processing effect and visual quality of the image. At the same time, based on the detection of the luminance component in the HSV image, the shadow area and the non-shadow area can be effectively distinguished. Through multi-scale fusion, different shadows in different areas can be effectively processed, and finally the shadows can be effectively removed, presenting a good overall effect.

[0076] In an embodiment, the CLAHE processing module 603 is specifically configured to: generate a plurality of the filter kernels based on a Gaussian function; perform a convolution operation on each of the filter kernels and the shadow area to perform multi-scale Gaussian filtering on the shadow area; wherein, the Gaussian function is provided with a gain term and a bias term, the gain term is used to adjust the intensity of the filter, and the bias term is used to adjust the baseline of the filter.

[0077] In an embodiment, the CLAHE processing module 603 is specifically configured to: at each scale, divide the filtered shadow area into a plurality of grid areas; perform histogram equalization on each of the grid areas to enhance the local contrast; recombine the grid areas that have undergone histogram equalization to obtain the CLAHE processing result.

[0078] In an embodiment, the shadow area determination module 602 is specifically configured to: traverse each pixel in the HSV image, compare the luminance value of each pixel with a preset luminance threshold; determine the area where the luminance value is less than the preset luminance threshold as the shadow area.

[0079] In one embodiment, the image shadow removal module 604 is specifically configured to: determine the weight of each scale; and perform weighted fusion on the multi-scale CLAHE processing results according to the weight of each scale to obtain an enhanced image with shadows removed.

[0080] In one embodiment, the conversion module 601 is further configured to: extract the R value, G value, and B value of each pixel from the color image to be processed; perform weighted summation on the R value, G value, and B value of each pixel to obtain the gray value of each pixel; and generate the gray image according to the gray value of each pixel.

[0081] Figure 7 An example of the physical structure diagram of an electronic device is shown as Figure 7 shown. The electronic device may include: a processor 710, a communication interface 720, a memory 730, and a communication bus 740. Among them, the processor 710, the communication interface 720, and the memory 730 communicate with each other through the communication bus 740. The processor 710 can call the logical instructions in the memory 730 to execute the image shadow removal method, which includes: converting the gray image to the HSV space to obtain an HSV image; detecting the brightness component in the HSV image to determine the shadow area; performing multi-scale Gaussian filtering on the shadow area, and performing contrast-limited adaptive histogram equalization (CLAHE) processing on the filtered shadow area at each scale; each scale in the multi-scale corresponds to a filter kernel with a different variance value; and fusing the multi-scale CLAHE processing results to obtain an enhanced image with shadows removed.

[0082] In addition, when the logical instructions in the above-mentioned memory 730 are implemented in the form of software functional units and sold or used as an independent product, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this 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 various embodiments of the present invention. The foregoing storage medium includes: various media such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk, or an optical disc that can store program codes.

[0083] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the image shadow removal method provided by each of the above methods, and the method includes: converting a grayscale image to the HSV space to obtain an HSV image; detecting the luminance component in the HSV image to determine the shadow area; performing multi-scale Gaussian filtering on the shadow area, and performing contrast-limited adaptive histogram equalization (CLAHE) processing on the filtered shadow area at each scale; each scale in the multi-scale corresponds to a filter kernel with a different variance value; fusing the results of the multi-scale CLAHE processing to obtain an enhanced image with shadows removed.

[0084] In another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it is implemented to execute the image shadow removal method provided by each of the above methods, and the method includes: converting a grayscale image to the HSV space to obtain an HSV image; detecting the luminance component in the HSV image to determine the shadow area; performing multi-scale Gaussian filtering on the shadow area, and performing contrast-limited adaptive histogram equalization (CLAHE) processing on the filtered shadow area at each scale; each scale in the multi-scale corresponds to a filter kernel with a different variance value; fusing the results of the multi-scale CLAHE processing to obtain an enhanced image with shadows removed.

[0085] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without creative labor.

[0086] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution, in essence, or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0087] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for removing image shadows, characterized in that: include: Convert the grayscale image to HSV space to obtain an HSV image; Detecting the brightness component in the HSV image to determine the shadow area; Performing multi-scale Gaussian filtering on the shadow area, and performing contrast-limited adaptive histogram equalization (CLAHE) processing on the filtered shadow area at each scale; each scale in the multi-scale corresponds to a filter kernel with a different variance value; The multi-scale CLAHE processing results are fused to obtain the enhanced image after removing the shadow.

2. The image shadow removal method according to claim 1, characterized in that: The performing multi-scale Gaussian filtering on the shadow area includes: Based on the Gaussian function, generating a plurality of filter kernels; Performing a convolution operation on each filter kernel and the shadow area to perform multi-scale Gaussian filtering on the shadow area; The Gaussian function is provided with a gain term and a bias term, the gain term is used to adjust the strength of the filter, and the bias term is used to adjust the baseline of the filter.

3. The image shadow removal method according to claim 1, characterized in that: The step of performing contrast-limited adaptive histogram equalization (CLAHE) processing on the filtered shadow area at each scale includes: At each scale, the filtered shadow area is divided into multiple grid areas; Performing histogram equalization on each of the grid regions to enhance local contrast; The grid areas that have been histogram equalized are recombined to obtain the CLAHE processing result.

4. The image shadow removal method according to claim 1, characterized in that: The detecting the brightness component in the HSV image to determine the shadow area includes: Traversing each pixel in the HSV image, and comparing the brightness value of each pixel with a preset brightness threshold; An area whose brightness value is less than the preset brightness threshold is determined as the shadow area.

5. The image shadow removal method according to claim 1, characterized in that: The multi-scale CLAHE processing results are fused to obtain an enhanced image after removing the shadows, including: Determine the weight of each scale; According to the weight of each scale, the multi-scale CLAHE processing results are weighted fused to obtain the enhanced image after removing the shadow.

6. The image shadow removal method according to any one of claims 1 to 5, characterized in that: The grayscale image is generated based on the following method: Extracting the R value, G value and B value of each pixel from the color image to be processed; Perform weighted summation on the R value, G value, and B value of each pixel to obtain the grayscale value of each pixel; The grayscale image is generated according to the grayscale value of each pixel.

7. An image shadow removal device, characterized in that: include: A conversion module is used to convert the grayscale image into the HSV space to obtain an HSV image; A shadow area determination module, used for detecting the brightness component in the HSV image to determine the shadow area; A CLAHE processing module, used for performing multi-scale Gaussian filtering on the shadow area, and performing contrast-limited adaptive histogram equalization CLAHE processing on the filtered shadow area at each scale; each scale in the multi-scale corresponds to a filter kernel with a different variance value; The image shadow removal module is used to fuse the multi-scale CLAHE processing results to obtain an enhanced image after removing the shadows.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the image shadow removal method according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the image shadow removal method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the image shadow removal method according to any one of claims 1 to 6 is implemented.

Citation Information

Cited By

  • Leather wear quality visual detection method and system

    CN120997222A