% 作者:徐志豪-苏州城市学院-科电俱乐部
% 开发时间:2022年4月
% 说明:禁止商用,欢迎大家魔改。
% 在此感谢张君豪学长以及卢冠阳对本次开发提供的帮助和建议
%开源地址:https://github.com/xuzhihaoup/Matlab-Gui-based-graph-transfer-to-upper-computer
function varargout = KeDianClub(varargin)
% KeDianClub MATLAB code for KeDianClub.fig
% KeDianClub, by itself, creates a new KeDianClub or raises the existing
% singleton*.
%
% H = KeDianClub returns the handle to a new KeDianClub or the handle to
% the existing singleton*.
%
% KeDianClub('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in KeDianClub.M with the given input arguments.
%
% KeDianClub('Property','Value',...) creates a new KeDianClub or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before KeDianClub_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to KeDianClub_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 KeDianClub
% Last Modified by GUIDE v2.5 05-Aug-2022 12:28:39
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @KeDianClub_OpeningFcn, ...
'gui_OutputFcn', @KeDianClub_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 KeDianClub is made visible.
function KeDianClub_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 KeDianClub (see VARARGIN)
%global get_image;
% Choose default command line output for KeDianClub
handles.output = hObject;
handles.get_image = ones(60,94);
guidata(hObject, handles);
%set(handles.image1,'Visible','off');
%set(handles.image2,'Visible','off');
% Ports = instrhwinfo('serial');
% if size(Ports.AvailableSerialPorts,1) ~= 0
% comlist = Ports.AvailableSerialPorts;
% set(handles.list1,'string',comlist);
% end
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes KeDianClub wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = KeDianClub_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 open.
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)
axes(handles.image1);
%图像重置
cla reset ;
axes(handles.image2);
%图像重置
cla reset ;
[image_name image_path]=uigetfile({'*.jpg';'*.bmp';'*.jpeg';'*.png'}, '打开文件');
original_image = [image_path image_name];
new_image = [image_path image_name];
%打开图像提示
if isequal(image_name,0)
warndlg('请选择一张图片','Warning') ;
else
img_path = sprintf('\n%s',original_image);
set(handles.text4,'string',img_path);
end
%判断图像文件格式是否正确
[fpath, fname, fext]=fileparts(image_name);
image_Type = ({'.bmp','.jpg','.jpeg','.png'});
%图像格式判断标志为
image_Type_flag = 0;
image_type_num = length(image_Type);
for i = 1 : image_type_num
if strcmpi(fext,image_Type{i})
image_Type_flag = 1;
set(handles.image1,'Visible','on');
set(handles.image2,'Visible','on');
end
end
if image_Type_flag == 0
errordlg('图像格式错误,可用格式[jpg、jpeg、bmp、png]','格式错误');
end
%加载图像到结构体
handles.oldimg = imread(original_image);
handles.img = imread(new_image);
h = waitbar(0,'Loading your image...');
for i=1:100
s=sprintf('运行中:%d',ceil(i/10));
waitbar(i/100,h,[s '%']);
end
close(h)
axes(handles.image2);
cla;
imshow(handles.img);
guidata(hObject,handles);
axes(handles.image1);
cla;
imshow(handles.img);
%示波器更新
update_image(handles,1);
%保存图片
% --- Executes on button press in save.
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)
[filename, pathname] = uiputfile({'*.png';'*.bmp';'*.jpg'},'图片保存');
if filename ~= 0
%imwrite(handles.img,save,'save.file');
h=getframe(handles.image2);%picture是GUI界面绘图的坐标系句柄
imwrite(h.cdata,[pathname, filename]);
msgbox('图像已成功保存','确认!','warn');
else
msgbox('操作已取消','确认','warn');
end
%清除效果
% --- Executes on button press in reset.
function reset_Callback(hObject, eventdata, handles)
% hObject handle to reset (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.s1,'Value',0);
set(handles.s2,'Value',0);
handles.img = handles.oldimg;
guidata(hObject,handles);
axes(handles.image2);
cla reset ;
imshow(handles.img);
axes(handles.image3);
cla reset ;
update_image(handles,1);
axes(handles.image4);
cla reset ;
axes(handles.image5);
cla reset ;
update_image(handles,3);
%退出程序
% --- Executes on button press in exit.
function exit_Callback(hObject, eventdata, handles)
% hObject handle to exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close all;
%老版栅格
% --- Executes on button press in pushbutton5.
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)
axes(handles.image2);
cla;
imshow(handles.img);
hold on
img_width = size(handles.img,2); %获取图像宽
img_length = size(handles.img,1); %获取图像长
%[X,Y] = meshgrid(1:100,1:100);
M = round(str2num(get(handles.edit1,'String')));
[X,Y] = meshgrid(round(linspace(1, img_width, M)), ...
round(linspace(1, img_length, M)));%生成数据点矩阵
mesh(X, Y, zeros(size(X)), 'FaceColor', ...
'None', 'LineWidth', 1, ...
'EdgeColor', 'k');
%plot(X,Y,'k',Y,X,'k'); %横线&竖线。
%axis equal; %方格网络
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATL
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于Matlab Gui的图传上位机源码(高分项目).zip基于Matlab Gui的图传上位机 下载.m文件和.fig文件运行即可 userprogra.m是二次开发的接口 主演功能: 1.代码动态编译 2.各种基本图像处理功能 3.串口通信 4.无线图传 基于Matlab Gui的图传上位机源码(高分项目).zip基于Matlab Gui的图传上位机 下载.m文件和.fig文件运行即可 userprogra.m是二次开发的接口 主演功能: 1.代码动态编译 2.各种基本图像处理功能 3.串口通信 4.无线图传 基于Matlab Gui的图传上位机源码(高分项目).zip基于Matlab Gui的图传上位机 下载.m文件和.fig文件运行即可 userprogra.m是二次开发的接口 主演功能: 1.代码动态编译 2.各种基本图像处理功能 3.串口通信 4.无线图传 基于Matlab Gui的图传上位机源码(高分项目).zip基于Matlab Gui的图传上位机 下载.m文件和.fig文件运行即可 userprogra.m是二次开发的接口 主演功能: 1.代码动态编译 2.各种
资源推荐
资源详情
资源评论
收起资源包目录
基于Matlab Gui的图传上位机源码.zip (3个子文件)
Matlab-Gui-based-graph-transfer-to-upper-computer-main
userprogram.m 2KB
KeDianClub.m 47KB
KeDianClub.fig 114KB
共 3 条
- 1
资源评论
不安分的小女孩
- 粉丝: 9940
- 资源: 2367
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- strawberry-perl-5.38.2.2-64bit.msi
- MeyboMail Web(Java)简化版
- java(结合lucene)版的公交搜索系统
- 【OpenHarmony】ArkTS 语法基础 ④ ( ArkTS UI 渲染控制 - 条件渲染 - 循环渲染 )
- 稽查监控平台标准化设计数据模型设计
- 一款极好用的 Office/WPS/Word/Excel/PPT/PDF工具箱软件 OfficeUtils 2.7
- 基于STM32的家庭环境参数检测系统设计
- 夺宝答题王答题小程序源码 开源可二开 Thinkphp内核
- Linux 系统下 Hadoop 安装配置教程.md
- 用于 CH32 MCU 的 CMake 实用程序(基于 STM32-CMake Proejct
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功