目錄
銳化(高通)空間濾波器
- 平滑通過稱為低通濾波
- 類似于積分運算
- 銳化通常稱為高通濾波
- 微分運算
- 高過(負責細節的)高頻,衰減或抑制低頻
鈍化掩蔽和高提升濾波
-
鈍化掩蔽
-
從原圖像中減去一幅鈍化(平滑后的)圖像
-
步驟:
模糊原圖像從原圖像減去模糊后的圖像(產生的差稱為模板)將模板與原圖像相加
令fˉ(x,y)\bar f(x,y)fˉ?(x,y)表示模糊后的圖像,則有
gmask(x,y)=f(x,y)?fˉ(x,y)(3.55)g_{mask}(x, y) = f(x, y) - \bar f(x,y) \tag{3.55}gmask?(x,y)=f(x,y)?fˉ?(x,y)(3.55)
g(x,y)=f(x,y)+kgmask(x,y)(3.56)g(x,y) = f(x,y) + k g_{mask}(x, y) \tag{3.56}g(x,y)=f(x,y)+kgmask?(x,y)(3.56)
權值k≥0k \ge 0k≥0,k=1k = 1k=1時,它是鈍化掩蔽,k>1k > 1k>1時,這個過程稱為高提升濾波,選擇k≤1k \leq 1k≤1可以減少鈍化模板的貢獻。
y
= np
.linspace
(0.4,1, 7)
y
= np
.pad
(y
, (4, 4), mode
='constant', constant_values
=[0.4, 1])fig
= plt
.figure
(figsize
=(16, 8))
ax_1
= fig
.add_subplot
(2, 2, 1)
ax_1
.plot
(y
, '-', label
="y")
ax_1
.legend
(loc
='best', fontsize
=12)kernel
= np
.array
([0.2, 0.6, 0.2])
y_bar
= np
.convolve
(y
, kernel
, 'same')y_bar
= y_bar
[1:-1]
ax_2
= fig
.add_subplot
(2, 2, 2)
ax_2
.plot
(y_bar
, '-', label
='Smooth')
ax_2
.legend
(loc
='best', fontsize
=12)y
= y
[1:-1]
y_mask
= y
- y_barax_3
= fig
.add_subplot
(2, 2, 3)
ax_3
.plot
(y_mask
, '-', label
='y - y_bar')
ax_3
.legend
(loc
='best', fontsize
=12)y_dst
= y
+ y_mask
y_dst
= normalize
(y_dst
)
ax_4
= fig
.add_subplot
(2, 2, 4)
ax_4
.plot
(y_dst
, '-', label
='y + y_mask')
ax_4
.legend
(loc
='best', fontsize
=12)plt
.tight_layout
()
plt
.show
()
img_ori
= cv2
.imread
("DIP_Figures/DIP3E_Original_Images_CH03/Fig0338(a)(blurry_moon).tif", 0)kernel_31
= gauss_kernel
((9, 9), sigma
=1)
img_31
= separate_kernel_conv2D
(img_ori
, kernel
=kernel_31
)
img_31
= np
.uint8
(normalize
(img_31
) * 255)img_diff
= img_ori
- img_31img_dst_1
= img_ori
+ img_diff
img_dst_1
= np
.uint8
(normalize
(img_dst_1
) * 255)img_dst_2
= img_ori
+ 2 * img_diff
img_dst_2
= np
.uint8
(normalize
(img_dst_2
) * 255)img_dst_3
= img_ori
- 3 * img_diff
img_dst_3
= np
.uint8
(normalize
(img_dst_3
) * 255)plt
.figure
(figsize
=(15, 12))
plt
.subplot
(2,3,1), plt
.imshow
(img_ori
, 'gray', vmax
=255), plt
.title
("Original"), plt
.xticks
([]), plt
.yticks
([])
plt
.subplot
(2,3,2), plt
.imshow
(img_31
, 'gray', vmax
=255), plt
.title
("Smooth"), plt
.xticks
([]), plt
.yticks
([])
plt
.subplot
(2,3,3), plt
.imshow
(img_diff
, 'gray', vmax
=255), plt
.title
("Diff"), plt
.xticks
([]), plt
.yticks
([])
plt
.subplot
(2,3,4), plt
.imshow
(img_dst_1
, 'gray', vmax
=255), plt
.title
("k = 1"), plt
.xticks
([]), plt
.yticks
([])
plt
.subplot
(2,3,5), plt
.imshow
(img_dst_2
, 'gray', vmax
=255), plt
.title
("k = 2"), plt
.xticks
([]), plt
.yticks
([])
plt
.subplot
(2,3,6), plt
.imshow
(img_dst_2
, 'gray', vmax
=255), plt
.title
("k = 3"), plt
.xticks
([]), plt
.yticks
([])
plt
.tight_layout
()
plt
.show
()
總結
以上是生活随笔為你收集整理的第3章 Python 数字图像处理(DIP) - 灰度变换与空间滤波16 - 锐化高通滤波器 - 钝化掩蔽和高提升滤波的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。