如何在matlab程序的图像中添加高斯白噪声?% 小波变换,加噪,去噪,增强% 《Denoising and contrast enhancement via wavelet shrinkage and nonlinear adaptive gain》clear; clcimage=imread('555.jpg');image=imread('555.jpg');figure; im

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/29 11:31:05
如何在matlab程序的图像中添加高斯白噪声?%小波变换,加噪,去噪,增强%《Denoisingandcontrastenhancementviawaveletshrinkageandnonlinea

如何在matlab程序的图像中添加高斯白噪声?% 小波变换,加噪,去噪,增强% 《Denoising and contrast enhancement via wavelet shrinkage and nonlinear adaptive gain》clear; clcimage=imread('555.jpg');image=imread('555.jpg');figure; im
如何在matlab程序的图像中添加高斯白噪声?
% 小波变换,加噪,去噪,增强
% 《Denoising and contrast enhancement via wavelet shrinkage and nonlinear adaptive gain》
clear; clc
image=imread('555.jpg');
image=imread('555.jpg');
figure; imshow(image); title('the original image');
% 加噪
image=double(image);
I=image+20*randn(size(image));
figure; imshow(uint8(I)); title('noised image');
% 小波分解
dwtmode('per');
[a1,h1,v1,d1]=dwt2(I,'sym8'); % 从1到3分辨率递减
[a2,h2,v2,d2]=dwt2(a1,'sym8');
[a3,h3,v3,d3]=dwt2(a2,'sym8');
% 计算去噪时的阈值
sigma=median(abs(d1(:)))/0.6745; % 确定噪声标准差
thr=2*sigma; % 权值根据实际情况选取
thr1=thr*2^(-(3-1)/2); % 分层阈值,从1到3分辨率递增,即这里的th1对应于小波系数的第3层
thr2=thr*2^(-(3-2)/2);
thr3=thr*2^(-(3-3)/2);
% 去噪
ccch=soft_t(h3,thr1); cccv=soft_t(v3,thr1); cccd=soft_t(d3,thr1);
cch=soft_t(h2,thr2); ccv=soft_t(v2,thr2); ccd=soft_t(d2,thr2);
ch=soft_t(h1,thr3); cv=soft_t(v1,thr3); cd=soft_t(d1,thr3);
% 重构去噪图像
cca=idwt2(a3,ccch,cccv,cccd,'sym8');
ca=idwt2(cca,cch,ccv,ccd,'sym8');
J1=idwt2(ca,ch,cv,cd,'sym8');
J1=uint8(J1);
figure; imshow(J1); title('denoised image');
p=psnr(image,J1)
就是这个程序,它原本是添加随即噪声的,我想问下怎么改成添加高斯白噪声?我自己试着添加了一下 结果出现?Error using ==> imnoise
A double-class image must have values between zero and one.

如何在matlab程序的图像中添加高斯白噪声?% 小波变换,加噪,去噪,增强% 《Denoising and contrast enhancement via wavelet shrinkage and nonlinear adaptive gain》clear; clcimage=imread('555.jpg');image=imread('555.jpg');figure; im
使用imnoise函数
X=imread('D:\matlab7.1\toolbox\images\imdemos\greens.jpg');
Y=imnoise(X,'gaussian');%%默认均值为0,方差为0.01
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A double-class image must have values between zero and one,这个问题是你的图像是double型,但是你的图像的数值不是0-1之间,给他除以255即可!