Case 2: Machine learning_Clustering_Urban color_Impression

Jingyi Chen
3 min readDec 9, 2020

--

In case 1, I introduce urban color analysis. Then we can explore intuitive impression next.

The method of clustering is used to extract the theme color of the image, and display it in the form of chart scatter to obtain the intuitive impression. In this case, two research routes were selected, one is Hupao in Hangzhou and the other is Biyun temple in Beijing. Using km= cluster.KMeans (n_ clusters=params[‘n_ Clusters’]. The “comparing different clustering algorithms on toy datasets” is transplanted to the calculation code of clustering part, which keeps the trace of migration as far as possible, so as to facilitate comparison and view of the difference changes. Set [57]’n_ The number of color clusters is 7, and the number of color clusters can be adjusted. Kmeans clustering algorithm can well separate color data and extract theme color. After extracting the theme colors of all the images, they are summed up in an array to vary= datasets.make_ blobs(n_ samples=n_ samples,cluster_ std=[1.0, 2.5, 0.5],random_ state=random_ The theme color is printed in the form of scatter, which makes it directly reflect the color impression of the city.

The theme color of tiger running is gray and dark (Architectural tone), mixed with green vegetation and blue sky, simple and elegant. Biyun temple is usually red in color, so it feels gorgeous when it is interspersed with vegetation and sky. Biyunsi calculates 124 images. Before clustering, the user-defined function def getpixdata (IMG) is used to compress images and reduce the amount of calculation. It takes about 3–4 hours of computing time to use the general 8g memory, Intel (R) core (TM) i7–4500u CPU @ 1.80GHz 2.40GHz configuration. Because it still needs some time to display the image and the thematic color chart after clustering extraction. Therefore, in the program debugging, we can reduce the image sample size and increase the image compression degree. After the program debugging runs normally, the final calculation is carried out. Through the extraction of urban theme color and the presentation of impression sense organs to study the city color, we can analyze the change of color according to different urban space and different time.

Color impression of Hupao, Hangzhou

Color impression of Biyun temple, Beijing

Survey image, clustering results and theme color extraction of Hupao, Hangzhou

Survey image, clustering results and theme color extraction of Biyun temple, Beijing

--

--