为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

20120511048王晨晨

2014-01-02 12页 doc 2MB 17阅读

用户头像

is_167734

暂无简介

举报
20120511048王晨晨2013-1014第一学期MATLAB课程期末考核作业 20120511048 王晨晨 基于MATLAB GUI的图片的数字化处理界面设计 设计目标: 利用GUI设计工具设计一个界面,该界面包括两个用于显示图片的坐标轴对象。用户通过单击相应的按钮,可以对图片进行灰度处理、均值化处理、直方图显示、亮度调节、颜色调节、旋转角度、背景颜色调节的功能。 打开GUI设计设计窗口,添加相关控件对象,并设置相应的属性。 编写代码,实现控件的功能。 1、加载图片按钮的代码:function pushbutton5_Callback(hObje...
20120511048王晨晨
2013-1014第一学期MATLAB课程期末考核作业 20120511048 王晨晨 基于MATLAB GUI的图片的数字化处理界面设计 设计目标: 利用GUI设计工具设计一个界面,该界面包括两个用于显示图片的坐标轴对象。用户通过单击相应的按钮,可以对图片进行灰度处理、均值化处理、直方图显示、亮度调节、颜色调节、旋转角度、背景颜色调节的功能。 打开GUI设计设计窗口,添加相关控件对象,并设置相应的属性。 编写代码,实现控件的功能。 1、加载图片按钮的代码:function pushbutton5_Callback(hObject, eventdata, handles) % hObject handle to pushbutton5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) [filename,pathname] =uigetfile({'*.jpg';'*.bmp';'*.tif'},'加载图片'); file=[pathname,filename]; global S; %设置一个全局变量S, S=file; x=imread(file); %选中图片 axes(handles.axes1); imshow(x); %用axes1 显示原图 axes(handles.axes2); imshow(x); %用axes2 显示处理后对比图 handles.img=x; %用handles(句柄)存储当前图像 guidata(hObject,handles); %保存handles 的内容 % --- Executes on button press in pushbutton6. 2、灰度处理按钮的代码;function pushbutton6_Callback(hObject, eventdata, handles) % hObject handle to pushbutton6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global T %设置全局变量 axes(handles.axes2); T=getimage; %获取当前图像(上一次操作后的图片) x=rgb2gray(handles.img); %二值化 imshow(x); %显示二值化后图片 handles.img=x; %用handles(句柄)存储当前图像 guidata(hObject,handles); %保存handles(句柄)的内容 3、反化按钮的代码:function pushbutton7_Callback(hObject, eventdata, handles) % hObject handle to pushbutton7 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global T %设置全局变量 axes(handles.axes2); %启用axes2 T=getimage; %获取上次操作图片 f=imcomplement(handles.img); %对图像数据进行取反运算(实现底片效果)。 imshow(f); %显示之 handles.img=f; %储存在句柄中 guidata(hObject,handles); %保存句柄内容 4、亮度调节的代码:function pushbutton8_Callback(hObject, eventdata, handles) % hObject handle to pushbutton8 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global T %全局变量 axes(handles.axes2); %启用axes2 T=getimage; %获取上一步图像 prompt={'调节倍数'}; %调节倍数对话框 defans={'1'}; %默认值设为1 p=inputdlg(prompt,'input',1,defans); %输入框由用户输入数值 p1=str2double(p{1}); %把字符串转换数值 y=imadjust(handles.img,[ ], [ ],p1); %调节灰度图像的亮度或彩色图像 imshow(y); %显示之 handles.img=y; guidata(hObject,handles); 5、直方图的代码:function pushbutton9_Callback(hObject, eventdata, % handles structure with handles and user data (see GUIDATA) axes(handles.axes2); x=imhist(handles.img); %显示灰度直方图 x1=x(1:10:256); horz=1:10:256; %X轴范围设置 bar(horz,x1); %调用bar函数显示直方图 axis([0 255 0 15000]); %设置Y轴示值范围 set(handles.axes2,'xtick',0:10:255); %X轴范围及分度 set(handles.axes2,'ytick',0:2000:15000); %Y值范围及分度 6、均值按钮的代码: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) T=getimage; %获取上一步图像 h=histeq(handles.img,64); %均衡化后的直方图只有64 个灰度值 imshow(h); %显示之 handles.img=h; %储存在句柄中 guidata(hObject,handles); %保存句柄内容 7、撤销上步按钮的代码: function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global T %全局变量 axes(handles.axes2); %启用axes2 imshow(T); %显示上一步图像(即撤销当前步骤的操 handles.img=T; guidata(hObject,handles); 8、恢复原图按钮的代码:function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global S %原图的全局变量 axes(handles.axes2); y=imread(S); %选择原图 imshow(y); %显示原图 handles.img=y; guidata(hObject,handles); 9、旋转图片按钮代码: function togglebutton2_Callback(hObject, eventdata, handles) % hObject handle to togglebutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global S %原图的全局变量 axes(handles.axes2); a=imread(S); %选择原图 a1=imrotate(a,-45,'bilinear');%%旋转函数,45为旋转角度,bilinear为旋转后不是整数点的像素值 通过双线性插值得到。当旋转角度为正时,逆时针旋转;当旋转角度为负时,顺时针旋转 imshow(a1); 10:改变背景颜色代码: function radiobutton6_Callback(hObject, eventdata, handles) % hObject handle to radiobutton6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(gcf, 'color', 'blue'); 11、适当调整图片颜色的代码: 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) global S %原图的全局变量 axes(handles.axes2); a=imread(S); %选择原图 b = imadjust(a,[.0 .2 0; .5 .6 .5],[]); [Height,Width,temp_3] = size(a); image(b) 12、退出按钮的代码 : % handles structure with handles and user data (see GUIDATA) clc; %退出 close all; close(gcf); Clear; 四、图片显示如下: 1、原图显示: 灰度处理: 直方图显示: 均值化处理: 5、均值化后的直方 6、恢复原图: 7、亮度调节: 8:反化处理: 9、旋转角度处理: 10图片颜色调节: 11、背景颜色调节:
/
本文档为【20120511048王晨晨】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索