This commit is contained in:
张梦南 2025-05-06 22:27:11 +08:00
parent b8a95e3da7
commit dc7b8a5bc1
11 changed files with 57 additions and 1 deletions

View File

@ -6,7 +6,7 @@ plt.rcParams['axes.unicode_minus'] = False
from Gaussian_Highpass import gaussian_high_pass_filter
# 读取照片
image_characterTestPattern2 = cv2.imread('file/characterTestPattern2.jpg', 0) # 改成你自己的图片路径
image_characterTestPattern2 = cv2.imread('file/characterTestPattern2.jpg', cv2.IMREAD_GRAYSCALE)
# 快速傅里叶变换
dft_characterTestPattern2 = np.fft.fft2(image_characterTestPattern2)

47
Filtering_HFE.py Normal file
View File

@ -0,0 +1,47 @@
import cv2
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['simHei']
plt.rcParams['axes.unicode_minus'] = False
from High_Frequency_Emphasis import apply_hfe_filter
# 读取照片
image_boy34 = cv2.imread("file/boy34.jpg", cv2.IMREAD_GRAYSCALE)
# 利用HFE滤波器处理
k1 = 0.8
k2 = 0.2
k11 = 0.5
k22 = 0.5
k111 = 0.2
k222 = 0.8
image_boy341 = apply_hfe_filter(image_boy34, k1, k2)
image_boy342 = apply_hfe_filter(image_boy34, k11, k22)
image_boy343 = apply_hfe_filter(image_boy34, k111, k222)
# 展示图像
plt.subplot(2,2,1)
plt.imshow(image_boy34, cmap='gray')
plt.title('原图')
plt.axis('off')
plt.subplot(2,2,2)
plt.imshow(image_boy341, cmap='gray')
plt.title('HFE滤波器K1=0.8,K2=0.2')
plt.axis('off')
plt.subplot(2,2,3)
plt.imshow(image_boy342, cmap='gray')
plt.title('HFE滤波器K1=0.5,K2=0.5')
plt.axis('off')
plt.subplot(2,2,4)
plt.imshow(image_boy343, cmap='gray')
plt.title('HFE滤波器K1=0.2,K2=0.5')
plt.axis('off')
plt.tight_layout()
plt.show()

View File

@ -0,0 +1,9 @@
import cv2
def apply_hfe_filter(image, k1, k2):
high_pass = cv2.Laplacian(image, cv2.CV_64F)
high_pass = cv2.convertScaleAbs(high_pass)
hfe_result = cv2.addWeighted(image, k1, high_pass, k2, 0)
return hfe_result

View File

Before

Width:  |  Height:  |  Size: 149 KiB

After

Width:  |  Height:  |  Size: 149 KiB

View File

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 119 KiB

View File

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 110 KiB

View File

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB