
在你的问题中,
noise_real=0.1*(randn(1,6)+1)
如果要产生复数的随机噪声,用randn分别构造实部与虚部,即:
A=randn(2,6)+1
n_real=A(1,:)
n_imag=A(2,:)
noise_comp=0.1/sqrt(2)*(n_real+j*n_imag)
%%可以用着两行来验证均值跟方差
% M=mean(noise_comp)
% N=var(noise_comp)
%%
你可以注册一些Matlab的论坛,之后下点别人共享的代码,多读就会了哈!
祝好!
M=imread('dl011.jpg') %读取MATLAB中的名为cameraman的图像subplot(3,3,1)
imshow(M) %显示原始图像
title('original')
P1=imnoise(M,'gaussian',0.02) %加入高斯躁声
subplot(3,3,2)
imshow(P1)%加入高斯躁声后显示图像
title('gaussian noise')
P2=imnoise(M,'salt &pepper',0.02) %加入椒盐躁声
subplot(3,3,3)
imshow(P2)%%加入椒盐躁声后显示图像
title('salt &pepper noise')
g=medfilt2(P1) %对高斯躁声中值滤波
subplot(3,3,5)
imshow(g)
title('medfilter gaussian')
h=medfilt2(P2) %对椒盐躁声中值滤波
subplot(3,3,6)
imshow(h)
title('medfilter salt &pepper noise')
l=[1 1 1 %对高斯躁声算术均值滤波
1 1 1
1 1 1]
l=l/9
k=conv2(P1,l)
subplot(3,3,8)
imshow(k,[])
title('arithmeticfilter gaussian')
%对椒盐躁声算术均值滤波
d=conv2(P2,l)
subplot(3,3,9)
imshow(d,[])
title('arithmeticfilter salt &pepper noise')
在matlab中无论是wgn还是awgn函数,实质都是由randn函数产生的噪声。即,wgn函数中调用了randn函数,而awgn函数中调用了wgn函数。根据awgn的实现代码可以知道“向已知信号添加某个信噪比(SNR)的高斯白噪声”,
即:awgn(x,snr,’measured’,'linear’),命令的作用是对原信号x添加信噪比(比值)为SNR的噪声,在添加之前先估计信号x的强度。
直接对原始信号添加噪声:
y=x+rand(length(x),1)
y=x+randn(length(x),1))
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)