import matplotlib.image as image
img1 = image.imread('.\data\images\logo-64x64.jpg') # 读取图片
plt.imshow(img1)
我老婆摔跤了还是那么可爱:
我要把她变得粉嫩嫩的:
# 我想找a中[<252, <252, <252]的数组,但是不知道怎么索引,目前先用遍历的方法
a = np.array(img1)
_, m, _ = a.shape
for n, (i, j, k) in enumerate(zip(a[:,:,0].flatten(), a[:,:,1].flatten(), a[:,:,2].flatten())):
if i>=252 and j >= 252 and k >=252: # 把白色换成粉色
a[int(n/m)][n - int(n/m)*m] = [253,243,243] # 粉色
image.imsave('.\data\images\logo-64x642.jpg', a) # 保存图片
plt.imshow(a)