该程序需要numpy,scipy和matplot.pyplpot三个模块。使用的imread,subplot,imshow和show函数。
import numpy as np
from scipy.misc import imread, imresize
import matplotlib.pyplot as plt
img = imread("D:\\Profile\\Desktop\\cat.jpg")
img_tinted = img * [1, 0.95, 0.1]
# Show the original image
plt.subplot(1, 2, 1)
plt.imshow(img)
# Show the tinted image
plt.subplot(1, 2, 2)
plt.imshow(np.uint8(img_tinted))
plt.show()
imread用来读取图片,双引号里面是图片在本地路径。本程序使用的图片在下方。
img_tinted = img*[1,0.95,0.9],把图片做了一个处理。
plt.imshow(np.unit8(img_tinted)),画图。其中np.unit8是把图片编码格式转换为unit8格式。
plt.show(),显示图片。
可以从结果看到这个两个图像有明显区别。