图像处理课程设计报告_第1页
图像处理课程设计报告_第2页
图像处理课程设计报告_第3页
图像处理课程设计报告_第4页
图像处理课程设计报告_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、摘要:matlab和mathematica、maple并称为三大数学软件。它在数学类科技应用软件在数值计算方面首屈一指。matlab可以进行矩阵运算、绘制函数和数据、实现算法、创用户界面、连接其他编程语言的程序等,主要应用于工程计算、控制设计、信号处理与通讯、图像处理、信号检测、金融建模设计与分析等领域。数字图像处理(digitalimageprocessing)是通过计算机对图像进行去除噪声、增强、复原、分割、提取特征等处理的方法和技术。数字图像处理的产生和迅速发展主要受三个因素的影响:一是计算机的发展;二是数学的发展(特别是离散数学理论的创立和完善);三是广泛的农牧业、林业、环境、军事、工

2、业和医学等方面的应用需求的增长。关键词:matlab,数字图像处理一课程设计目的1、 提高分析问题、解决问题的能力,进一步巩固数字图像处理系统中的基本原理与方法。2、 熟悉掌握一门计算机语言,可以进行数字图像的应用处理的开发设计二. 课程设计的内容matlab gui程序设计,利用matlab图像处理工具箱。要求:按照软件工程方法,根据需求进行程序的功能分析和界面设计,给出设计详细说明。然后按照自己拟定的功能要求进行程序设计和调试。 以下几点是程序实现的功能。1)能对图像文件(bmp、 jpg、 tiff、 gif等)进行打开、保存、另存、打印、退出等功能操作。(2)能对图像进行直方图统计,包

3、括r直方图,直方图统计,直放图均衡,周长和面积计算,区域图面积统计。(3)能对图像进行图像变化处理,包括小波变换,傅里叶变换,快速傅里叶变化,快速逆变换,傅里叶逆变换,离散余弦变换。(4)能对图像进行滤波处理,包括低通滤波,平滑滤波,自适应滤波。(5)能对图像进行频域增强处理,包括同态滤波,高频锐化。(6)能对图像进行噪声添加处理,包括椒盐噪声,加性噪声,高斯噪声。(7)能对图像进行图像滤波器处理,包括高通滤波器,低通滤波器。三、总体方案设计通过matlab 的gui 设计界面,实现打开,保存,退出,打印功能,设计对比示区,功能按钮,实现各种图形处理的基本功能。四、各个功能模块的主要实现程序

4、在gui界面上创建一系列的按钮以实现各种功能。其实现语句如下:打开程序:function open_callback(hobject, eventdata, handles)% hobject handle to open (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)name,path=uigetfile('*.jpg''*.bmp'&#

5、39;*.gif''*.tif','ÔØÈëͼÏñ');if isequal(name,0)isequal(path,0) errordlg('ûÓÐÑ¡ÖÐÎļþ','³ö´í'); returnelse x=imread(path,name); axes(handles.axe

6、s1); imshow(x); handles.img=x; handles.noise_img=x; guidata(hobject,handles)end保存程序:function save_callback(hobject, eventdata, handles)% hobject handle to save (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)file

7、name,pathname = uiputfile('*.jpg''*.bmp''*.gif''*.tif','ͼƬ±£´æÎª');if isequal(filename,pathname,0,0) errordlg('ûÓб£´æ','³ö´í'); re

8、turn;elsefile=strcat(pathname,filename);(handles.axes1);i=getimage(gca);imwrite(i,file);打印程序:function dayin_callback(hobject, eventdata, handles)% hobject handle to dayin (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see g

9、uidata)printpreviewprintpreview(f)退出程序:function tuichu_callback(hobject, eventdata, handles)% hobject handle to tuichu (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)% hobject handle to quit (see gcbo)% eventdat

10、a reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)button = questdlg('ÄúÈ·¶¨ÒªÍ˳ö±¾³ÌÐòÂð£¿','È·¶

11、¨²Ù×÷');switch button case 'yes' close(gcf); case 'no' end;然后制作axes1并建立面板,修改颜色和名称,即界面中的function,再在面板上添加按钮1. r直方图按钮程序:function rzhifangtu_callback(hobject, eventdata, handles)% hobject handle to rzhifangtu (see gcbo)% eventdata reserved - to be defined in

12、a future version of matlab% handles structure with handles and user data (see guidata)set(handles.axes1,'handlevisibility','on');axes(handles.axes1);x=imhist(handles.img(:,:,1); %Ö±·½Í¼Í³¼Æx1=x(1:10:256);horz=1:10:256;bar(horz,x1);set

13、(handles.axes1,'xtick',0:50:255);2.直方图统计按钮:function zhifangtutongji_callback(hobject, eventdata, handles)% hobject handle to zhifangtutongji (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)set(handles.axe

14、s1,'handlevisibility','on');axes(handles.axes1);x=imhist(handles.img(:,:,1); %Ö±·½Í¼Í³¼Æx1=x(1:10:256);horz=1:10:256;bar(horz,x1);axes(handles.axes1);set(handles.axes1,'xtick',0:50:255);% hobject handle to tongji (see gcbo)% e

15、ventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata) % - executes on button press in zhifangtujunheng.3.直方图统计按钮程序:function zhifangtujunheng_callback(hobject, eventdata, handles)% hobject handle to zhifangtujunheng (see gcbo)% eve

16、ntdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)set(handles.axes1,'handlevisibility','on');axes(handles.axes1);if isrgb(handles.img) a=histeq(handles.img(:,:,1); b=histeq(handles.img(:,:,2); c=histeq(handles.img

17、(:,:,3); k(:,:,1)=a; k(:,:,2)=b; k(:,:,3)=c; axes(handles.axes1); imshow(k);elseh=histeq(handles.img);axes(handles.axes1);%Ö±·½Í¼¾ùºâimshow(h);end% hobject handle to junheng (see gcbo)% eventdata reserved - to be defined in a future version of matlab

18、% handles structure with handles and user data (see guidata) % - executes on button press in mianjijisuan.4.周长和面积计算程序:function mianjijisuan_callback(hobject, eventdata, handles)% hobject handle to mianjijisuan (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles stru

19、cture with handles and user data (see guidata)axes(handles.axes1);y=handles.img;k=rgb2gray(y);bw = im2bw(k); % ת»¯Îª¶þֵͼÏñ l,n = bwlabel(bw,4); % ±ê×¢¶þ½øÖÆÍ¼Ï

20、41;ÖÐÒÑÁ¬½ÓµÄ²¿·Öx=1;%ĬÈÏͼÏñÖÐÖ»ÓÐÒ»¸öÁ¬Í¬ÇøÓò.i j=find(l=x);%½«±ê×¢

21、µÄÇøÓò·Åµ½Ò»¸öÊý×éÖÐ.bwi=bwselect(l,i,j,4);p=bwperim(bwi);perm=sum(sum(p);%Öܳ¤.area=size(i);%Ãæ»ý.±ê×¢ÇøÓòÏñ&

22、#203;صãÊý¾ÍΪÎïÌåÃæ»ý.imshow(bw);pa='ͼÏñÃæ»ýΪ:' num2str(area) 'ÏñËØµã'pp='ͼÏñÖÜ&#

23、179;¤Îª:' num2str(perm) 'ÏñËØ'xxx=pa,pp;title(xxx);% hobject handle to zhouchanghemianji (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata% - executes on button press

24、in pushbutton8.5.区域图面积程序function quyumianji_callback(hobject, eventdata, handles)% hobject handle to quyumianji (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)axes(handles.axes1);y=handles.img;k=rgb2gray(y);x=ar

25、ea(k,-2); title('ÇøÓòÃæ»ýͼµÄ»æÖÆ');set(gca,'layer','top'); % hobject handle to quyutumianji (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with ha

26、ndles and user data (see guidata) % - executes on button press in kuaisufuliyebianhuan.6.小波变换程序:function xiaobo_callback(hobject, eventdata, handles)% hobject handle to xiaobo (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (

27、see guidata)axes(handles.axes1);x=(handles.img);if (isrgb(x)=0);y=rgb2gray(x); ca1,ch1,cv1,cd1 = dwt2(y,'bior3.7');a1=upcoef2('a',ca1,'bior3.7',1);image(wcodemat(a1,192); title('½üËÆÖµÏµÊýa1');else ca1,ch1,cv1,cd1 = dw

28、t2(x,'bior3.7');a1=upcoef2('a',ca1,'bior3.7',1);image(wcodemat(a1,192);end% hobject handle to xiaobobianhuan (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata) % - executes on button press i

29、n ditonglvbo.7.傅里叶变换程序:function fuliyebianhuan_callback(hobject, eventdata, handles)% hobject handle to fuliyebianhuan (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)axes(handles.axes1);x=(handles.img);if isrgb(

30、x); i=fft(x);else i=fft(x);endo=fftshift(i);imshow(o);title('ÆÕͨft±ä»»ºóµÄͼÏñ');% hobject handle to ft (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handle

31、s and user data (see guidata)8.快速傅里叶程序:function kuaisufuliyebianhuan_callback(hobject, eventdata, handles)% hobject handle to kuaisufuliyebianhuan (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)axes(handles.axes

32、1);x=(handles.img);if isrgb(x) i=fftn(x);else i=fft2(x);end o=fftshift(i);imshow(o);title('fft±ä»»ºóµÄͼÏñ'); % hobject handle to fft (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure wi

33、th handles and user data (see guidata) % - executes on button press in nibianhuan.9.快速逆变换程序;function nibianhuan_callback(hobject, eventdata, handles)% hobject handle to nibianhuan (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user da

34、ta (see guidata)axes(handles.axes1);x=(handles.img);if isrgb(x) i=ifftn(x);o=fftshift(i);imshow(o);title('ifft±ä»»ºóµÄͼÏñ');else i=ifft2(x); o=fftshift(i);imshow(o);title('ifft±ä»»ºóµÄ

35、05;¼Ïñ');end% hobject handle to ifft (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)10.傅里叶逆变换程序:function fuliyenibianhuan_callback(hobject, eventdata, handles)% hobject handle to fuliyenibianh

36、uan (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)axes(handles.axes1);x=(handles.img);if isrgb(x) i=ifft(x);else i=fft(x);endo=ifftshift(i);imshow(o);title('ÆÕͨift±ä»

37、7;ºóµÄͼÏñ'); % hobject handle to ift (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)11.离散余弦变化程序:function yuxuanbianhua_callback(hobject, eventdata, handles)% hobject

38、handle to yuxuanbianhua (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)axes(handles.axes1);x=(handles.img);if (isrgb(x)=0); y=rgb2gray(x);i=dct(y);imshow(i);title('dct±ä»»ºó

39、1;ÄͼÏñ');else i=dct(x);imshow(i);title('dct±ä»»ºóµÄͼÏñ');end % hobject handle to dct (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and use

40、r data (see guidata)12.低通滤波程序:function ditonglvbo_callback(hobject, eventdata, handles)% hobject handle to ditonglvbo (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)axes(handles.axes1);if isrgb(handles.img)x=(ha

41、ndles.img);y=rgb2gray(x);h=imnoise(y,'salt & pepper',0.04); %¼Ó½·ÑÎÔëÉù z=medfilt2(h,5 5,'symmetric'); %ÖÐÖµÂ˲¨ imshow(z);else msgbox('ÕâÒѾ­ÊÇ&#

42、187;Ò¶ÈͼÏñ','ת»»Ê§°Ü');end % hobject handle to ditonglubo (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)12.平滑滤波程序:functio

43、n pinhualvbo_callback(hobject, eventdata, handles)% hobject handle to pinhualvbo (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)axes(handles.axes1);axes(handles.axes1);img=(handles.img);if isrgb(img) f=rgb2gray(

44、img);f=double(f);f=fft2(f);f=fftshift(f);m,n=size(f); %d0=80;m1=fix(m/2);n1=fix(n/2);for i=1:m for j=1:n d=sqrt(i-m1)2+(j-n1)2); h(i,j)=exp(-d2/2/d02); endendg=f.*h;g=ifftshift(g);g=ifft2(g);g=mat2gray(real(g); imshow(g);else msgbox('ÕâÒѾ­ÊÇ»Ò&#

45、182;ÈͼÏñ','ת»»Ê§°Ü');end % hobject handle to pinghualubo (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata) % - executes on button pres

46、s in zishiyin.13自适应滤波程序:function zishiyin_callback(hobject, eventdata, handles)% hobject handle to zishiyin (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)axes(handles.axes1);if isrgb(handles.img)x=(handles.img)

47、;y=rgb2gray(x);h=imnoise(y,'gaussian',0,0.05); %¼Ó¸ß˹ÔëÉùz=wiener2(h,5 5);%×ÔÊÊÓ¦Â˲¨axes(handles.axes1);imshow(z);else msgbox('ÕâÒѾ­ÊÇ»Ò

48、;¶ÈͼÏñ','ת»»Ê§°Ü');end % hobject handle to zishiyinglubo (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata) % - executes on button

49、 press in tongtai.14.同态滤波程序:function tongtai_callback(hobject, eventdata, handles)% hobject handle to tongtai (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)axes(handles.axes1);y=(handles.img);i=rgb2gray(y);i=im

50、2uint8(i);m n=size(i); i=double(i); lni = log(1+i); ; fi = fft2(lni); p =fftshift(fi); for i=1:m for j=1:n d(i,j)=(i-m/2)2+(j-n/2)2); end end prompt='Èñ»¯²ÎÊý:','½ØÖ¹ÆµÂÊ' defans='0','0' p

51、=inputdlg(prompt,'Èñ»¯²ÎÊý:',1,defans); c=str2num(p1); do=str2num(p2); h=(2.0-0.5)*(1-exp(c*(-d/(do2)+0.5; hi=fi.*h; gi=ifft2(hi); y=exp(gi); g=real(y);s=uint8(g);imshow(s); % hobject handle to tongtaizq (see gcbo)% eventdata reserved - to be defined i

52、n a future version of matlab% handles structure with handles and user data (see guidata) % - executes on button press in gaopin.15.高频锐化程序:function gaopin_callback(hobject, eventdata, handles)% hobject handle to gaopin (see gcbo)% eventdata reserved - to be defined in a future version of matlab% hand

53、les structure with handles and user data (see guidata)axes(handles.axes1);if isrgb(handles.img)x=(handles.img);y=rgb2gray(x);h=0 -1 0;-1 4 -1;0 -1 0 ;i=imfilter(y,h);imshow(i);title('ƵÓòÈñ»¯ºóµÄͼÏñ');end% hobje

54、ct handle to gaopingruihua (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata) % - executes on button press in jiaoyanzaosheng.16.椒盐噪声程序:function jiaoyanzaosheng_callback(hobject, eventdata, handles)% hobject handle

55、 to jiaoyanzaosheng (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)prompt='ÊäÈë²ÎÊý:'%¶Ô»°¿òµÄÉèÖã

56、;¬Óû§ÊäÈëµÄÊÇ×Ö·û´®defans='0.02' %ȱʡֵp=inputdlg(prompt,'ÊäÈë²ÎÊý£º',1,defans); p1=str2num(p1); %×

57、14;·û´®×ª»¯ÎªÊýÖµaxes(handles.axes1);x=(handles.img);y=imnoise(x,'salt & pepper',p1); handles.noise_img=y;guidata(hobject,handles);imshow(y);% hobject handle to jiaoyanzaosheng (see gcbo)% eventdata reserved - to be de

58、fined in a future version of matlab% handles structure with handles and user data (see guidata) % - executes on button press in jiaxin.16.加性噪声程序:function jiaxin_callback(hobject, eventdata, handles)% hobject handle to jiaxin (see gcbo)% eventdata reserved - to be defined in a future version of matla

59、b% handles structure with handles and user data (see guidata)axes(handles.axes1);prompt='ÊäÈë²ÎÊý:'defans='0.02'p=inputdlg(prompt,'ÊäÈë²ÎÊý£º',1,defans);p1=str2num(p1);y=imnoise(handles.

60、img,'speckle',p1); handles.noise_img=y;guidata(hobject,handles);imshow(y);% hobject handle to jiaxingzaosheng (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata) % - executes on button press in gaosizaosheng

61、. % - executes on button press in gaotonglvboqi.117.高斯噪声程序:function gaotonglvboqi_callback(hobject, eventdata, handles)% hobject handle to gaotonglvboqi (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)% hobject h

62、andle to gaosigaotonglb (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)%¸ßͨÂ˲¨Æ÷axes(handles.axes1);x=(handles.img);if isrgb(x) msgbox('ÕâÊ&

63、#199;²ÊɫͼÏñ,²»ÄÜͨ¹ý¸ßͨÂ˲¨Æ÷','ʧ°Ü');elsey1=imnoise(x,'gaussian'); %¼Ó¸ß˹ÔëÉ

64、49;f=double(y1); % Êý¾ÝÀàÐÍת»»k=fft2(f); % ¸µÁ¢Ò¶±ä»»g=fftshift(k); % ת»»Êý¾Ý¾ØÕóm,n=size(g);nn=2;d0=3; %½ØÖ¹

65、;ƵÂÊΪ3m=fix(m/2); n=fix(n/2);for i=1:m for j=1:n d=sqrt(i-m)2+(j-n)2); % ¼ÆËã¸ßͨÂ˲¨Æ÷´«µÝº¯Êý if d<=d0 h=0; else h=1; end result(i,j)=h*g(i,j); endendres

66、ult=ifftshift(result);y2=ifft2(result);y3=uint8(real(y2);imshow(y3); end % - executes on button press in batewosi.18.高通滤波器程序:function gaotonglvboqi_callback(hobject, eventdata, handles)% hobject handle to gaotonglvboqi (see gcbo)% eventdata reserved - to be defined in a future version of matlab% han

67、dles structure with handles and user data (see guidata)% hobject handle to gaosigaotonglb (see gcbo)% eventdata reserved - to be defined in a future version of matlab% handles structure with handles and user data (see guidata)%¸ßͨÂ˲¨Æ÷axes(handles.

68、axes1);x=(handles.img);if isrgb(x) msgbox('ÕâÊDzÊɫͼÏñ,²»ÄÜͨ¹ý¸ßͨÂ˲¨Æ÷','ʧ°Ü');elsey1=imnoise(x,'gaussian

69、'); %¼Ó¸ß˹ÔëÉùf=double(y1); % Êý¾ÝÀàÐÍת»»k=fft2(f); % ¸µÁ¢Ò¶±ä»»g=fftshift(k); % ת»»Êý¾Ý¾

70、;ØÕóm,n=size(g);nn=2;d0=3; %½ØÖ¹ÆµÂÊΪ3m=fix(m/2); n=fix(n/2);for i=1:m for j=1:n d=sqrt(i-m)2+(j-n)2); % ¼ÆËã¸ßͨÂ˲¨Æ÷´«µÝº¯Êý if d<=d0 h=0; else h=1; end result(i,j)=h*g(i,j); endendresult=ifftshift(result);y2=ifft2(result);y3=uint8(real(y2);imshow(y3); end % - executes on button pr

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论