最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python 3.x - Perceptual Hashing with Imagehash without saving matplotlib plots - Stack Overflow

programmeradmin1浏览0评论

I am creating matplotlib plots using data processed by a function. I would like to plot the data and compare the plot to another plot, albeit on different scales. I am using image hash library but unable to get the hash of an image without saving it first.

import hashlib
import numpy as np
import matplotlib.pyplot as plt
import imagehash
from io import BytesIO

X = np.linspace(0,100,1000)
Y = np.sin(0.5*X)
plt.plot(X,Y)
buffer1 = BytesIO()
plt.savefig(buffer1, format='png')
#canvas = plt.gcf().canvas
#canvas.draw()
#new_hash = hashlib.sha1(np.array(canvas.buffer_rgba())).hexdigest()
new_hash = imagehash.whash(buffer1)
print(str(new_hash))
plt.cla()

How can I do this. I saw a thread that uses hash lib but I would like to use image hash library.

发布评论

评论列表(0)

  1. 暂无评论