数字图像处理实验报告

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

数字图像处理实验报告实验一:一.实验目的1.了解图像代数运算、逻辑运算及滤波的意义和手段;2.熟练掌握代数运算、逻辑运算和滤波的方法及应用;3.通过本实验掌握利用MATALB编程实现数字图像处理的代数运算、逻辑运算和滤波。二.实验结果及程序1.图像的代数运算和逻辑运算加法clear;clc;%¼Ó·¨Æ½¾ùÈ¥Ôë·¨I=imread('C:\Users\Administrator\Desktop\lena.jpeg');B=rgb2gray(I);J=imnoise(B,'gaussian',0,0.02);subplot(1,2,1),imshow(B);title('ԭͼ');subplot(1,2,2),imshow(J);title('¼Ó¸ß˹ÔëÉù');K=zeros(220,220);fori=1:100C=imnoise(B,'gaussian',0,0.02);C1=im2double(C);K=K+C1;endK=K/100;figure;imshow(K);title('È¥ÔëͼƬ');结果:减法clear;clc;%¼õ·¨»¹Ô­I=imread('C:\Users\Administrator\Desktop\lena.jpeg');B=rgb2gray(I);J=imnoise(B,'gaussian',0,0.02);subplot(1,3,1),imshow(B);title('ԭͼ');subplot(1,3,2),imshow(J);title('¼Ó¸ß˹ÔëÉù');K=imsubtract(J,B);K1=255-K;subplot(1,3,3);imshow(K1);%ÌáÈ¡µÄÔëÉùtitle('ÔëÉùͼƬ');乘法clear;clc;%³Ë·¨I=imread('C:\Users\Administrator\Desktop\lena.jpeg');B=rgb2gray(I);C=immultiply(B,1.3);D=immultiply(B,2);subplot(1,3,1),imshow(B);title('ԭͼ');subplot(1,3,2),imshow(C);title('1,2±¶');subplot(1,3,3),imshow(D);title('2±¶');除法clear;clc;%¼õ·¨»¹Ô­I=imread('C:\Users\Administrator\Desktop\lena.jpeg');B=rgb2gray(I);C=double(B);D=C*0.43+90;B1=uint8(D);D=imdivide(B,B1);subplot(1,2,1),imshow(B);title('ԭͼ');subplot(1,2,2),imshow(D,[]);title('³ý·¨Í¼Æ¬');二值运算clear;clc;%¼õ·¨»¹Ô­I=imread('C:\Users\Administrator\Desktop\lena.jpeg');B=rgb2gray(I);A=zeros(128);A(40:67,60:100)=1;subplot(2,3,1);imshow(A);title('Aͼ');B=zeros(128);B(50:80,40:70)=1;subplot(2,3,2);imshow(B);title('Bͼ');C=and(A,B);subplot(2,3,3);imshow(C);title('Óëͼ');D=or(A,B);subplot(2,3,4);imshow(D);title('»òͼ');E=not(A);subplot(2,3,5);imshow(E);title('·Çͼ');2.1图像空域滤波clear;clc;%Â˲¨I=imread('C:\Users\Administrator\Desktop\lena.jpeg');figure;subplot(2,2,1);A1=imshow(I);title('ԭͼ');B=rgb2gray(I);C=imnoise(B,'salt&pepper',0.02);D=imfilter(B,fspecial('average',3));E=medfilt2(B);subplot(2,2,3)imshow(D);title('¾ùÖµÂ˲¨');subplot(2,2,4);imshow(D)title('ÖÐÖµÂ˲¨');subplot(2,2,2)imshow(C)title('¼ÓÈë½·ÑÎÔëÉùͼÏñ')程序结果:2.2图像频域滤波%Èñ»¯´¦ÀíI=imread('C:\Users\Administrator\Desktop\lena.jpeg');figure;subplot(2,3,1);A=imshow(I);title('ԭͼ');B=rgb2gray(I);hs=fspecial('sobel');S=imfilter(B,hs);hp=fspecial('prewitt');P=imfilter(B,hs);B=double(B);%Ë«¾«¶ÈÐÍH=[0,1,0;1,-4,1;0,1,0];J=conv2(B,H,'same');K=B-J;subplot(2,3,2)imshow(K);title('laplaceÈñ»¯Í¼Ïñ');C=edge(B,'roberts',0.1);subplot(2,3,3)imshow(C);title('robertÈñ»¯Í¼Ïñ');subplot(2,3,4)imshow(S);title('sobelËã×ÓÈñ»¯Í¼Ïñ');subplot(2,3,5)imshow(P);title('prewittËã×ÓÈñ»¯Í¼Ïñ');结果:实验二:一.实验目的1.了解图像读入、图像变换、信息隐藏的意义和手段;2.熟悉傅里叶的基本性质;3.通过本实验了解离散傅里叶变换的特点4.掌握利用MATALB编程实现数字图像处理的操作。二.实验结果及程序1.读入一幅彩色图像,显示各层图像程序:clear;clc;A=imread('C:\Users\Administrator\Desktop\ai.jpg');A1=A(:,:,1);A2=A(:,:,2);A3=A(:,:,3);figure(1);subplot(2,2,1);B1=imshow(A);title('ԭͼ');subplot(2,2,2);B2=imshow(A1);title('µÚÒ»²ã');subplot(2,2,3);B3=imshow(A2);title('µÚ¶þ²ã');subplot(2,2,4);B4=imshow(A3);title('µÚÈý²ã');结果:2.图像的离散傅里叶变换程序:clear;clc;I=imread('C:\Users\Administrator\Desktop\lena.jpeg');subplot(2,3,1);imshow(real(I));title('ԭͼ');I=I(:,:,3);fftI=fft2(I);sfftI=fftshift(fftI);RRfdp1=real(sfftI);IIfdp1=imag(sfftI);a=sqrt(RRfdp1.^2+IIfdp1.^2);a=(a-min(min(a)))/(max(max(a))-min(min(a)))*225;subplot(2,3,2);imshow(real(a));title('ԭͼ');b=angle(fftI);subplot(2,3,3);imshow(real(b));title('ԭͼ');theta=30;RR1=a*cos(theta);II1=a*sin(theta);fftI1=RR1+i.*II1;C=ifft2(fftI1)*225;subplot(2,3,4);imshow(real(C));title('ԭͼ');MM=150;RR2=MM*cos(angle(fftI));II2=MM*sin(angle(fftI));fftI2=RR2+i.*II2;D=ifft2(fftI2);subplot(2,3,5);imshow(real(D));title('ԭͼ');结果:3.图像的信息隐藏程序:clearall;clccloseall%=========================%readimage%=========================mat=imread('C:\Users\Administrator\Desktop\lena.jpeg');mbt=imread('C:\Users\Administrator\Desktop\2.bmp');imgread=rgb2gray(mat);mbt=uint8(mbt);[maa,mab]=size(imgread);%[mba,mbb]=size(mbt);md=ones(maa,mab);ma=zeros(2*maa,2*mab);ma=im2uint8(ma);%========================%progresstheimage%========================fori=1:1:maaforj=1:1:mabimgread(i,j)=imgread(i,j)-mod(imgread(i,j),4);endend%========================%enlargeimage%=======================forj=1:1:mabfori=1:1:maama(2*i-1,2*j-1)=imgread(i,j);ma(2*i,2*j-1)=imgread(i,j);ma(2*i-1,2*j)=imgread(i,j);ma(2*i,2*j)=imgread(i,j);mb(2*i-1,2*j-1)=mbt(i,j);mb(2*i,2*j-1)=mbt(i,j);mb(2*i-1,2*j)=mbt(i,j);mb(2*i,2*j)=mbt(i,j);endendma=ma+mb*3;%=======================%attack%=======================noise=normrnd(0,0.2,2*maa,2*mab);%Gaussian,uniform,%laplace,salt-pepperma=double(ma);ma=ma+noise;ma=uint8(ma);figure(1);subplot(2,2,1);imshow(imgread);title('ԭʼͼƬ');subplot(2,2,2);imshow(mbt,[0,1]);title('ˮӡͼƬ');subplot(2,2,3);imshow(ma);title('Òþ²ØºóͼƬ');%subplot(2,2,1);imshow(mb,[0,1]);subplot(2,2,2);imshow(ma);subplot(2,2,3);imshow(mc);%=======================%watermarkextraction%=======================fori=1:1:maaforj=1:1:maba=mod(ma(2*i-1,2*j-1),2)+mod(ma(2*i,2*j-1),2)+mod(ma(2*i-1,2*j),2)+mod(ma(2*i,2*j),2);a=(-a+mod(ma(2*i-1,2*j-1),4)+mod(ma(2*i,2*j-1),4)+mod(ma(2*i-1,2*j),4)+mod(ma(2*i,2*j),4))/2;ifa4md(i,j)=0;endende

1 / 11
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功