日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python 图像清晰度_图像清晰度评价指标(Python)

發(fā)布時間:2023/12/8 python 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python 图像清晰度_图像清晰度评价指标(Python) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

最近在畢業(yè)設(shè)計中涉及了有關(guān)增強圖像清晰度的實驗,需要一些指標(biāo)來進行實驗結(jié)果的評估。剛好網(wǎng)上有個總結(jié)的非常好的博客(見參考文獻(xiàn)[1]),但沒有實現(xiàn)方法。因此,我將在我的博客中用Python實現(xiàn)。

評估方法實現(xiàn)

所有函數(shù)的具體說明都在參考文獻(xiàn)[1]里,這里不做過多的贅述,

只討論實現(xiàn)

github:圖像清晰度評估算法包(有示例)

1 Brenner 梯度函數(shù)

def brenner(img):

'''

:param img:narray 二維灰度圖像

:return: float 圖像約清晰越大

'''

shape = np.shape(img)

out = 0

for x in range(0, shape[0]-2):

for y in range(0, shape[1]):

out+=(int(img[x+2,y])-int(img[x,y]))**2

return out

2 Laplacian梯度函數(shù)

def Laplacian(img):

'''

:param img:narray 二維灰度圖像

:return: float 圖像約清晰越大

'''

return cv2.Laplacian(img,cv2.CV_64F).var()

3 SMD(灰度方差)

def SMD(img):

'''

:param img:narray 二維灰度圖像

:return: float 圖像約清晰越大

'''

shape = np.shape(img)

out = 0

for x in range(0, shape[0]-1):

for y in range(1, shape[1]):

out+=math.fabs(int(img[x,y])-int(img[x,y-1]))

out+=math.fabs(int(img[x,y]-int(img[x+1,y])))

return out

4 SMD2(灰度方差乘積)

def SMD2(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+=math.fabs(int(img[x,y])-int(img[x+1,y]))*math.fabs(int(img[x,y]-int(img[x,y+1])))

return out

5 方差函數(shù)

def variance(img):

'''

:param img:narray 二維灰度圖像

:return: float 圖像約清晰越大

'''

out = 0

u = np.mean(img)

shape = np.shape(img)

for x in range(0,shape[0]):

for y in range(0,shape[1]):

out+=(img[x,y]-u)**2

return out

6 能量梯度函數(shù)

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

7 Vollath函數(shù)

def Vollath(img):

'''

:param img:narray 二維灰度圖像

:return: float 圖像約清晰越大

'''

shape = np.shape(img)

u = np.mean(img)

out = -shape[0]*shape[1]*(u**2)

for x in range(0, shape[0]-1):

for y in range(0, shape[1]):

out+=int(img[x,y])*int(img[x+1,y])

return out

8 熵函數(shù)

def entropy(img):

'''

:param img:narray 二維灰度圖像

:return: float 圖像約清晰越大

'''

out = 0

count = np.shape(img)[0]*np.shape(img)[1]

p = np.bincount(np.array(img).flatten())

for i in range(0, len(p)):

if p[i]!=0:

out-=p[i]*math.log(p[i]/count)/count

return out

參考文獻(xiàn)

[1] 圖像清晰度的評價指標(biāo)

總結(jié)

以上是生活随笔為你收集整理的python 图像清晰度_图像清晰度评价指标(Python)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。