拉普拉斯算子的高通滤波器python
时间: 2023-09-03 20:16:12 浏览: 114
拉普拉斯算子的高通滤波器可以通过巴特沃斯高通滤波器锐化来实现。在python中,可以使用OpenCV库来实现这一功能。下面是一个示例代码:
```python
import cv2
import numpy as np
def laplace_high_pass_filter(img, M, D0):
# 首先对图像进行灰度化处理
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# 对图像进行拉普拉斯锐化
lap_img = cv2.Laplacian(gray_img, cv2.CV_16S, ksize=3)
# 对图像进行巴特沃斯高通滤波器锐化
rows, cols = lap_img.shape
mask = np.zeros((rows, cols), np.float32)
for i in range(rows):
for j in range(cols):
d = np.sqrt((i - rows / 2) ** 2 + (j - cols / 2) ** 2)
mask[i, j = 1 / (1 + (d / D0) ** (2 * M))
filtered_img = np.multiply(lap_img, mask)
# 将图像转换回uint8格式
filtered_img = cv2.convertScaleAbs(filtered_img)
return filtered_img
```
其中,`img`是输入的图像,`M`是巴特沃斯高通滤波器的阶数,`D0`是截断频率。函数会返回经过拉普拉斯算子的高通滤波器锐化后的图像。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [拉普拉斯算子Laplace](https://blog.csdn.net/bblingbbling/article/details/109743608)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [数字图像处理(图像锐化)](https://download.csdn.net/download/liangyuexin/1671610)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文