理论
能量梯度函数更适合实时评价图像清晰度,该函数定义如下:
https://blog.csdn.net/Real_Myth/article/details/50827940
代码
def energy(img):
'''
:param img:narray 二维灰度图像
:return: float 图像约清晰越大
'''
shape = np.shape(img)
out = 0
for x in range(0, shape[0]-1):
for y in range(0, shape[1]-1):
out+=((int(img[x+1,y])-int(img[x,y]))**2)+((int(img[x,y+1]-int(img[x,y])))**2)
return out