One
As picture signal and Additive white noise are discrete random variables: X 、 Y X、Y X、Y , picture can be show by : f ( X ) + g ( Y ) f(X)+g(Y) f(X)+g(Y)
∵ \because ∵ X , Y X,Y X,Y are mutually independent. Then E ( Y ) = 0 E(Y)=0 E(Y)=0
∵ \because ∵
D ( X ) = E ( X 2 ) − E ( X ) 2 D(X)=E(X^2)-E(X)^2 D(X)=E(X2)−E(X)2
E ( X Y ) = E ( X ) E ( Y ) E(XY)=E(X)E(Y) E(XY)=E(X)E(Y)
D ( X + Y ) = D ( X ) + D ( Y ) D(X+Y)=D(X)+D(Y) D(X+Y)=D(X)+D(Y)
E ( X Y ) = E ( X ) E ( Y ) E(XY)=E(X)E(Y) E(XY)=E(X)E(Y)
∴ \therefore ∴
D ( X + Y ) = D ( Y ) D(X+Y)=D(Y) D(X+Y)=D(Y)
So If you are new to noise reduction modules, you can try using this component to measure the fluctuation of the noise you are removing. It’s not hard to see that the bigger the variance, the louder the noise.
Further, we need to know about homomorphic transformations.
what is homomorphic transformations?
Homomorphic transformation generally refers to the nonlinear combination signal through some transformation, so that it can be more convenient to use linear operation to process the signal. If you want to learn more, check out this blog post.https://blog.csdn.net/edogawachia/article/details/79368882
To describe it mathematically:
f ( x ) g ( x ) f(x)g(x) f(x)g(x) -> e l o g ( f ( x ) g ( x ) ) e^{log(f(x)g(x))} elog(f(x)g(x))-> e l o g f ( x ) + l o g g ( x ) e^{logf(x)+logg(x)} elogf(x)+logg(x)
If you want to know how to use it, this blog can give you answer. https://blog.csdn.net/wang_xinyu/article/details/111232266?spm=1001.2101.3001.6650.2&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-2.pc_relevant_paycolumn_v2&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-2.pc_relevant_paycolumn_v2&utm_relevant_index=5
code :
import cv2
import numpy as np
def homomorphic_filter(src, d0=10, rl=0.5, rh=2.0, c=4, h=2.0, l=0.5):
gray = src.copy()
if len(src.shape) > 2:
gray = cv2.cvtColor(src, cv2.COLOR_BGR2GRAY) # 转换成灰度图像
gray = np.log(1e-5 + gray) # 取对数
rows, cols = gray.shape
gray_fft = np.fft.fft2(gray) # FFT傅里叶变换
gray_fftshift = np.fft.fftshift(gray_fft) # FFT中心化
M, N = np.meshgrid(np.arange(-cols // 2, cols // 2), np.arange(-rows // 2, rows // 2))
D = np.sqrt(M ** 2 + N ** 2) # 计算距离
Z = (rh - rl) * (1 - np.exp(-c * (D ** 2 / d0 ** 2))) + rl # H(u,v)传输函数
dst_fftshift = Z * gray_fftshift
dst_fftshift = (h - l) * dst_fftshift + l
dst_ifftshift = np.fft.ifftshift(dst_fftshift)
dst_ifft = np.fft.ifft2(dst_ifftshift) # IFFT逆傅里叶变换
dst = np.real(dst_ifft) # IFFT取实部
dst = np.exp(dst) - 1 # 还原
dst = np.uint8(np.clip(dst, 0, 255))
return dst
img = cv2.imread('hf1.jpg')
img_new = homomorphic_filter(img)
cv2.imshow("img", img)
cv2.imshow("img_new", img_new)
cv2.imwrite("img_new1.jpg", img_new)
key = cv2.waitKey(0)
cv2.destroyAllWindows()