当前位置:网站首页>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 !

边栏推荐
猜你喜欢

& 3 view request message and response message in browser

什么是外链和内链?

Safety innovation practice | Haitai Fangyuan was invited to participate in the technical exchange Seminar on "network information innovation and value co creation in the digital age"

Intelligent trash can (IV) -- raspberry pie Pico realizes ultrasonic ranging (hc-sr04)

pod安全策略(PSP)

黑化的蜜雪冰城,凭营销就想抓牢消费者的心?

Sofaregistry source code | data synchronization module analysis
![Jerry's about TWS pairing mode configuration [chapter]](/img/c8/d78e817295169753244299545d9aba.png)
Jerry's about TWS pairing mode configuration [chapter]

SOFARegistry 源码|数据同步模块解析

MATLAB Gui 实现点击按钮,打开文件对话框,导入图片功能
随机推荐
杰理之关于 TWS 配对方式配置【篇】
AUTOCAD——文字显示方式、CAD怎么直接打开天正图纸
2022胺基化工艺考试题模拟考试题库及在线模拟考试
2022 Guangxi provincial safety officer C certificate examination questions and mock examination
美创入选信通院“业务安全推进计划”首批成员单位
C语言##__VA_ARGS__的用法
Introduction to software engineering - Chapter 5 - overall design
Easy express: we use Zadig to realize 10000 times of construction and deployment, smart operation and maintenance, and release development productivity
AOSP ~ Logcat 持久化
2022施工员-土建方向-通用基础(施工员)理论题库模拟考试平台操作
Good news | Haitai Fangyuan has passed the cmmi-3 qualification certification, and its R & D capability has been internationally recognized
基于字节码的统一异常上报实践
[HBZ sharing] InnoDB principle of MySQL
杰理之关于 TWS 声道配置【篇】
杰理之关于开机发起回连对耳的位置:【篇】
Students' programming stories
torch. Load load model error: can't get attribute 'VAE_ vc‘ on <module ‘__ main__‘ From 'xxxx() run file path‘
c# 键盘钩子
钛动科技:我们的 Zadig 落地之路
Deep understanding of volatile keyword