MATLAB(GUI)数字图像处理实验报告资料_第1页
MATLAB(GUI)数字图像处理实验报告资料_第2页
MATLAB(GUI)数字图像处理实验报告资料_第3页
MATLAB(GUI)数字图像处理实验报告资料_第4页
MATLAB(GUI)数字图像处理实验报告资料_第5页
已阅读5页,还剩31页未读 继续免费阅读

下载本文档

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

文档简介

1、20122013学年第二学期课程名称:教学实践:软硬件提高训练任课教师: 题 目:MATLAB数字图像处理学号:ROB12023姓名: 年级:2012级专业:自动化评语:成绩: 评卷人:提交日期: 年 月 日1.设计目的利用MATLAB的GUI程序设计一个简单实用的图像处理程序。该程序应具备图像处理的常用功能,以满足要求。2.设计要求设计程序有以下基本功能:1)图像的读取、保存和程序退出2)图像转化为灰度图像3)底片处理(反色)4)截图5)亮度和对比度度调节6)图像的翻转与旋转7)添加噪声8)平滑和锐化9)直方图均衡化处理10)图像的腐蚀和膨胀11)边缘检测12)还原和撤销3.总体设计4.程序

2、与运行结果4.1图像的读取、保存和程序退出1图像读取1)主要程序A=imread(str) %读取图片imshow(A) %显示图片2)运行结果 2图像保存1)主要程序imwrite(handles.img,sfilefullname); %图像的保存2)运行结果3退出1)主要程序close all; %关闭所有 2)运行结果(略)4.2图像转化为灰度图像1)主要程序C=rgb2gray(img); %将rgb彩色图像转换为灰度图2)运行结果4.3底片处理(反色)1)主要程序I=imcomplement(handles.img); %底片处理(反色)2)运行结果4.4截图1)主要程序a=imc

3、rop(handles.img); %图像的截取2)运行结果4.5亮度和对比度度调节1亮度调节1)主要程序y=imadjust(handles.img, , ,p1); %亮度调节2)运行结果2对比度调节1)主要程序f=immultiply(handles.img,p1); %对比度增强f=imdivide(handles.img,p1); %对比度减弱2)运行结果4.6图像的翻转与旋转1图像的翻转1)主要程序fliplr(b) %图像的翻转2)运行结果2图像的旋转1)主要程序f=imrotate(handles.img,p1,'bilinear','crop'

4、); %图像的旋转2)运行结果 4.7添加噪声1椒盐噪声1)主要程序f=imnoise(handles.img,'salt & pepper',p1); %添加椒盐噪声2)运行结果2高斯噪声1)主要程序f=imnoise(handles.img,'gaussian',p1,p2); %添加高斯噪声2)运行结果3乘法噪声1)主要程序f=imnoise(handles.img,'speckle',p1); %添加乘法噪声2)运行结果4.8平滑和锐化1平滑1)主要程序Imfilter % 均值滤波medfilt2 % 中值滤波2)运行结果2锐化

5、1)主要程序fspecial( ) %创建预定义的滤波算子imfilter( );imadd( ); %在实现卷积运算的基础上进行滤波2)运行结果4.9直方图均衡化处理1灰度图像1)主要程序B=histeq(C); %直方图均衡化函数2)运行结果2RGB图像1)主要程序B=histeq(C); %直方图均衡化函数2)运行结果4.10 图像的腐蚀和膨胀1图像的腐蚀1)主要程序I1=imerode(handles.img,se); %图像的腐蚀2)运行结果2图像的膨胀1)主要程序I1=imdilate(handles.img,se); %图像的膨胀2)运行结果4.11 边缘检测 1)主要程序rsl

6、t=ycbcr2rgb(uint8(img2); %边缘检测2)运行结果4.12 还原和撤销1还原1)主要程序global S %设计一个全局变量S,保存初始图像路径,以便之后的还原操作 2)运行结果2撤销(只能撤销一次)1)主要程序global T %设计一个全局变量S,保存每次操作原图像,以便撤销操作 2)运行结果5心得体会通过用()设计数字图像处理界面,我掌握了有关数字图像处理的相关知识和的操作知识,让理论知识与实际相结合,做出了数字图像处理的图形用户界面。在实践前,通过一天的数字图像处理的相关知识与一天的知识的学习,掌握了其基本入门知识;然后在实践中,结合要设计要求补充自学相关知识,在

7、实践中验证理论知识,充实理论知识,加强动手能力;在实践后,总结实践过程,撰写实验报告,再次加深所学知识。6.附录代码(带注释)function varargout = dazouyematlab(varargin)%DAZOUYEMATLAB M-file for dazouyematlab.fig% DAZOUYEMATLAB, by itself, creates a new DAZOUYEMATLAB or raises the existing% singleton*.% H = DAZOUYEMATLAB returns the handle to a new DAZOUYEMATL

8、AB or the handle to% the existing singleton*.% DAZOUYEMATLAB('Property','Value',.) creates a new DAZOUYEMATLAB using the% given property value pairs. Unrecognized properties are passed via% varargin to dazouyematlab_OpeningFcn. This calling syntax produces a% warning when there is an

9、 existing singleton*.% DAZOUYEMATLAB('CALLBACK') and DAZOUYEMATLAB('CALLBACK',hObject,.) call the% local function named CALLBACK in DAZOUYEMATLAB.M with the given input% arguments.% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singlet

10、on)".% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help dazouyematlab% Last Modified by GUIDE v2.5 18-Jul-2014 11:52:53% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, . 'gui_Singleton',

11、gui_Singleton, . 'gui_OpeningFcn', dazouyematlab_OpeningFcn, . 'gui_OutputFcn', dazouyematlab_OutputFcn, . 'gui_LayoutFcn', , . 'gui_Callback', );if nargin && ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);endif nargout varargout1:nargout = gui

12、_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes just before dazouyematlab is made visible.function dazouyematlab_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject h

13、andle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin unrecognized PropertyName/PropertyValue pairs from the% command line (see VARARGIN)% Choose default command line output for dazouyematlabhandles.out

14、put = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes dazouyematlab wait for user response (see UIRESUME)% uiwait(handles.figure1);% - Outputs from this function are returned to the command line.function varargout = dazouyematlab_OutputFcn(hObject, eventdata, handles)% var

15、argout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout1 = handles.output;% -

16、Executes on button press in pushbutton14.function pushbutton14_Callback(hObject, eventdata, handles)%退出% hObject handle to pushbutton14 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)clc;close all;close(gcf);cle

17、ar;% - Executes on button press in pushbutton15.function pushbutton15_Callback(hObject, eventdata, handles)%图像载入% hObject handle to pushbutton15 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)filename,pathname=u

18、igetfile('*.jpg''*.bmp''*.tif','选择图片'); str=pathname filename;global S %设计一个全局变量S,保存初始图像路径,以便之后的还原操作S=str;A=imread(str);set(handles.axes1,'HandleVisibility','ON');axes(handles.axes1);imshow(A);set(handles.axes1,'HandleVisibility','OFF')

19、;axes(handles.axes2); imshow(A);cla(handles.axes2);handles.img=A;guidata(hObject,handles);% - Executes on button press in pushbutton16.function pushbutton16_Callback(hObject, eventdata, handles)%图像保存% hObject handle to pushbutton16 (see GCBO)% eventdata reserved - to be defined in a future version o

20、f MATLAB% handles structure with handles and user data (see GUIDATA)sfilename,sfilepath=uiputfile('*.jpg''*.bmp''*.tif''*.*','保存图像文件','untitled.jpg');if isequal(sfilename,sfilepath,0,0) sfilefullname=sfilepath,sfilename; imwrite(handles.img,sfilefullna

21、me);else msgbox('取消保存','保存失败');end% - Executes on button press in pushbutton22.function pushbutton22_Callback(hObject, eventdata, handles)%腐蚀% hObject handle to pushbutton22 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles a

22、nd user data (see GUIDATA)temp='腐蚀圆盘半径:'defans='0'p=inputdlg(temp,'请输入',1,defans);p1=str2num(p1);se=strel('disk',p1,0);global Taxes(handles.axes2);T=handles.img;I1=imerode(handles.img,se);imshow(I1); handles.img=I1;guidata(hObject,handles);% - Executes on button press

23、 in pushbutton23.function pushbutton23_Callback(hObject, eventdata, handles)%膨胀% hObject handle to pushbutton23 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)temp='膨胀结构长度:'defans='0'p=inputdlg(t

24、emp,'请输入',1,defans);p1=str2num(p1);se=strel('line',p1,0);I1=imdilate(handles.img,se);global Taxes(handles.axes2);T=handles.img;imshow(I1);handles.img=I1;guidata(hObject,handles);% - Executes on button press in pushbutton21.function pushbutton21_Callback(hObject, eventdata, handles)%R

25、GB图象% hObject handle to pushbutton21 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global Taxes(handles.axes2);T=handles.img;RGB=handles.img;R=RGB(:,:,1);G=RGB(:,:,2);B=RGB(:,:,3);G1(:,:,1)=histeq(R);G1(:,:,2)=

26、histeq(G);G1(:,:,3)=histeq(B);imshow(G1);handles.img=G1;guidata(hObject,handles);% - Executes on button press in pushbutton19.function pushbutton19_Callback(hObject, eventdata, handles)%添加噪声% hObject handle to pushbutton19 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB%

27、 handles structure with handles and user data (see GUIDATA)I=handles.img;global Tstr=get(handles.popupmenu7,'value');axes(handles.axes2);switch str case 1 T=handles.img; prompt='输入椒盐噪声参数1:' defans='0.02' p=inputdlg(prompt,'input',1,defans); p1=str2num(p1); f=imnoise(h

28、andles.img,'salt & pepper',p1); imshow(f); handles.img=f; guidata(hObject,handles); case 2 T=handles.img; prompt='输入高斯噪声1:','输入高斯噪声2' defans='0','0.02' p=inputdlg(prompt,'input',1,defans); p1=str2num(p1); p2=str2num(p2); f=imnoise(handles.img,'

29、gaussian',p1,p2); imshow(f); handles.img=f; guidata(hObject,handles); case 3 T=handles.img; prompt='输入乘性噪声1:' defans='0.02' p=inputdlg(prompt,'input',1,defans); p1=str2num(p1); f=imnoise(handles.img,'speckle',p1); imshow(f); handles.img=f; guidata(hObject,handles)

30、; end% - Executes on selection change in popupmenu7.function popupmenu7_Callback(hObject, eventdata, handles)% hObject handle to popupmenu7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = cell

31、str(get(hObject,'String') returns popupmenu7 contents as cell array% contentsget(hObject,'Value') returns selected item from popupmenu7% - Executes during object creation, after setting all properties.function popupmenu7_CreateFcn(hObject, eventdata, handles)% hObject handle to popup

32、menu7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: popupmenu controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'Backgroun

33、dColor'), get(0,'defaultUicontrolBackgroundColor') set(hObject,'BackgroundColor','white');end% - Executes on button press in pushbutton17.function pushbutton17_Callback(hObject, eventdata, handles)%平滑% hObject handle to pushbutton17 (see GCBO)% eventdata reserved - to be

34、defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global Tstr=get(handles.popupmenu5,'value');axes(handles.axes2);switch str case 1 T=handles.img; prompt='请输入模版维度:' defans='3' p=inputdlg(prompt,'input',1,defans); p1=str2n

35、um(p1); h1=fspecial('average',p1 p1); I=imfilter(handles.img,h1); imshow(I); handles.img=I; guidata(hObject,handles); case 2 T=handles.img; prompt='请输入模版维度:' defans='3' p=inputdlg(prompt,'input',1,defans); p1=str2num(p1); if numel(size(handles.img)>2 A=handles.img;

36、 R=A(:,:,1); G=A(:,:,2); B=A(:,:,3); GP(:,:,1)=medfilt2(R,p1 p1); GP(:,:,2)=medfilt2(G,p1 p1); GP(:,:,3)=medfilt2(B,p1 p1); imshow(GP); handles.img=GP; else A=handles.img; I=medfilt2(A,p1 p1); imshow(I); handles.img=I; end guidata(hObject,handles); end% - Executes on button press in pushbutton20.fun

37、ction pushbutton20_Callback(hObject, eventdata, handles)% hObject handle to pushbutton20 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)clc;close all;close(gcf);clear;% - Executes on button press in pushbutton16

38、.function pushbutton16_Callback(hObject, eventdata, handles)% hObject handle to pushbutton16 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global Tstr=get(handles.popupmenu5,'value');axes(handles.axes2)

39、;switch str case 1 T=handles.img; prompt='请输入模版维度:' defans='3' p=inputdlg(prompt,'input',1,defans); p1=str2num(p1); h1=fspecial('average',p1 p1); I=imfilter(handles.img,h1); imshow(I); handles.img=I; guidata(hObject,handles); case 2 T=handles.img; prompt='请输入模版维度:

40、' defans='3' p=inputdlg(prompt,'input',1,defans); p1=str2num(p1); if numel(size(handles.img)>2 A=handles.img; R=A(:,:,1); G=A(:,:,2); B=A(:,:,3); GP(:,:,1)=medfilt2(R,p1 p1); GP(:,:,2)=medfilt2(G,p1 p1); GP(:,:,3)=medfilt2(B,p1 p1); imshow(GP); handles.img=GP; else A=handles.i

41、mg; I=medfilt2(A,p1 p1); imshow(I); handles.img=I; end guidata(hObject,handles); end% - Executes on button press in pushbutton18.function pushbutton18_Callback(hObject, eventdata, handles)%锐化% hObject handle to pushbutton18 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB

42、% handles structure with handles and user data (see GUIDATA)global Tstr=get(handles.popupmenu6,'value');axes(handles.axes2);T=handles.img;g=handles.img;switch str case 1 h=fspecial('sobel'); case 2 h=fspecial('prewitt'); case 3 h=fspecial('laplacian');endif numel(size

43、(g)>2 R=g(:,:,1); G=g(:,:,2); B=g(:,:,3); R1=imfilter(R,h); GP(:,:,1)=imadd(R,R1); G1=imfilter(G,h); GP(:,:,2)=imadd(G,G1); B1=imfilter(B,h); GP(:,:,3)=imadd(B,B1); imshow(GP); handles.img=GP;else g1=g; g2=imfilter(g1,h); g3=imadd(g2,g1); imshow(g3); handles.img=g3;endguidata(hObject,handles);% -

44、 Executes on selection change in popupmenu5.function popupmenu5_Callback(hObject, eventdata, handles)% hObject handle to popupmenu5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(

45、hObject,'String') returns popupmenu5 contents as cell array% contentsget(hObject,'Value') returns selected item from popupmenu5% - Executes during object creation, after setting all properties.function popupmenu5_CreateFcn(hObject, eventdata, handles)% hObject handle to popupmenu5 (s

46、ee GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: popupmenu controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor&#

47、39;), get(0,'defaultUicontrolBackgroundColor') set(hObject,'BackgroundColor','white');end% - Executes on selection change in popupmenu6.function popupmenu6_Callback(hObject, eventdata, handles)% hObject handle to popupmenu6 (see GCBO)% eventdata reserved - to be defined in a

48、future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = cellstr(get(hObject,'String') returns popupmenu6 contents as cell array% contentsget(hObject,'Value') returns selected item from popupmenu6% - Executes during object creation, afte

49、r setting all properties.function popupmenu6_CreateFcn(hObject, eventdata, handles)% hObject handle to popupmenu6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: popupmenu controls usually have

50、 a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor') set(hObject,'BackgroundColor','white');end% - Executes on button press in pushbutton10.function pushbutton10_Callback(hObject, eventdata, handles)%检测% hObject handle to pushbutton10 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global Tstr=get(handles.popupmenu4,'value');axes(handles.axes2);if numel(size(handles.

温馨提示

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

评论

0/150

提交评论