请生成一段Python代码,它可以读取图片并得到其直方图,翻转直方图数据,再展示出调整后的图片
时间: 2023-03-11 22:25:36 浏览: 64
import matplotlib.pyplot as plt
from PIL import Image# 读取图片
img = Image.open('path/to/image.png')# 得到图片的直方图数据
hist = img.histogram()# 翻转直方图数据
inverted_hist = [255 - x for x in hist]# 展示调整后的图片
plt.imshow(inverted_hist, cmap='gray')
plt.show()