标签:分享图片 color 应用 image clust int sample png nbsp
from sklearn.datasets import load_sample_image china=load_sample_image(‘china.jpg‘) print(china.shape) china
import matplotlib.pyplot as plt plt.imshow(china) plt.show()
plt.imshow(china[:,:,0],plt.cm.gray)
plt.show()
plt.imshow(china[:,:,2])
plt.show()
from sklearn.datasets import load_sample_image from sklearn.cluster import KMeans import matplotlib.pyplot as plt import numpy as np china=load_sample_image("china.jpg") plt.imshow(china) plt.show() image=china[::3,::3] image.shape plt.imshow(image) plt.show() x=image.reshape(-1,3) model=KMeans(n_clusters=64) model.fit_predict(x) a=model.cluster_centers_
from sklearn.datasets import load_sample_image china=load_sample_image(‘china.jpg‘) import sys sys.getsizeof(china)
sys.getsizeof(image)
import matplotlib.image as img img.imsave(‘E://01.jpg‘,china) img.imsave(‘E://02.JPg‘,image)
二
标签:分享图片 color 应用 image clust int sample png nbsp
原文地址:https://www.cnblogs.com/yuxiang1212/p/9945562.html