[VP] 拉普拉斯算子 Laplacian Filter
生活随笔
收集整理的這篇文章主要介紹了
[VP] 拉普拉斯算子 Laplacian Filter
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
拉普拉斯算子
- 拉普拉斯算子
- 性質
拉普拉斯算子
長這樣:
[?12?1?12?1?12?1]\begin{bmatrix} -1 & 2 &-1 \\ -1 & 2 &-1 \\-1 & 2 &-1 \end{bmatrix}????1?1?1?222??1?1?1????
性質
Image = np.array([[0, 0, 0, 0, 0, 0], [0, 1, 5, 9, 7, 0], [0, 1, 5, 9, 7, 0], [0, 1, 5, 9, 7, 0], [0, 1, 5, 9, 7, 0], [0, 0, 0, 0, 0, 0]])Kernel = [[-1, 2, -1], [-1, 2, -1], [-1, 2, -1]]ax1 = plt.subplot(1,2,1) plt.imshow(Image) plt.title('Image')ax1 = plt.subplot(1,2,2) plt.imshow(Kernel) plt.title('Kernel')def convolution(Image, Kernel):count = 0for i in range(0, 3):for j in range(0, 3):count += Image[2-i][2-j]*Kernel[i][j]return countdef correlation(Image, Kernel):count = 0for i in range(0, 3):for j in range(0, 3):count += Image[i][j]*Kernel[i][j]return countresult1 = [[0, 0, 0, 0], [0, 0, 0, 0],[0, 0, 0, 0], [0, 0, 0, 0]]for i in range(4):for j in range(4):result1[i][j] = convolution(Image[i:i+3, j:j+3], Kernel)result2 = [[0, 0, 0, 0], [0, 0, 0, 0],[0, 0, 0, 0], [0, 0, 0, 0]]for i in range(4):for j in range(4):result2[i][j] = correlation(Image[i:i+3, j:j+3], Kernel)_, ax = plt.subplots(1, 2, figsize = (10, 10))ax[0].imshow(result1) ax[0].set_title('Convolution Result') ax[1].imshow(result2) ax[1].set_title('Correlation Result')從結果看出,用拉普拉斯算子對圖像做卷積和關聯操作,其結果是一樣的,因為拉普拉斯算子本身旋轉 180° 的結果還是它本身。
總結
以上是生活随笔為你收集整理的[VP] 拉普拉斯算子 Laplacian Filter的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: amoeba mysql_详解如何利用a
- 下一篇: 7、核心芯片说明文档