diff --git a/Filtering_Gaussian_Highpass.py b/Filtering_Gaussian_Highpass.py index 68d9e01..a734415 100644 --- a/Filtering_Gaussian_Highpass.py +++ b/Filtering_Gaussian_Highpass.py @@ -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) diff --git a/Filtering_HFE.py b/Filtering_HFE.py new file mode 100644 index 0000000..618b595 --- /dev/null +++ b/Filtering_HFE.py @@ -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() \ No newline at end of file diff --git a/High_Frequency_Emphasis.py b/High_Frequency_Emphasis.py new file mode 100644 index 0000000..4cb87ff --- /dev/null +++ b/High_Frequency_Emphasis.py @@ -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 \ No newline at end of file diff --git a/Result_Photo_Filtering/Figure_1.png b/Result_Photo_Filtering/3.Gaussian_Highpass10.png similarity index 100% rename from Result_Photo_Filtering/Figure_1.png rename to Result_Photo_Filtering/3.Gaussian_Highpass10.png diff --git a/Result_Photo_Filtering/Figure_2.png b/Result_Photo_Filtering/3.Gaussian_Highpass100.png similarity index 100% rename from Result_Photo_Filtering/Figure_2.png rename to Result_Photo_Filtering/3.Gaussian_Highpass100.png diff --git a/Result_Photo_Filtering/Figure_3.png b/Result_Photo_Filtering/3.Gaussian_Highpass1000.png similarity index 100% rename from Result_Photo_Filtering/Figure_3.png rename to Result_Photo_Filtering/3.Gaussian_Highpass1000.png diff --git a/Result_Photo_Filtering/Figure_All.png b/Result_Photo_Filtering/3.Gaussian_Highpass_All.png similarity index 100% rename from Result_Photo_Filtering/Figure_All.png rename to Result_Photo_Filtering/3.Gaussian_Highpass_All.png diff --git a/Result_Photo_Filtering/4.HFE_0.2_0.8.png b/Result_Photo_Filtering/4.HFE_0.2_0.8.png new file mode 100644 index 0000000..8bc6f59 Binary files /dev/null and b/Result_Photo_Filtering/4.HFE_0.2_0.8.png differ diff --git a/Result_Photo_Filtering/4.HFE_0.5_0.5.png b/Result_Photo_Filtering/4.HFE_0.5_0.5.png new file mode 100644 index 0000000..a6d17a4 Binary files /dev/null and b/Result_Photo_Filtering/4.HFE_0.5_0.5.png differ diff --git a/Result_Photo_Filtering/4.HFE_0.8_0.2.png b/Result_Photo_Filtering/4.HFE_0.8_0.2.png new file mode 100644 index 0000000..a6da56c Binary files /dev/null and b/Result_Photo_Filtering/4.HFE_0.8_0.2.png differ diff --git a/Result_Photo_Filtering/4.HFE_All.png b/Result_Photo_Filtering/4.HFE_All.png new file mode 100644 index 0000000..ac27032 Binary files /dev/null and b/Result_Photo_Filtering/4.HFE_All.png differ