当前位置:网站首页>Matlab GUI realizes the function of clicking the button, opening the file dialog box and importing pictures
Matlab GUI realizes the function of clicking the button, opening the file dialog box and importing pictures
2022-06-29 12:07:00 【Fish ball】
That's what it is MATLAB Gui Interface built in , The purpose is to read and import pictures .

stay Gui In the interface , Right click the button , choice Callback Enter the callback function ( Right click the select Picture button --- Click View callback ---- choice Callback), The visible codes are as follows :
Because what I want to display is a picture , So the file type only selects .bmp and .jpg and .png Three formats , Of course, you can add it according to your own needs !
filename The file name is saved in ,filepath The path saved in is , Note that the second sentence must be filepath before , So that the file can be read later .
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 image;
[filename,filepath]=uigetfile({'*.bmp;*.png;*.jpg;'},' Choose an image ');% Write down the file types that can be imported
if(isequal(filename,0)||isequal(filepath,0)) % If you press Cancel , be return
return;
end
image = [filepath,filename]; % Save the file name , And as a global variable , It is convenient for later programs to call
im=imread(image);
axes(handles.axes1);
imshow(im);
title(' original image '); % Display images , stay axes1
axes(handles.axes2);
imhist(im); % Output image histogram , stay axes2
title(' Histogram of original image ');Command annotations :
1、uigetfile - Open standard dialog box for retrieving files( Open the standard dialog box to retrieve the file )
[FileName,PathName,FilterIndex] = uigetfile(FilterSpec)
[ file name , Pathname , Filter index ]=uigetfile( Filter specification , That is, the filtered content )
2、imread - Read image from graphics file( Read image from drawing file )
3、Set - Set graphics object properties( Set drawing object properties )
4、Image - Display image object( Display image objects )
After importing successfully , The image is displayed in axes Control !(axes The control number should be based on its own Gui Actually modify )
So far, the function of selecting pictures from folders has been completed !

边栏推荐
- 在校生的编程故事
- 基于字节码的统一异常上报实践
- Helping the ultimate experience, best practice of volcano engine edge computing
- 2022 construction worker civil engineering direction general foundation (construction worker) theoretical question bank simulation test platform operation
- Windwos10安装sshd服务
- [VTK] MFC grid editor based on vtk8.2
- Deep understanding of volatile keyword
- 地平线开发板配置网段
- 什么是外链和内链?
- Is the table queried by this EMR sparksql node ODPs?
猜你喜欢

Jericho's position on initiating the connection back to the opposite ear: 【 chapter 】

申请uniapp离线打包时的AppKey
![Jerry's configuration of TWS cross pairing [chapter]](/img/35/a041093ce3dab8e2739bbc1466ba29.png)
Jerry's configuration of TWS cross pairing [chapter]

启泰观察:职业精英创业必踩巨坑之 --- 学习效果坑

Introduction to software engineering - Chapter 5 - overall design

Numpy的ndarray数组基础

杰理之关于 TWS 交叉配对的配置【篇】

Object 类——万类之父

如何查看网站已经保存的密码
联想领像 lenovoimage 部分打印机 驱动 PPD 文件
随机推荐
Unity learning notes --vector3 how to set default parameters
Zhengda futures liu4 data integration
当技术人成长为 CEO,应该修改哪些“Bug”?
自动化测试摸索之路---准备工作
杰理之发起对耳配对、回连、开启可发现、可连接的轮循函数【篇】
合约量化交易系统玩法开发 (现成案例分析)
Codeforces Round #803 (Div. 2)
钛动科技:我们的 Zadig 落地之路
基础类型变量声明
2022广西省安全员C证考试试题及模拟考试
现在怎么开户?有没有更快又安全的开通渠道
MMdet中的Resnet源码解读+Ghost模块
equals提高执行速度/性能优化
Pro test! Centos7 deploy PHP + spool
镜像漏洞扫描工具:Trivy
开源机器学习平台
shell判断命令是否执行成功
Jerry's about TWS pairing mode configuration [chapter]
杰理之关于 TWS 配对方式配置【篇】
Numpy's ndarray array Foundation