Finish
@ -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
@ -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()
|
9
High_Frequency_Emphasis.py
Normal 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
|
Before Width: | Height: | Size: 149 KiB After Width: | Height: | Size: 149 KiB |
Before Width: | Height: | Size: 119 KiB After Width: | Height: | Size: 119 KiB |
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 110 KiB |
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 132 KiB |
BIN
Result_Photo_Filtering/4.HFE_0.2_0.8.png
Normal file
After Width: | Height: | Size: 184 KiB |
BIN
Result_Photo_Filtering/4.HFE_0.5_0.5.png
Normal file
After Width: | Height: | Size: 173 KiB |
BIN
Result_Photo_Filtering/4.HFE_0.8_0.2.png
Normal file
After Width: | Height: | Size: 178 KiB |
BIN
Result_Photo_Filtering/4.HFE_All.png
Normal file
After Width: | Height: | Size: 164 KiB |