Disclosure of Invention
The invention aims to enhance the timeliness of remote sensing image quality inspection and improve the utilization rate of remote sensing images, so that the remote sensing image quality inspection system can be applied to domestic satellite image product quality inspection systems such as resource one, resource three, daily drawing one, high-grade first and the like.
In order to achieve the purpose, the invention provides a satellite remote sensing image cloud, snow and fog detection method based on a support vector machine, and the specific implementation of the technical scheme of the invention comprises the following steps:
Step 1, collecting a large amount of cloud, snow, fog and ground object sample image data;
Step 2, extracting gray features and texture features of various sample images to form feature vectors;
Step 3, training the feature vectors of the sample images by using a support vector machine to respectively obtain a cloud image classifier, a snow image classifier and a fog image classifier which are formed by decision functions;
step 4, performing down-sampling processing on an original image of the satellite remote sensing image to be detected to obtain a thumbnail, performing image segmentation on the thumbnail to obtain sub-images, and calculating a feature vector consisting of gray features and texture features of all the sub-images;
Step 5, classifying the sub-images of the remote sensing image of the satellite to be detected, comprising the following sub-steps,
Step 5.1, respectively inputting the feature vectors extracted in the step 4 into the cloud, snow and fog image classifiers obtained in the step 3 for prediction classification;
Step 5.2, dividing all the sub-images into a cloud area, a fog area, a snow area and a ground object area according to the types of the target areas;
Step 5.3, dividing the images into three binary images according to the cloud and ground object areas, the fog and ground object areas and the snow and ground object areas, wherein the ground object areas in each image take the same zero value, and the cloud, snow and fog areas take different image values;
Step 6, performing morphological 'closing' operation on the classification result obtained in the step 5;
And 7, comparing three binary image values at the same position to obtain detection results of cloud, snow and fog in the remote sensing image of the satellite to be detected.
further, the implementation manner of the step 7 is as follows,
step 7.1, comparing three binary image values at the same position, and if the image values at the same position of the three images are the same, judging that the position is a ground object area; if two same values exist at the same position, the position is judged to be a category area represented by a third image value; if the image values of the three images at the same position are different, judging that the position is an overlapping area with cloud, snow and fog, recording a point with a zero value as the overlapping area, and recording a point without the zero value as a triple overlapping area;
7.2, repeating the step 7.1, comparing all image values of the three binary images to obtain discrimination results of cloud, snow and fog areas, ground object areas and overlapping areas, and correcting the overlapping areas; firstly, judging whether the overlapped area is contained in other areas, and if so, replacing the overlapped area with other areas; secondly, judging the type of the overlapping area, if the overlapping area is externally connected with a certain determined type area, judging the type of the overlapping area to be the type of the overlapping area except the determined externally connected type, and if not, confirming after the type of the overlapping area is judged to be finished; for the triple overlapping area, if the triple overlapping area is externally connected with a certain determined type area, the overlapping area is judged to be the overlapping area without the externally connected type, and if the triple overlapping area is externally connected with the overlapping area, the type of the overlapping area is judged to be the type of the overlapping area different from the type of the overlapping area externally connected with the overlapping area; and finally, judging the condition that the overlapped areas are only externally connected with different overlapped areas, respectively judging the areas into the categories except the common categories, and finally obtaining the judgment result.
and 7.3, performing morphological 'closed' operation on the judgment result to obtain detection results of cloud, snow and fog in the remote sensing image of the satellite to be detected.
further, the method comprises a step 8 of selecting a proper amount of cloud and ground object samples, fog and ground object samples, snow and ground object samples as training samples again, repeating the steps 2-7 to carry out secondary detection on the remote sensing image of the satellite to be detected, comparing the detection result of the secondary detection with the detection result of the primary detection, determining the type of the position as the type obtained by any detection result if the two detection results of the same position are the same, and determining the type of the position as the ground object if the two detection results of the same position are different, thereby finally obtaining the detection result.
Further, the step 2 is realized as follows,
Step 2.1, calculating gray level characteristics of the sample image, including a gray level mean value, a gray level variance, a first order difference and a histogram information entropy of the sample image;
Wherein the calculation formula of the gray level mean value is,
wherein f (i, j) is the gray value at (i, j), S is M × N, M is the width of the sample image, and N is the height of the sample image;
The gray-scale variance is calculated by the formula,
The first order difference is calculated by the formula,
the calculation formula of the information entropy of the histogram is,
wherein, h [ g ] is the histogram of the sample image, h [ g ] (i) is the percentage of the pixel under a certain gray level to the whole sample image, M is the maximum gray level;
Step 2.2, calculating the texture characteristics of the sample image, including the gradient standard deviation, the mixed entropy, the inverse difference moment and the inverse difference moment of the sample image,
a texture score dimension;
wherein the standard deviation of the gradient is calculated by the formula,
g (i, j; d, θ) { (x 1, y 1) (x 2, y 2) | f (x 1, y 1) ═ i, f (x 2, y 2) ═ j, | (x 1, y 1) - (x 2, y 2) | d, [ phi ((x 1, y 1), (x 2, y 2)) ] where d represents the distance between two pixels, theta represents the direction angle between the pixels, f (x 1, y 1) and f (x 2, y 2) represent the gray scale values of (x 1, y 1) and (x 2, y 2), respectively, phi represents the number of pixel pairs with respect to the horizontal position, and # represents the sum of the number of all pixel pairs in a specific positional relationship, # L x L y represents the maximum value of the gray scale value L g;
The formula for calculating the entropy of the mixture is,
The calculation formula of the inverse difference is that,
The fractal Brownian random field method is used for solving the texture fractal dimension of the sample image, and the expression of the fractal dimension D of the image is,
D=n+1-H
wherein n refers to the spatial dimension of the sample image, and H is a self-similarity parameter;
And 2.3, forming 8-dimensional feature vectors by the gray features and the texture features.
Further, the implementation manner of the step 3 is as follows,
step 3.1, selecting a part of cloud samples and ground feature samples as training samples, and using feature vectors of the training samples as a training set T { (x 1, y 1. (x i, y i) }, i { (1 … N), y i ∈ ψ { -1, 1}, wherein 1 represents a positive class which represents a cloud region class, -1 represents a negative class which represents a ground feature region class, x i ∈ R n, x i is feature vectors, and N is the number of samples;
step 3.2, constructing a classification hyperplane by adopting a support vector machine of a C-SVC model, calculating a Gaussian kernel function,
wherein x i and x j respectively refer to feature vectors of samples i and j, | | x i -x j | | 2 is the square of the euclidean distance, σ is the variance, i is 1 … N, j is 1 … N, and N is the number of samples;
step 3.3, solving Lagrange multiplier vector of the optimal classification hyperplane of the characteristic space by adopting a convex quadratic programming method,
wherein α i is not less than 0 and not more than C, i is 1,2 … N, and is a lagrange multiplier vector, α i and α j respectively represent ith and jth lagrange multipliers, x i and x j respectively represent eigenvectors of an ith sample and a jth sample, y i and y j are respectively represented as categories of the ith sample and the jth sample, C is a penalty parameter, N is the number of samples, and the optimal solution of the lagrange multiplier vector is obtained as follows:
α*=(α1 *,α2 *,...αi *...αN *)T
where α i * represents the optimal solution for the ith Lagrangian multiplier;
Step 3.4, solving the intercept of the optimal classification hyperplane of the feature space, wherein the calculation formula is as follows,
wherein, α i * is the optimal solution of the ith Lagrangian multiplier, y i is the category of the ith sample, and N is the number of samples;
Step 3.5, substituting the obtained Gaussian kernel function, the Lagrange optimal solution and the hyperplane intercept into a decision function,
Step 3.6, taking the rest cloud samples and ground object samples as test samples, testing the decision function, optimizing the decision function, and simultaneously obtaining corresponding cloud image classifiers;
and 3.7, repeating the steps 3.1-3.6 to respectively obtain a snow image classifier and a fog image classifier.
further, in step 4, if the remote sensing image to be detected is a panchromatic image, the down-sampling processing is directly adopted, and if the remote sensing image to be detected is a multispectral image, the down-sampling is carried out by adopting three RGB bands.
further, the step 6 is implemented by selecting a structural element with a square structural shape and a 3 × 3 structural size, performing expansion operation on the three binary images, and performing corrosion operation on the obtained processed images by using the same structural element.
compared with the prior art, the invention has the advantages that: the method can be used for multiple detections after one-time training, the image classifier is obtained through a large amount of image training, the image classifier only needs to be used again during detection, the time complexity of the support vector machine algorithm in the prediction classification stage is low, and the region type can be quickly detected; through tests, the method is suitable for full-color images and n-channel multispectral images, cloud detection is carried out on a plurality of domestic satellite remote sensing images such as a resource number one 02 star, a resource number three, a sky number one, a high-resolution number one and the like by using the method, and the accuracy respectively reaches 94.8%, 96.4%, 93.2% and 95.2%.
Detailed Description
In order to facilitate the understanding and practice of the present invention for those of ordinary skill in the art, the present invention will be described in further detail with reference to the accompanying drawings and examples, which are provided for illustration and explanation and are not intended to limit the scope of the present invention.
Referring to fig. 1, the invention takes the panchromatic image data of the satellite with the resource number one 02C, the satellite with the resource number three and the multispectral remote sensing image data with the sky drawing number one as an example, and the implementation steps are as follows:
step 1, sample acquisition
And (3) down-sampling an original image of the sample into a 1024 × 1024 pixel 8-bit bmp format thumbnail, and performing image segmentation on the thumbnail. And if the remote sensing image is a panchromatic image, directly adopting down-sampling processing, and if the remote sensing image is a multispectral image, adopting RGB three-band to carry out down-sampling. The panchromatic image is divided into 32 x 32 sample blocks, the multispectral image is divided into 16 x 16 image blocks, and 1500 ground object samples, 1000 cloud samples, 1000 snow samples and 1000 fog samples are respectively selected as training sample data.
Step 2, feature extraction: generally speaking, the average brightness of a cloud area in a full-color image and a multispectral image is much higher than that of a fog area, the brightness value of the fog area is greater than that of a ground object area, the cloud and snow areas have similar spectral characteristics, and meanwhile, the cloud, snow, fog and ground objects have obvious differences in gray level distribution, gray level change and the like, so that the target area image and the ground object image can be distinguished to a certain extent by utilizing the gray level characteristics of the image.
extracting the gray characteristic and the texture characteristic vector value of the sample image to form an 8-dimensional characteristic vector, wherein the specific implementation steps are as follows:
Step 2.1, calculating the gray level characteristics of the sample image
step 2.1.1, solving the gray average value, and calculating by using the following formula:
where f (i, j) is the grayscale value at (i, j), S is M × N, M is the width of the sample image, and N is the height of the sample image.
Step 2.1.2, calculating the gray variance of the sample image:
step 2.1.3, calculating the first order difference of the sample image:
step 2.1.4, calculating the histogram information entropy of the sample image:
Where h g is the histogram of the sample image, h g (i) is the percentage of pixels in the entire image at a certain gray level (i), and M is the maximum gray level.
step 2.2, calculating the texture features of the sample image: from the perspective of visual characteristics of human eyes, the texture information of clouds, snow and fog in the satellite remote sensing image is often single and simpler than the texture of ground objects, in addition, the edges of the cloud, snow and fog areas in the image are also fuzzy and smooth, and the edges of the ground objects are generally sharp and have large gradients. Therefore, the texture information and the gradient information of the satellite remote sensing image can be used for detecting and dividing the cloud, snow and fog areas and the ground feature information. In addition, the texture features of the cloud, snow and fog images are obviously different. For the cloud sample, the texture of the cloud sample belongs to random texture, is variable and difficult to detect, shows disorder and no rule, and has thicker and fuzzy edge texture; the fog sample texture is relatively uniform, the smoothness is relatively good, and the edge form is regular; the snow sample is influenced by the ground texture, so that the snow sample has better directionality and large gradient change. And distinguishing different texture characteristics expressed by cloud, snow and fog through the comprehensive information of the image gray level and the image gradient.
step 2.2.1, calculating a gray gradient co-occurrence matrix G (i, j, d, theta) of the sample image, and using the following formula:
g (i, j; d, θ) { (x 1, y 1) (x 2, y 2) | f (x 1, y 1) ═ i, f (x 2, y 2) ═ j, | (x 1, y 1) - (x 2, y 2) | d, ((x 1, y 1), (x 2, y 2)) } θ where d denotes a distance between two pixels, θ denotes a direction angle between pixels, (x, y) denotes coordinates of a pixel point, f (x, y) denotes a gray value of the point, and denotes an angle between the pixel point and a horizontal position, and # denotes the number of pixel pairs obtained according to a constraint condition in a set, for example, two point pixel values are 1 and 2, respectively, the distance between them is 1, θ is 0 °, that is a horizontal direction, and the number of pixel pairs satisfying these conditions is counted throughout the entire image.
step 2.2.2, normalizing the gray level co-occurrence matrix G (i, j, d, theta) into H (i, j; d, theta), wherein the calculation formula is as follows:
Where Σ # L x L y represents the sum of the number of all pixel pairs in a particular positional relationship (i.e., the finger distance d and the included angle θ are the same).
step 2.2.3, calculating the standard deviation of the gradient of the sample image, firstly calculating the average of the gradient:
l g denotes the maximum value of the gray level, and L denotes the maximum value of the gradient.
Substituting the gradient average value T into the following formula to obtain the standard deviation of the gradient:
step 2.2.4, calculating the mixed entropy of the sample image, wherein the calculation formula is as follows:
Step 2.2.5, extracting local stationarity characteristics of the sample image, and calculating an inverse difference, wherein a calculation formula is as follows:
step 2.2.6, solving the texture fractional dimension of the sample image by using a fractal Brownian random field method;
Solving for the constant H (0< H <1) such that the distribution function f (t) satisfies:
F (t) is a distribution function independent of x, Δ x, H is a self-similarity parameter, f (x) is called a real random function with respect to x, n is a spatial dimension of the sample image, and the fractional dimension D of the image is expressed as:
D=n+1-H
step 3, training the image classifier
Training a feature vector of a sample image by using a method of a support vector machine to respectively obtain a cloud image classifier, a snow image classifier and a fog image classifier which are formed by decision functions, wherein the specific implementation comprises the following substeps:
Step 3.1, using 80% of cloud samples and feature samples as training samples, using feature vectors of the training samples as a training set T { (x 1, y 1. (x i, y i) } of the training image classifier, and i ═ 1 … N, wherein y i ∈ ψ { -1, 1} wherein 1 represents a positive class, i.e., a cloud region class, 1 represents a negative class, i.e., a feature region class, x i ∈ R n, x i is a feature vector, and N is a sample number.
step 3.2, constructing a classification hyperplane by adopting a support vector machine of the C-SVC model, and calculating a Gaussian kernel function:
wherein x i and x j respectively refer to the feature vectors of samples i and j, | | x i -x j | | 2 is the square of euclidean distance, σ is variance, and the value of σ is usually selected appropriately according to the experimental result.
step 3.3, solving Lagrange multiplier vectors of the optimal classification hyperplane of the feature space by adopting a convex quadratic programming method:
wherein α i is not less than 0 and not more than C, i is 1,2 … N, and is a lagrange multiplier vector, α i and α j are the ith and jth lagrange multipliers therein, x i and x j respectively represent the eigenvectors of the ith sample and jth sample, y i and y j are the categories of the ith sample and jth sample, C is a penalty parameter, N is the number of samples, and the optimal solution of the lagrange multiplier vector is solved as follows:
α*=(α1 *,α2 *,...αi *...αN *)T
Where α i * represents the optimal solution for the ith lagrange multiplier.
Step 3.4, solving the intercept of the optimal classification hyperplane of the feature space, and calculating a formula:
Wherein, α i * is the optimal solution of the ith Lagrangian multiplier, y i is the positive and negative categories of the ith sample, and N is the number of samples.
And 3.5, substituting the obtained Gaussian kernel function, the Lagrange optimal solution and the hyperplane intercept into a decision function:
and 3.6, taking 20% of the cloud sample and the ground feature sample as a test sample set, testing the decision function, optimizing the decision function, and obtaining the corresponding cloud image classifier.
and 3.7, repeating the steps 3.1-3.6 to respectively obtain a snow image classifier and a fog image classifier.
Step 4, extracting the characteristics of the image to be detected
The method comprises the steps of down-sampling an original image to be detected into a 1024 × 1024 pixel 8-bit bmp format thumbnail, directly performing down-sampling processing if the remote sensing image is a panchromatic image, performing down-sampling by adopting RGB three wave bands if the remote sensing image is a multispectral image, performing image segmentation on the thumbnail to obtain 1024 32 × 32 pixel sub-images, extracting feature vectors of all the sub-images, including gray feature vectors and texture feature vectors, and specifically extracting the feature vectors through step 2.
step 5, classifying the images to be detected
and 5.1, respectively inputting the feature vectors extracted in the step 4 into corresponding cloud, snow and fog image classifiers obtained in the step 3 for prediction classification, and classifying the feature vectors through a decision function.
And 5.2, repeatedly executing the step 3 until all the sub-images are classified, and dividing all the sub-images into cloud areas, fog areas, snow areas and non-cloud snow and fog areas (namely land areas) according to the types of the target areas.
and 5.3, dividing the cloud and ground object areas, the fog and ground object areas and the snow and ground object areas into three binary images, wherein the ground object areas among the images have the same zero value, and the cloud, snow and fog areas have different image values.
Step 6, morphological close operation
selecting structural elements with the square structural shape and the 3 x 3 structural size, respectively performing expansion operation on the three binary images, performing corrosion operation on the obtained processed images by using the same structural elements, connecting cloud, snow and fog areas into a whole, and finally eliminating noise areas at the edges.
Step 7, correction of the overlap region
Step 7.1, comparing three binary image values at the same position: if the image values of the same position of the three images are the same, judging that the position is a ground area; if two same values exist, the position is indicated as a category area represented by a third image value; if the image values are different, the sub-image is indicated to have an overlapping area of cloud, snow and fog, points with zero values are recorded as the overlapping area, and points without zero values are recorded as the triple overlapping area.
7.2, repeating the step 7.1, comparing all image values of the three binary images to obtain discrimination results of cloud, snow and fog areas, ground object areas and overlapping areas, and correcting the overlapping areas; firstly, judging whether the overlapped area is contained in other areas, and if so, replacing the overlapped area with other areas (including the overlapped area and the determined category area); secondly, judging the type of the overlapping area, if the overlapping area is externally connected with a certain determined type area, judging the type of the overlapping area to be the type of the overlapping area except the determined externally connected type, and if not, confirming after the type of the overlapping area is judged to be finished; for the triple overlapping area, if the triple overlapping area is externally connected with a certain determined type area, the overlapping area is judged to be the overlapping area without the externally connected type, and if the triple overlapping area is externally connected with the overlapping area, the type of the overlapping area is judged to be the type of the overlapping area different from the type of the overlapping area externally connected with the overlapping area; and finally, judging the condition that the overlapped areas are only externally connected with different overlapped areas, respectively judging the areas into the categories except the common categories, and finally obtaining the judgment result. For example, if the periphery of the cloud and snow overlapping area is a determined fog area, the cloud and snow area is determined as the fog area; if the cloud and snow area is surrounded by the cloud and fog area, judging the cloud and snow area as the cloud and fog area; if the cloud and snow area is externally connected with the determined cloud area, judging that the area is a snow area; if the cloud area determined by the cloud and snow fog area is externally connected, judging that the area is a snow and fog area; if the cloud snow fog area is externally connected with the cloud fog area, judging the area as a determined snow area; and if the cloud snow area and the cloud and fog area are externally connected, judging that the cloud snow area and the cloud and fog area are a snow area and a fog area respectively.
and 7.3, performing morphological 'closed' operation on the judgment result, wherein the operation method is as described in the step 6, and obtaining a final cloud, snow and fog detection result.
Step 8, secondary detection
and newly selecting 500 cloud and ground object samples, fog and ground object samples, snow and ground object samples to manufacture a support vector machine classifier, and selecting a highlight sample from the ground object. The method comprises the steps of carrying out 'secondary detection' on a sample to be detected, comparing a detection result of the secondary detection with a detection result of the primary detection, determining the type of the position as the type obtained by any one detection result if two detection results of the same position are the same, and determining the type of the position as a ground object if the two detection results of the same position are different, thereby finally obtaining the detection result. For example, if the result of the second inspection is cloud or snow, the result of the first inspection is fog, the area is determined as a feature, and the area can be determined as cloud only if the results of the first and second inspections are cloud.
The specific embodiments described herein are merely illustrative of the spirit of the invention. Various modifications or additions may be made to the described embodiments or alternatives may be employed by those skilled in the art without departing from the spirit or ambit of the invention as defined in the appended claims.