11、

(1)界面设计

(2)添加按钮的回调函数

function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fd=get(handles.edit1,'String');%获取函数
axes(handles.axes1)%坐标轴
Xmin=get(handles.edit4,'String');
Xmax=get(handles.edit5,'String');
Ymin=get(handles.edit6,'String');
Ymax=get(handles.edit7,'String');%坐标轴范围
f=ezplot(fd,[str2num(Xmin),str2num(Xmax),str2num(Ymin),str2num(Ymax)]);%注意转成数字
col=get(handles.edit2,'String');%获取输入的颜色
wid=get(handles.edit3,'String');%获取输入的线宽
set(f,'Color',col);%设置颜色
set(f,'Linewidth',str2num(wid));%注意str2num
grid on

(3) 

12、图片打开与保存

(1)前台界面

(2)添加打开图片的回调函数

function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (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';'*.gif'},'选择图片');
if isequal(filename,0)
disp('Users Selected Canceled');
else
str=[pathname filename];
im = imread(str);
axes(handles.axes1);%axes1是坐标轴的标示
imshow(im);
end;

(3)保存并退出的回调函数

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)
[filename,pathname]=uiputfile({'*.bmp';},'保存图片','Undefined.bmp');
if ~isequal(filename,0)
str = [pathname filename];
px=getframe(handles.axes1);
%saveas(gcf,str,'bmp');
ta = getappdata(gcf,'Timg');
imwrite(px.cdata,str,'bmp');
close(gcf);
else
disp('保存失败');
end;

(4)大小可调

(5)

12、

(1)

(2)回调函数

function new_pic_1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to new_pic_1 (see VARARGIN) % Choose default command line output for new_pic_1
handles.output = hObject; % Update handles structure
guidata(hObject, handles); % UIWAIT makes new_pic_1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
set(handles.axes1,'xtick',[]);%设置不显示x,y轴
set(handles.axes1,'ytick',[]);
set(handles.axes1,'ycolor','white');
set(handles.axes1,'xcolor','white');
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global imgsrc %全局变量
[filename,pathname]=uigetfile({'*.jpg';'*.bmp';'*.gif'},'选择图片');
if isequal(filename,0)||isequal(pathname,0)
disp('Users Selected Canceled');
end
fpath=[pathname filename];
imgsrc = imread(fpath);
axes(handles.axes1);%axes1是坐标轴的标示
imshow(imgsrc);
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)
close(gcf)

(3)

(4)

function uibuttongroup1_SelectionChangedFcn(hObject, eventdata, handles)
% hObject handle to the selected object in uibuttongroup1
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global imgsrc
str=get(hObject,'String');
axes(handles.axes1);
switch str %调用三种边缘检测函数
case '原图'
imshow(imgsrc)
case 'sobel'
BW=edge(rgb2gray(imgsrc),'sobel');
imshow(BW);
case 'prewitt'
BW=edge(rgb2gray(imgsrc),'prewitt');
imshow(BW);
case 'canny'
BW=edge(rgb2gray(imgsrc),'canny');
imshow(BW);
end

12、参数传递

(1)

clear all
hfig=figure; %新建一个figure窗体
setappdata(hfig,'url','http://www.matlabsky.com'); %添加应用程序数据url
setappdata(hfig,'author','baby_wolf'); %添加应用程序数据author
getappdata(hfig,'url')%获取应用程序数据
getappdata(hfig)

13、

function varargout = pic_1(varargin)
% PIC_1 MATLAB code for pic_1.fig
% PIC_1, by itself, creates a new PIC_1 or raises the existing
% singleton*.
%
% H = PIC_1 returns the handle to a new PIC_1 or the handle to
% the existing singleton*.
%
% PIC_1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in PIC_1.M with the given input arguments.
%
% PIC_1('Property','Value',...) creates a new PIC_1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before pic_1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop_music. All inputs are passed to pic_1_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help pic_1 % Last Modified by GUIDE v2.5 01-Dec-2017 00:36:17 % Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @pic_1_OpeningFcn, ...
'gui_OutputFcn', @pic_1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT % --- Executes just before pic_1 is made visible.
function pic_1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to pic_1 (see VARARGIN) % Choose default command line output for pic_1
handles.output = hObject; % Update handles structure
guidata(hObject, handles);
set(handles.axes1,'xtick',[]);%设置不显示x,y轴
set(handles.axes1,'ytick',[]);
set(handles.axes1,'ycolor','white');
set(handles.axes1,'xcolor','white');
set(handles.axes2,'xtick',[]);%设置不显示x,y轴
set(handles.axes2,'ytick',[]);
set(handles.axes2,'ycolor','white');
set(handles.axes2,'xcolor','white');
set(handles.axes3,'xtick',[]);%设置不显示x,y轴
set(handles.axes3,'ytick',[]);
set(handles.axes3,'ycolor','white');
set(handles.axes3,'xcolor','white');
set(handles.axes4,'xtick',[]);%设置不显示x,y轴
set(handles.axes4,'ytick',[]);
set(handles.axes4,'ycolor','white');
set(handles.axes4,'xcolor','white');
set(handles.axes5,'xtick',[]);%设置不显示x,y轴
set(handles.axes5,'ytick',[]);
set(handles.axes5,'ycolor','white');
set(handles.axes5,'xcolor','white'); % UIWAIT makes pic_1 wait for user response (see UIRESUME)
% uiwait(handles.figure1); % --- Outputs from this function are returned to the command line.
function varargout = pic_1_OutputFcn(hObject, eventdata, handles)
% varargout 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 structure
varargout{1} = handles.output; % --- Executes on button press in rgb.
function rgb_Callback(hObject, eventdata, handles)
% hObject handle to rgb (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global imgsrc
axes(handles.axes2);
[m,n,o]=size(imgsrc);
%%
grayPic=imgsrc(:,:,1);
gp=zeros(1,256); %计算各灰度出现的概率
for i=1:256
gp(i)=length(find(grayPic==(i-1)))/(m*n);
end newGp=zeros(1,256); %计算新的各灰度出现的概率
S1=zeros(1,256);
S2=zeros(1,256);
tmp=0;
for i=1:256
tmp=tmp+gp(i);
S1(i)=tmp;
S2(i)=round(S1(i)*256);
end
for i=1:256
newGp(i)=sum(gp(find(S2==i)));
end newGrayPic=grayPic; %填充各像素点新的灰度值
for i=1:256
newGrayPic(find(grayPic==(i-1)))=S2(i);
end
nr=newGrayPic;
%%
grayPic=imgsrc(:,:,2); gp=zeros(1,256); %计算各灰度出现的概率
for i=1:256
gp(i)=length(find(grayPic==(i-1)))/(m*n);
end newGp=zeros(1,256); %计算新的各灰度出现的概率
S1=zeros(1,256);
S2=zeros(1,256);
tmp=0;
for i=1:256
tmp=tmp+gp(i);
S1(i)=tmp;
S2(i)=round(S1(i)*256);
end
for i=1:256
newGp(i)=sum(gp(find(S2==i)));
end newGrayPic=grayPic; %填充各像素点新的灰度值
for i=1:256
newGrayPic(find(grayPic==(i-1)))=S2(i);
end
ng=newGrayPic;
%%
grayPic=imgsrc(:,:,3); gp=zeros(1,256); %计算各灰度出现的概率
for i=1:256
gp(i)=length(find(grayPic==(i-1)))/(m*n);
end newGp=zeros(1,256); %计算新的各灰度出现的概率
S1=zeros(1,256);
S2=zeros(1,256);
tmp=0;
for i=1:256
tmp=tmp+gp(i);
S1(i)=tmp;
S2(i)=round(S1(i)*256);
end
for i=1:256
newGp(i)=sum(gp(find(S2==i)));
end newGrayPic=grayPic; %填充各像素点新的灰度值
for i=1:256
newGrayPic(find(grayPic==(i-1)))=S2(i);
end
nb=newGrayPic;
%%
res=cat(3,nr,ng,nb);
imshow(res); % --- Executes on button press in hsv.
function hsv_Callback(hObject, eventdata, handles)
% hObject handle to hsv (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global imgsrc
axes(handles.axes3);
hsv=rgb2hsv(imgsrc);
imshow(hsv) % --- Executes on button press in smooth.
function smooth_Callback(hObject, eventdata, handles)
% hObject handle to smooth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global imgsrc
axes(handles.axes4);
w = fspecial('average',8);%生成一个8x8的均值滤波器
smooth_pic = imfilter(imgsrc, w, 'replicate');
imshow(smooth_pic); % --- Executes on button press in sharpen.
function sharpen_Callback(hObject, eventdata, handles)
% hObject handle to sharpen (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global imgsrc
axes(handles.axes5);
H=fspecial('sobel');%sobel滤波器
J=imfilter(imgsrc, H, 'replicate');%灰度值
sharpen=imgsrc+0.32*J;%比例相加
imshow(sharpen) % --- Executes on button press in close_all.
function close_all_Callback(hObject, eventdata, handles)
% hObject handle to close_all (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close all
clear sound % --------------------------------------------------------------------
function file_Callback(hObject, eventdata, handles)
% hObject handle to file (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA) % --------------------------------------------------------------------
function music_Callback(hObject, eventdata, handles)
% hObject handle to music (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA) % --------------------------------------------------------------------
function start_music_Callback(hObject, eventdata, handles)
% hObject handle to start_music (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global song
[filename,pathname]=uigetfile({'*.mp3';'*.wma';'*.wav'},'选择音乐');
if isequal(filename,0)||isequal(pathname,0)
disp('Users Selected Canceled');
end
fpath=[pathname filename];
[song,fs]=audioread(fpath);
sound(song,fs); % --------------------------------------------------------------------
function stop_music_Callback(hObject, eventdata, handles)
% hObject handle to stop_music (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global song
clear sound%结束音乐 % --------------------------------------------------------------------
function openfile_Callback(hObject, eventdata, handles)
% hObject handle to openfile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global imgsrc
[filename,pathname]=uigetfile({'*.jpg';'*.bmp';'*.gif'},'选择图片');
if isequal(filename,0)||isequal(pathname,0)
disp('Users Selected Canceled');
end
fpath=[pathname filename];
imgsrc = imread(fpath);
axes(handles.axes1);%axes1是坐标轴的标示
imshow(imgsrc); % --------------------------------------------------------------------
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) % --------------------------------------------------------------------
function save_rgb_Callback(hObject, eventdata, handles)
% hObject handle to save_rgb (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,pathname]=uiputfile({'*.bmp';},'保存图片','Undefined.bmp');
if ~isequal(filename,0)
str = [pathname filename];
px=getframe(handles.axes2);
%saveas(gcf,str,'bmp');
%ta = getappdata(gcf,'Timg');
imwrite(px.cdata,str,'bmp');
%close(gcf);
else
disp('保存失败');
end; % --------------------------------------------------------------------
function save_hsv_Callback(hObject, eventdata, handles)
% hObject handle to save_hsv (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,pathname]=uiputfile({'*.bmp';},'保存图片','Undefined.bmp');
if ~isequal(filename,0)
str = [pathname filename];
px=getframe(handles.axes3);
%saveas(gcf,str,'bmp');
%ta = getappdata(gcf,'Timg');
imwrite(px.cdata,str,'bmp');
%close(gcf);
else
disp('保存失败');
end;

14、gui转exe

(1)

运行之后,得到如下exe

(2)双击exe

Matlab GUI设计(2)的更多相关文章

  1. Matlab GUI设计中的一些常用函数

    Matlab GUI常用函数总结 % — 文件的打开.读取和关闭% — 文件的保存% — 创建一个进度条% — 在名为display的axes显示图像,然后关闭% — 把数字转化为时间格式% — ch ...

  2. MATLAB GUI 设计要点 转

    https://www.cnblogs.com/wangh0802PositiveANDupward/p/4588512.html 从简单的例子说起吧. 创建Matlab GUI界面通常有两种方式: ...

  3. MATLAB GUI设计(线性卷积和循环卷积的比较--笔记)

    原创循环卷积代码,转载需注明出处 线性卷积与循环卷积的比较 实验目的和要求 掌握循环卷积和线性卷积的原理,与理论分析结果比较,加深理解循环卷积与线性卷积之间的关系. 实验内容和步骤 1) 已知两序列X ...

  4. MATLAB GUI设计(1)

    一.新建GUI 1.命令行窗口输入 guide会出来如下界面,可以新建空白GUI,也可以打开已有GUI 2.通过工具栏新建 二.数据传递例子 1.添加输入框按钮,设置尺寸大小,内容,格式,标签 2.复 ...

  5. MATLAB GUI设计(3)

    一.gca.gcf.gco 1.三者的功能定义: gcf 返回当前Figure 对象的句柄值 gca 返回当前axes 对象的句柄值 gco 返回当前鼠标单击的句柄值,该对象可以是除root 对象外的 ...

  6. [学习一个] Matlab GUI 学习笔记 Ⅰ

    Matlab GUI 学习笔记 Ⅰ 1. Foreword Matlab 是严格意义上的编程语言吗?曾经有人告诉我他是通过 Matlab 学会了面对对象编程,我是不信的,但这依然不妨碍它在特殊领域的强 ...

  7. matlab gui界面设计记录

    我们要进行的程序是彩色图像处理试验示例,用这个程序来练习我们的gui前台设计. 程序功能介绍:具有彩色图像处理及保存和音乐播放功能效果如下图 2 在MATLAB的命令窗口中输入guide命令,打开gu ...

  8. [转载] 关于matlab GUI的一点心得

    转载自 落落轻尘 [Fig文件方式,即使用菜单File->New->GUI来设计界面] 首先值得注意的是,在低版本matlab上制作的含GUI的m文件一般不能在高版本的matlab上面运行 ...

  9. Matlab GUI memo

    有一段时间没写博客,一周4篇文章都坚持不下来,不知道写哪个方面的内容,写研究相关就怕论文查重查到,其他方面也没太多时间去学.还是花时间多学点其他方面.废话到此,很早就做过matlab gui相关,现在 ...

随机推荐

  1. linux构建DHCP服务器

    1.DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一个局域网的网络协议,使用UDP协议工作,主要用途:给内部网络或网络服务供应商自动分配IP地址 ...

  2. c++中比较好用的黑科技

    切入正题,上黑科技 一.黑科技函数(常用的我就不写了,例如sort函数) 1.next_permutation(a+1,a+1+n) a[1-n]全排列 2.reverse(a+1,a+1+n) 将a ...

  3. OpenGL 实现视频编辑中的转场效果

    转场介绍 转场效果是什么? 转场效果,简单来说就是两段视频之间的衔接过渡效果. 现在拍摄 vlog 的玩家越来越多,要是视频没有一两个炫酷的转场效果,都不好意思拿出来炫酷了. 那么如何在视频编辑软件中 ...

  4. 学习ConcurrentHashMap并发写机制

    1. 前言 上篇文章讲了 Unsafe 类中 CAS 的实现,其实是在为这篇文章打基础.不太熟悉的小伙伴请移步Unsafe 中 CAS 的实现.本篇文章主要基于 OpenJDK8 来做源码解析. 2. ...

  5. Vue2.0 【第二季】第8节 Component 父子组件关系

    目录 Vue2.0 [第二季]第8节 Component 父子组件关系 第8节 Component 父子组件关系 一.构造器外部写局部注册组件 二.父子组件的嵌套 Vue2.0 [第二季]第8节 Co ...

  6. Vue2.0 【第一季】第5节 v-on:绑定事件监听器

    目录 Vue2.0 [第一季] 第5节 v-on:绑定事件监听器 第五节 v-on:绑定事件监听器 一.使用绑定事件监听器,编写一个加分减分的程序. Vue2.0 [第一季] 第5节 v-on:绑定事 ...

  7. 03、MySql的数据类型

    MySQL中定义数据字段的类型对你数据库的优化是非常重要的. MySQL支持多种类型,大致可以分为三类:数值.日期/时间和字符串(字符)类型. 1.数字类型 类型 大小 范围(有符号) 范围(无符号) ...

  8. 记一次修改mysql密码

    因为马大哈的原因,没有记录自己服务器mysql的密码,试来试去试不出来只好选择重置密码. 直接上命令: 首先 vim /etc/my.cnf 在my.cnf文件中,在[mysqld]的段中加上 ski ...

  9. MQTT抓包分析

    1. 概述 MQTT(Message Queuing Telemetry Transport,消息队列遥测传输协议),是一种基于发布/订阅(Publish/Subscribe)模式的轻量级通讯协议,该 ...

  10. JavaScript每日学习日记(1)

    8.11.2019 1. lastIndexOf() 方法从尾到头进行检索. 2. 有三种提取部分字符串的方法: 2.1 slice(start, end)  如果某个参数为负,则从字符串的结尾开始计 ...