数字图像处理报告
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
信息科学与技术学部数字图像处理实验报告
学号:0901********
专业:电子信息工程
班级:二班
姓名:
指导老师:
例4.4 程序如下:
I=imread('tu1.jpg');
imshow(I);
I=double(I);
[M,N]=size(I);
for k=1:8
j=zeros(M,N);
for i=1:M
for j=1:N
temp=I(i,j);
s1=0;s2=0;
range=[k:-1:1];
for d=range
s1=2^(8-d)+s1;
s2=2^(8-d+1);
if temp>=s1&temp J(i,j)=255;break; end end end end J=uint8(J); figure;imshow(J); end 原图: 运行程序得: 例4.14:程序如下: I=imread('tu2.jpg'); J=imnoise(I,'salt & pepper',0.02); subplot(121);imshow(J); title('含有噪椒盐声的图像') J=double(J); f=fft2(J); g=fftshift(f) [M,N]=size(f); n=3; d0=20 n1=floor(M/2) n2=floor(N/2) for i=1:M for j=1:N d=sqrt((i-n1)^2+(j-n2)^2) h=1/(1+(d/d0)^(2*n)); g(i,j)=h*g(i,j); end end g=ifftshift(g); g=uint8(real(ifft2(g))); subplot(122); imshow(g); 运行程序得: :例4.16 程序如下: J=imread('tu3.jpg'); subplot(121);imshow(J); J=double(J); f=fft2(J); g=fftshift(f); [M,N]=size(f); d0=10; r1=0.9; rh=2 c=4; n1=floor(M/2); n2=floor(N/2); for i=1:M for j=1:N d=sqrt((i-n1)^2+(j-n2)^2); h=(rh-r1)*(1-exp(-c*(d.^2/d0.^2)))+r1; g(i,j)=h*g(i,j); end end g=ifftshift(g); g=uint8(real(ifft2(g))); subplot(122);imshow(g); 运行程序得: 例5.3 程序如下: F=checkerboard(8); figure(1); imshow(F,[]); PSF=fspecial('motion',7,45); MF=imfilter(F,PSF,'circular'); noise=imnoise(zeros(size(F)),'gaussian',0,0.001); MFN=MF + noise; figure(2); imshow(MFN,[]); NSR=sum(noise(:).^2)/sum(MFN(:).^2); figure(3); imshow(deconvwnr(MFN,PSF),[]); figure(4); imshow(deconvwnr(MFN,PSF,NSR),[]); 运行程序得: f=imread('tu5.jpg'); figure(1);imshow(f); title('原始图像'); g=imnoise(f,'salt & pepper',0.2); figure(2);imshow(g); title('椒盐噪声污染的图像'); g1=double(g)/255; j1=medfilt2(rgb2gray(g1),'symmetric'); figure(3);imshow(j1); title('中值滤波图像'); j2=ordfilt2(rgb2gray(g1),median(1:3*3),ones(3,3),'symmetric'); figure(4);imshow(j2); title('中点滤波图像'); j3=ordfilt2(rgb2gray(g1),1,ones(3,3)); figure(5);imshow(j3); title('最小值滤波图像'); j4=ordfilt2(rgb2gray(g1),9,ones(3,3)); figure(6);imshow(j4); title('最大值滤波图像'); 运行程序得: I=imread('tu6.jpg'); I=double(I); [M,N]=size(I); L=256; for i=1:M for j=1:N if I(i,j) R(i,j)=0; G(i,j)=4*I(i,j); B(i,j)=L; else if I(i,j)<=L/2 R(i,j)=0; G(i,j)=L; B(i,j)=-4*I(i,j)+2*L; else if I(i,j)<=3*L/4 R(i,j)=4*I(i,j)-2*L; G(i,j)=L; B(i,j)=0; else R(i,j)=L; G(i,j)=-4*I(i,j)+4*L; B(i,j)=0; end end end end end for i=1:M for j=1:N G2C(i,j,1)=R(i,j); G2C(i,j,2)=G(i,j); G2C(i,j,3)=B(i,j); end end G2C=G2C/256; figure; imshow(G2C);