轉(zhuǎn):https://www.cnblogs.com/hyddd/p/7689132.html
這個(gè)密鑰交換方法,由惠特菲爾德·迪菲(Bailey Whitfield Diffie)、馬丁·赫爾曼(Martin Edward Hellman)于1976年發(fā)表。
它是一種安全協(xié)議,讓雙方在完全沒有對(duì)方任何預(yù)先信息的條件下通過不安全信道建立起一個(gè)密鑰,這個(gè)密鑰一般作為“對(duì)稱加密”的密鑰而被雙方在后續(xù)數(shù)據(jù)傳輸中使用。DH數(shù)學(xué)原理是base離散對(duì)數(shù)問題。做類似事情的還有非對(duì)稱加密類算法,如:RSA。
其應(yīng)用非常廣泛,在SSH、VPN、Https...都有應(yīng)用,勘稱現(xiàn)代密碼基石。
DH算法是相當(dāng)簡(jiǎn)單、直觀的,我直接把wikipedia的描述拿過來了:

DH算法是相當(dāng)簡(jiǎn)單、直觀的,我直接把wikipedia的描述拿過來了:
上圖中,Alice和Bob通過DH算法生成秘鑰K, 其中:
注:
再來個(gè)直觀的圖說明下:

再來個(gè)直觀的圖說明下:
第2頁?/(共2頁)
最近用ssim測(cè)試圖片畫質(zhì)損傷時(shí),發(fā)現(xiàn)matlab自帶ssim與之前一直使用的ssim計(jì)算得分有差異,故和同事開始確定差異所在。
這里提到不同的ssim版本主要基于matlab。如前言所述,主要分為2個(gè)實(shí)現(xiàn)。
雖然2個(gè)版本的代碼實(shí)現(xiàn)完全不一樣,但總的說,差異可以歸結(jié)為以下幾點(diǎn):
The precisely right scale depends on both the image resolution and the viewing distance and is usually difficult to be obtained. In practice, we suggest to use the following empirical formula to determine the scale for images viewed from a typical distance (say 3~5 times of the image height or width): 1) Let F = max(1, round(N/256)), where N is the number of pixels in image height (or width); 2) Average local F by F pixels and then downsample the image by a factor of F; and 3) apply the ssim_index.m program. For example, for an 512 by 512 image, F = max(1, round(512/256)) = 2, so the image should be averaged within a 2 by 2 window and downsampled by a factor of 2 before applying ssim_index.m.
上面這段意思:人看圖片時(shí),與圖片有一定距離(相當(dāng)于圖片縮小),一些細(xì)節(jié)可被忽略,如果進(jìn)行downsample,除了減低運(yùn)算復(fù)雜度,還能更貼合人的主觀觀看感受。
涉及downsample的代碼部分:
Zhou Wang版本 代碼:
matlab版本 代碼:



