Load and display image when pushing a button
显示 更早的评论
I'm looking for help with the creation of a GUI in MATLAB. When the user pushes a button, the program should load an image and display it.
I tried many suggestions found on this forum with no luck.
Here the portion of my code:
% Button pushed function: BrowseButton
function BrowseButtonPushed(app, event)
[FileName,PathName] = uigetfile({'*.jpeg;*.png';'*.*'},'Select an image to process');
FullPath = strcat(PathName,FileName);
app.PathEditField.Value = FullPath;
app.PathEditField.HorizontalAlignment = 'right';
% I = imread(FullPath);
% J = imresize(I, 0.08);
imshow(FullPath,'Parent',app.AcquiredImg);
end
The image should be loaded in AXES called "AcquiredImg" which is inside a panel.
Any suggestion? Thank you!
3 个评论
Michal Dobai
2017-12-10
编辑:Michal Dobai
2017-12-10
Are you using GUIDE or App Designer to create GUI? Or there is a third option, create GUI programmatically.
Edit:
OK. I figured out you probably talking about App Designer GUI. I created simple GUI with one panel, axes, button and textbox for displaying opened image path. Your code works for me just fine.
Are you getting some errors? Or nothing happens when you click on the button? You should provide more information about your problem.
This could be good starting point if you don't know how to create app using App Designer: Create a Simple App Using App Designer
Fareha Chowdhury
2020-3-16
did this code work?
Mohammad Sami
2020-3-17
You are using strcat. use the function fullfile(directory,fname) to get the fullpath.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!