python计算图像感知相似度(PHash Sim)实例_图像相似度计算_图像质量评价

scient

scient一个用python实现科学计算相关算法的包,包括自然语言、图像、神经网络、优化算法、机器学习、图计算等模块。

scient源码和编译安装包可以在Python package index获取。

The source code and binary installers for the latest released version are available at the [Python package index].

https://pypi.org/project/scient

可以用pip安装scient

You can install scient like this:

pip install scient

也可以用setup.py安装。

Or in the scient directory, execute:

python setup.py install

scient.image

图像相关算法模块,包括边缘检测、图像相似度计算、图像质量评价、图像特征提取等。

scient.image.hash

图像hash模块,包括均值hash(mean hash),差值hash(diff hash),感知hash(percept hash)。

scient.image.hash.percept(image,hash_size=64)

Parameters

image : numpy.array 2D

hash_size : 输出hash值的长度

Returns

list

Algorithms

先将图片缩放成hash_size * hash_size大小,然后对图像进行离散余弦变换DCT,并输出左上角h * w=hash_size的mean hash。
DCT是一种特殊的傅立叶变换,将图片从像素域变换为频率域,并且DCT矩阵从左上角到右下角代表越来越高频率的系数,图片的主要信息保留左上角的低频区域。

一维DCT变换:

F ( x ) = c ( x ) ∑ i = 0 N − 1 f ( i ) c o s ( ( i + 0.5 ) π N x ) c ( x ) = { 1 N , x = 0 2 N , x ! = 0 F(x)=c(x)\sum^{N-1}_{i=0}{f(i)cos(\frac {(i+0.5)π}{N}x) } \\ c(x)=\left\{\begin{matrix}\sqrt{\frac{1}{N}} ,x=0\\\sqrt{\frac{2}{N}} ,x!=0 \end{matrix}\right. F(x)=c(x)i=0N1f(i)cos(N(i+0.5)πx)c

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值