An unsupervised shadow detection method for remote sensing images
The unsupervised shadow detection method in remote sensing images addresses the inaccuracy of existing methods by converting to HSI color space, applying Gaussian filtering, and using optimal thresholds to achieve precise shadow detection and removal.
Patent Information
- Application Number
- CN202210638592.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-08
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2042-06-08
AI Technical Summary
Existing shadow detection methods in remote sensing images are inaccurate due to high dependence on scene, lighting conditions, and prior knowledge, making it difficult to detect shadows effectively in multiple scenes.
An unsupervised remote sensing image shadow detection method that converts RGB color space to HSI, applies Gaussian filtering, uses optimal segmentation thresholds, and performs morphological closing operations to accurately identify shadows.
Accurately detects shadows in remote sensing images with complex structures, providing reliable guidance for subsequent shadow removal and restoration of original object structures.
Smart Images

Figure CN115018791B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of remote sensing image monitoring, and in particular to an unsupervised remote sensing image shadow detection method. Background Art
[0002] Due to the large number of shadow areas in remote sensing images, the features of the objects are disturbed by the shadows and become less obvious, thus affecting the accuracy of image interpretation. At present, the shadow detection method based on spectral differences and geometric features has too high requirements on the scene, lighting conditions, geometric theory and other prior knowledge. The detection is difficult and the accuracy is not high, which is not conducive to the shadow detection of remote sensing images in multiple scenes. Summary of the invention
[0003] In order to solve the above technical problems, the present invention provides an unsupervised remote sensing image shadow detection method, which includes the following steps:
[0004] S1, converting the remote sensing image RGB color space into HSI color space, and performing Gaussian filtering to denoise, to obtain a denoised image;
[0005] S2, using the denoised image to form a sample set, and obtaining the optimal segmentation threshold of each color channel of HSI;
[0006] S3, according to the optimal segmentation threshold of each color channel of HSI, detect the image to be detected and obtain preliminary shadow detection results;
[0007] S4, marking the preliminary shadow detection result, obtaining the marked connected region, and calculating the area of the connected region;
[0008] S5. Set a threshold for the area of the connected region to perform screening, and fill the screened region with a morphological closing operation to obtain the final shadow region.
[0009] Furthermore, in step S2, the process of obtaining the optimal segmentation threshold of any color channel is as follows:
[0010] S21, first randomly select n threshold points t between [0-255] i , i = {1, 2, ..., n}, set the maximum number of iterations to max_iteration, the initial step size v 0 , start the iteration process;
[0011] S22, at the kth iteration, for a certain threshold point t i , will be lower than t i The pixels above t are recorded as shadow samples. i The pixel points are recorded as non-shadow samples;
[0012] S23, calculating the average gray value μ of the input image of the sample set;
[0013] S24, the ratio of the number of shadow sample points to all pixel points is recorded as w 1 , calculate the average gray value within the shadow sample point, denoted as μ 1 ;
[0014] S25. The ratio of the number of non-shadow sample points to all pixel points is recorded as w 2 , calculate the average gray value in the non-shadow sample, denoted as μ 2 ;
[0015] S26, calculate the image at the threshold point t i The between-class variance is as follows:
[0016] g=w 1 (μ 1 -μ) 2 +w 2 (μ 2 -μ) 2 (1)
[0017] S27, traverse each threshold point t i , i = {1, 2, ..., n}, calculate the inter-class variance of each threshold at the kth iteration according to formula (1)
[0018] S28, traverse threshold point t i , update the threshold point t from the 1st to the kth iteration i Optimal value of between-class variance And the corresponding threshold point
[0019] S29, after obtaining each threshold point t i The optimal value of the between-class variance After that, record the optimal value of the inter-class variance of all threshold points at the kth iteration And the corresponding optimal threshold point
[0020] S210, for the threshold point under the kth iteration Update the search step size for each threshold point; the search step size update formula is as follows:
[0021]
[0022]
[0023]
[0024]
[0025] In formulas (2)-(5), is the compensation index, is the search step length calculated at the k-1th iteration, r 1 , r 2 , r 3 , r 4 is a random number between [0,1];
[0026] S211, according to the search step length, for the threshold point Its position will move to the threshold value in the k+1th iteration
[0027]
[0028] S212, traverse the kth iteration lower threshold point According to the steps S22-S211, the threshold point for the k+1th time is obtained.
[0029] S213, until k reaches the maximum number of times max_iteration, the iteration stops, and the global optimal value t is obtained at this time best , as the optimal value for image segmentation under any color channel.
[0030] Furthermore, in step S210, the compensation index The formula is as follows:
[0031]
[0032] in, is the initial compensation index, To terminate the compensation index, These are preset values.
[0033] In step S3, the specific process of obtaining the preliminary shadow detection result is as follows:
[0034] S31, in the HSI color space, define a difference channel HI of hue and brightness, use the HI channel as the input of step S2, and obtain the optimal segmentation threshold tHI of the HI channel; use the threshold tHI to perform threshold processing on the image to be detected, remove the area in the image to be detected that is misdetected due to high hue, and obtain a processed image;
[0035] S32, the processed image is subjected to dual threshold detection of saturation and brightness channels, and when the pixel is higher than the optimal segmentation threshold t of the saturation channel, s , and is lower than the optimal segmentation threshold t of the brightness channel I , it is determined that this pixel belongs to the preliminary shadow area, and thus all pixels are traversed to obtain the preliminary shadow detection result.
[0036] The beneficial effect provided by the present invention is that shadows can be accurately detected in remote sensing images, especially in remote sensing areas with complex structures. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION
[0038] To make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described below with reference to the accompanying drawings.
[0039] Please refer to Figure 1 , Figure 1 : is a system structure diagram of the present invention; an unsupervised remote sensing image shadow detection method, comprising the following:
[0040] S1, converting the remote sensing image RGB color space into HSI color space, and performing Gaussian filtering to denoise, to obtain a denoised image;
[0041] It should be noted that since each channel in the RGB image affects each other, color similarity is difficult to distinguish. Therefore, the HSI color space that is more in line with visual characteristics is adopted in image processing. The HSI color space can be divided into three channels: hue, saturation, and brightness. The rgb2hsi function in matlab can be used to convert from RGB color space to HSI space.
[0042] Considering that the image noise will be generated by the device due to the influence of light and temperature during the image acquisition process, after the image is converted to the HSI color space, each channel needs to be filtered to remove the image noise. The specific steps are:
[0043] Take a point in the image (n 1 ,n 2 ) as the center, define a 3*3 template. Select the kernel function as:
[0044]
[0045] In the above formula, n 1 ,n 2 is the horizontal and vertical coordinates of the pixel point, δ is the bandwidth of the filter, and the value of δ determines the smoothness of the image. The value h of each pixel point in the template after the kernel function changes is calculated by the formula g (n 1 ,n 2 ,δ).
[0046] After each point in the template is transformed by the kernel function, it is normalized and the normalized value is regarded as the weight of the template. The normalization formula is:
[0047]
[0048] According to the template, the center pixel (n 1 ,n 2 ) and surrounding pixels, calculate the filtered pixel h_s(n 1 ,n 2 ), and the calculation formula is as follows.
[0049]
[0050] In the above formula, the original grayscale value of the surrounding pixels is h(n i ,n j ), through the weight h′ of the corresponding position template g (n i ,n j ,δ) are multiplied to finally get the center pixel (n 1 ,n 2 ) is the weighted average of the filtered central pixel. Traverse each pixel in the image and filter the image according to the above steps.
[0051] S2, using the denoised image to form a sample set, and obtaining the optimal segmentation threshold of each color channel of HSI;
[0052] In step S2, the process of obtaining the optimal segmentation threshold for any color channel is as follows:
[0053] S21, first randomly select n threshold points t between [0-255] i , i = {1, 2, ..., n}, set the maximum number of iterations to max_iteration, the initial step size v 0 , starts the iteration process; in this application, v 0 =2;
[0054] S22, at the kth iteration, for a certain threshold point t i , will be lower than t i The pixel points with a value higher than t are recorded as shadow samples. i The pixel points are recorded as non-shadow samples;
[0055] S23, calculating the average gray value μ of the input image of the sample set;
[0056] S24, the ratio of the number of shadow sample points to all pixel points is recorded as w 1 , calculate the average gray value within the shadow sample point, denoted as μ1 ;
[0057] S25. The ratio of the number of non-shadow sample points to all pixel points is recorded as w 2 , calculate the average gray value in the non-shadow sample, denoted as μ 2 ;
[0058] S26, calculate the image at the threshold point t i The between-class variance is as follows:
[0059] g=w 1 (μ 1 -μ) 2 +w 2 (μ 2 -μ) 2 (1)
[0060] S27, traverse each threshold point t i , i = {1, 2, ..., n}, calculate the inter-class variance of each threshold at the kth iteration according to formula (1)
[0061] S28, traverse threshold point t i , update the threshold point t from the 1st to the kth iteration i Optimal value of between-class variance And the corresponding threshold point
[0062] S29, after obtaining each threshold point t i The optimal value of the between-class variance After that, record the optimal value of the inter-class variance of all threshold points at the kth iteration And the corresponding optimal threshold point
[0063] S210, for the threshold point under the kth iteration Update the search step size for each threshold point; the search step size update formula is as follows:
[0064]
[0065]
[0066]
[0067]
[0068] In formulas (2)-(5), is the compensation index, is the search step length calculated at the k-1th iteration, r 1 , r2 , r 3 , r 4 is a random number between [0,1];
[0069] In step S210, the compensation index The formula is as follows:
[0070]
[0071] in, is the initial compensation index, which is set to 0.95 in this application. is the termination compensation index, which is set to 0.05 in this application; All are preset values. This compensation formula can ensure that at the beginning of the threshold search process, a larger compensation index can be maintained, and the search step will not decrease rapidly due to the compensation index decreasing too quickly, thus falling into the local optimum, so that the optimal threshold range can be found at a faster speed. At the end of the search process, the compensation index can maintain a smaller value, so that a more stable search step can be maintained, and the optimal threshold within the range can be searched more accurately.
[0072] S211, according to the search step length, for the threshold point Its position will move to the threshold value in the k+1th iteration
[0073]
[0074] S212, traverse the kth iteration lower threshold point According to the steps S22-S211, the threshold point for the k+1th time is obtained.
[0075] S213, until k reaches the maximum number of times max_iteration, the iteration stops, and the global optimal value t is obtained at this time best , as the optimal value for image segmentation under any color channel
[0076] S3, according to the optimal segmentation threshold of each color channel of HSI, detect the image to be detected and obtain preliminary shadow detection results;
[0077] In this application, a combination design of shadow detection channels is performed based on the characteristics of shadows in images, that is, high hue, high saturation, and low brightness.
[0078] In step S3, the specific process of obtaining the preliminary shadow detection result is as follows:
[0079] S31, in the HSI color space, define a difference channel HI of hue and brightness, use the HI channel as the input of step S2, and obtain the optimal segmentation threshold tHI of the HI channel; use the threshold tHI to perform threshold processing on the image to be detected, remove the area in the image to be detected that is misdetected due to high hue, and obtain a processed image;
[0080] S32, the processed image is subjected to dual threshold detection of saturation and brightness channels, and when the pixel is higher than the optimal segmentation threshold t of the saturation channel, s , and is lower than the optimal segmentation threshold t of the brightness channel I , it is determined that this pixel belongs to the preliminary shadow area, and thus all pixels are traversed to obtain the preliminary shadow detection result.
[0081] S4, marking the preliminary shadow detection result, obtaining the marked connected region, and calculating the area of the connected region;
[0082] It should be noted that in this application, the bwlabel function in Matlab is used to mark the shadow area to obtain mark_image. The specific command is mark_image = bwlabel (initial_result, 8); 8 means to search for the area according to 8 connectivity.
[0083] The area of the connected regions in mark_image is calculated using Matlab's regionprops function. The specific command is: area = regionprops (mark_image, 'Area'); where area represents the area of each connected region.
[0084] Use the bwareaopen function in Matlab to filter out the areas with an area less than 100 in each connected area. The specific command is: mark_image = bwareaopen (mark_image, 100);
[0085] S5. Set a threshold for the area of the connected region to perform screening, and fill the screened region with a morphological closing operation to obtain the final shadow region.
[0086] It should be noted that this application uses the closing operation in mathematical morphology to fill the gaps in the shadow detection results. The specific process is as follows:
[0087] The obtained mark_image is converted into a binary image using the im2bw function. The specific command is: bim = im2bw (mark_image);
[0088] Use the strel function to create a morphological structure element, and use the eye function to create a 15*15 diagonal matrix. The specific command is: SE=strel(eye(15));
[0089] Combine the given morphological structure elements to perform the closing operation in mathematical morphology. The specific command is: shdow_result = imclose (bim, SE)
[0090] After the above steps, the shadow detection result is finally obtained.
[0091] The beneficial effect of the present invention is that in remote sensing images with complex objects and diverse scenes, the shadow area in the image can be accurately detected. The method can provide reliable guidance information for subsequent remote sensing shadow removal, so that the original object structure in the area can be restored from the shadow.
[0092] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. An unsupervised remote sensing image shadow detection method, characterized in that: The following steps are involved: S1, converting the remote sensing image RGB color space into HSI color space, and performing Gaussian filtering to denoise, to obtain a denoised image; S2, using the denoised image to form a sample set, and obtaining the optimal segmentation threshold of each color channel of HSI; S3, according to the optimal segmentation threshold of each color channel of HSI, detect the image to be detected and obtain preliminary shadow detection results; S4, marking the preliminary shadow detection result, obtaining the marked connected region, and calculating the area of the connected region; S5, setting a threshold for the area of the connected region to perform screening, and filling the screened region with a morphological closing operation to obtain a final shadow region; In step S2, the process of obtaining the optimal segmentation threshold for any color channel is as follows: S21, first randomly select n threshold points t between [0-255] i ,i={1,2,…,n}, set the maximum number of iterations to max_iteration, the initial step size v0, and start the iteration process; S22, at the kth iteration, for a certain threshold point t i , will be lower than t i The pixel points with a value higher than t are recorded as shadow samples. i The pixel points are recorded as non-shadow samples; S23, calculating the average gray value μ of the input image of the sample set; S24, record the ratio of the number of shadow sample points to all pixel points as w1, and calculate the average gray value of the shadow sample points, record it as μ1; S25, record the ratio of the number of non-shadow sample points to all pixel points as w2, and calculate the average gray value in the non-shadow samples, record it as μ2; S26, calculate the image at the threshold point t i The between-class variance is as follows: g=w1(μ1-μ) 2 +w2(μ2-μ) 2 (1) S27, traverse each threshold point t i , i = {1, 2, ..., n}, calculate the inter-class variance of each threshold at the kth iteration according to formula (1) S28, traverse threshold point t i , update the threshold point t from the 1st to the kth iteration i Optimal value of between-class variance And the corresponding threshold point S29, after obtaining each threshold point t i The optimal value of the between-class variance After that, record the optimal value of the inter-class variance of all threshold points at the kth iteration And the corresponding optimal threshold point S210, for the threshold point under the kth iteration Update the search step size for each threshold point; the search step size update formula is as follows: In formulas (2)-(5), is the compensation index, is the search step calculated at the k-1th iteration, r1, r2, r3, r4 are random numbers between [0,1]; S211, according to the search step length, for the threshold point Its position will move to the threshold value in the k+1th iteration S212, traverse the kth iteration lower threshold point According to the steps S22-S211, the threshold point for the k+1th time is obtained. S213, until k reaches the maximum number of times max_iteration, the iteration stops, and the global optimal value t is obtained at this time best , as the optimal value for image segmentation under any color channel; In step S210, the compensation index The formula is as follows: in, is the initial compensation index, To terminate the compensation index, These are preset values.
2. The unsupervised remote sensing image shadow detection method according to claim 1, characterized in that: In step S3, the specific process of obtaining the preliminary shadow detection result is as follows: S31, in the HSI color space, define a difference channel HI of hue and brightness, use the HI channel as the input of step S2, and obtain the optimal segmentation threshold tHI of the HI channel; use the threshold tHI to perform threshold processing on the image to be detected, remove the area in the image to be detected that is misdetected due to high hue, and obtain a processed image; S32, the processed image is subjected to dual threshold detection of saturation and brightness channels, and when the pixel is higher than the optimal segmentation threshold t of the saturation channel, s , and is lower than the optimal segmentation threshold t of the brightness channel I , it is determined that this pixel belongs to the preliminary shadow area, and thus all pixels are traversed to obtain the preliminary shadow detection result.
Citation Information
Patent Citations
Method for eliminating image shades of digital camera
CN101621607A
Shadow detection method based on color saturation property of shadow area
CN110428439A