该程序需要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(),显示图片。
可以从结果看到这个两个图像有明显区别。

本文介绍了一种使用Python中的numpy,scipy和matplotlib模块进行图像处理的方法。通过读取图像,调整色彩并展示原始图像与处理后图像的对比,展示了图像处理的基本流程。

被折叠的 条评论
为什么被折叠?



