ZKX's LAB

基于MATLAB的噪声的叠加和滤除程序 MATLAB如何给图像加噪声进行中值滤波

2021-04-26知识11

求基于pcnn图像噪声滤除matlab仿真程序代码 function y=PCNN()主程序global alpha beta w h c threshold YX=double(imread('cameraman.tif'));[w,h]=size(X);figure,imshow(X/255)title('原始噪声图像')求取最小交叉熵H=zeros(1,256);计算灰度直方图for i=1:wfor j=1:ha=X(i,j);H(a+1)=H(a+1)+1/256;endendD=zeros(1,15);threshold0=255;for n0=1:15;threshold0=exp(-alpha)*threshold0;t=round(threshold0);h1=sum(H(1:t+1));h2=sum(H(t+2:256));f1=1:t;g1=sum(sum(f1.*H(2:t+1)));f2=t+1:255;g2=sum(sum(f2.*H(t+2:256)));u1=1/h1*g1;u2=1/h2*g2;D1=sum(sum(f1.*H(2:t+1).*log10(f1/u1)+u1*H(2:t+1).*log10(u1./f1)));背景交叉D2=sum(sum(f2.*H(t+2:256).*log10(f2/u2)+u2*H(t+2:256).*log10(u2./f2)));目标交叉D(n0)=(D1+D2)/255%整幅图像交叉endMIN_D=min(D)for n0=1:15;if D(n0)=MIN_D;n=n0;endend%交叉熵最小时所取最佳迭代次数下面为二值分割threshold=zeros(w,h);threshold(=255;Y=zeros(w+1,h+1);Weight=[0.707 1 0.707;1 0 1;0.707 1 0.707];while(n>;0)for i=2:wfor j=2:hF=X(i,j);V=[Y(i-1,j-1)Y(i-1,j)Y(i-1,j+1);Y(i,j-1)Y(i,j)Y(i,j+1);Y(i+1,j-1)Y(i+1,j)Y(i+1,j+1)];L=sum(sum(V。.

基于MATLAB的有噪声的语音信号分析与处理设计的源代码及详细分析 这是我刚做的,运行是正确的!ly是语音信号的名字,截图自己运行就会有!

编写用均值滤波去噪的matlab程序,用两种方法实现.(重谢) 方法一:filter2clear all;I=imread('lena.bmp');读入预处理图像imshow(I)显示预处理图像K1=filter2(fspecial('average',3),I)/255;进行3*3均值滤波K2=filter2(fspecial('average',5),I)/255;进行5*5均值滤波K3=filter2(fspecial('average',7),I)/255;进行7*7均值滤波figure,imshow(K1)figure,imshow(K2)figure,imshow(K3)方法二:双循环语句,移动平均法均值滤波clc,clear;f=imread('lena.bmp');subplot(121),imshow(f),title('原图');f1=imnoise(f,'gaussian',0.002,0.0008);subplot(222),imshow(f1),title('添加高斯噪声图');k1=floor(3/2)+1;k2=floor(3/2)+1;X=f1;[M,N]=size(X);uint8 Y=zeros(M,N);funBox=zeros(3,3);for i=1:M-3for j=1:N-3funBox=X(i:i+3,j:j+3);s=sum(funBox(:));h=s/9;Y(i+k1,j+k2)=h;end;end;Y=Y/255;subplot(122),imshow(Y),title('均值滤波');实现图:

#基于MATLAB的噪声的叠加和滤除程序

随机阅读

qrcode
访问手机版