Remote sensing image classification method based on K-means and CNN

Remote sensing image classification based on K-means and CNN
1. Introduction
1. Research background
Aerospace remote sensing technology is a technology that obtains remote sensing image information data through satellite earth observation. These image data play an indispensable role in various fields. . Remote sensing image classification mainly determines and identifies the attributes of ground objects based on the characteristics of electromagnetic wave radiation of ground objects on remote sensing images, thereby providing auxiliary information for other applications such as target detection and recognition, and can also be used as the final result to provide basic geographical information for map drawing. Measuring, emergency and disaster relief, military reconnaissance and other fields. Remote sensing image classification is an important link in the application of remote sensing technology.
Remote sensing image classification is to use computers to analyze the spectral information and spatial information of various types of ground objects in remote sensing images, select features, divide each pixel in the image into different categories according to certain rules or algorithms, and then obtain the characteristics of remote sensing images. Corresponding information of actual ground objects to achieve image classification. The computer classification of remote sensing images is based on the similarity of pixels in remote sensing images. Distance and correlation coefficient are often used to measure similarity. Common classification methods include: supervised classification and unsupervised classification.
2. Research content
Scholars in various aspects have conducted many studies on the classification of remote sensing images and have proposed many classification methods. Classification methods can be divided into supervised classification and Unsupervised classification. According to the minimum classification unit, classification methods can be divided into pixel-based classification, object-based classification, and classification based on mixed pixel decomposition. In addition, the classification methods of different types of remote sensing images (multispectral remote sensing images, hyperspectral remote sensing images, synthetic aperture radar images) are also different. Since target classification is usually performed in feature space, the expression and learning of features are the key to achieving target classification. According to the way of expressing and learning features, existing remote sensing image classification methods can be roughly divided into three categories: classification methods based on manual feature description, classification methods based on machine learning, and classification methods based on deep learning. It should be noted that these three types of methods do not have strict boundaries, and they overlap and learn from each other. This study used a machine learning and a deep learning method to build the model.

2. Classification method

  1. K-means algorithm
    K-means algorithm is a typical point-by-point modified and iterative dynamic clustering algorithm, and it is also a commonly used method. Its main point is to use the sum of squares of errors as the criterion function. The general approach is to first select some representative points as the core of clustering according to certain principles, and then divide the remaining points to be divided into categories according to a certain method (criteria) to complete the initial classification. After the initial classification is completed, each cluster center is recalculated and the first iteration is completed. Then modify the cluster center for the next iteration. There are two options for this kind of modification, namely point-by-point modification and batch-by-batch modification. Modifying the class center point by point means that after a pixel sample belongs to a certain group of classes according to a certain principle, the mean of the group must be recalculated, and the new mean is used as the agglomeration center point for the next pixel clustering. Modifying the class center batch by batch means that after all pixel samples are classified according to the class center of a certain group, the average value of the modified class is calculated and used as the agglomeration center point for the next classification.
    Code display:
rs_data_trans = rs_data.transpose(1,2,0) 
rs_data.shape, rs_data_trans.shape 
rs_data_1d = rs_data_trans.reshape(-1, rs_data_trans.shape[2]) 
rs_data_1d.shape
cl = cluster.KMeans(n_clusters=4) # create an object of the classifier 
param = cl.fit(rs_data_1d) # train it 
img_cl = cl.labels
img_cl = img_cl.reshape(rs_data_trans[:,:,0].shape) 
prof = rs.profile 
prof.update(count=1) 
with rio.open('result.tif','w',**prof) as dst:
     dst.write(img_cl, 1)
fig, (ax1,ax2) = plt.subplots(figsize=[15,15], nrows=1,ncols=2) 
show(rs, cmap='gray', vmin=vmin, vmax=vmax, ax=ax1) 
show(img_cl, ax=ax2) 
ax1.set_axis_off() 
ax2.set_axis_off() 
fig.savefig("pred.png", bbox_inches='tight') 
plt.show()

K-means classification results (red: cultivated land, green: forest, blue: water body), as shown in the figure:
Insert image description here

  1. CNN algorithm
    CNN convolutional network uses "end-to-end" feature learning, reveals the nonlinear features hidden in the data through a multi-layer processing mechanism, and can automatically learn global features from a large number of training sets (this feature is called "learning features" ”), is an important reason for its success in automatic target recognition in remote sensing images, and also marks the transformation of feature models from manual features to learned features. In this experiment, four layers of convolution + pooling were designed in the CNN network architecture, and then the Relu activation function was used, and finally Softmax was used for normalization processing to calculate the probability of each target category among all possible target categories, and then the input pictures to classify.
    Code display:
# 设计模型: CNN + maxpool 
model = tf.keras.models.Sequential([     
# 我们的数据是150x150而且是三通道的,所以我们的输入应该设置为这样的格式。     

tf.keras.layers.Conv2D(32, (3, 3), 
activation='relu', 
input_shape=(256, 256, 3)),     
tf.keras.layers.MaxPooling2D(2, 2),     
tf.keras.layers.Conv2D(64, (3, 3), 
activation='relu'),     
tf.keras.layers.MaxPooling2D(3, 3),    
tf.keras.layers.Conv2D(128, (3, 3), 
activation='relu'),     
tf.keras.layers.MaxPooling2D(2, 2),     
tf.keras.layers.Conv2D(128, (3, 3), 
activation='relu'),     
tf.keras.layers.MaxPooling2D(2, 2),     
tf.keras.layers.Flatten(),     # 512 neuron hidden layer     
tf.keras.layers.Dense(512, activation='relu'),     
tf.keras.layers.Dense(21, activation='softmax') #'sigmoid' ])

Recognize the following image and output it as the forest category (It is forest), as shown in the figure:
Insert image description here

3. Summary
The great success of deep learning in the field of computer vision provides important opportunities for remote sensing intelligent analysis; machine learning innovation also brings more ideas to remote sensing image classification. In recent years, these algorithms have been widely used in the field of remote sensing. They have shown great advantages and development potential in automatic and rapid detection of large-scale targets, fine classification of complex scenes, and rapid identification of surface parameters. They have continuously improved the efficiency and quality of intelligent image classification and provided a basis for remote sensing. Intelligent information extraction from data brings development opportunities.
Remote sensing big data is a new stage in the development of space-time science and technology. Remote sensing image classification, quantification, and prediction have gradually transformed from traditional statistical mathematical analysis and quantitative remote sensing modeling analysis to data-driven intelligent analysis. The era of remote sensing big data marked by intelligent analysis has arrived. How to broaden and deepen its application is worthy of continuous exploration by the industry and academia. But it will undoubtedly bring about a profound change in the aerospace industry, smart cities, and digitalization of government and enterprises.

代码:
CNN:
https://gitee.com/A-xinss/cnn-to-remote-sensing-image-classification
CNN-进阶版
K-Means:
https://gitee.com/A-xinss/k-means-to-remote-sensing-image-classification

Guess you like

Origin blog.csdn.net/perfectzxiny/article/details/134899716