Load and display image when pushing a button

조회 수: 11 (최근 30일)
Matteo Gambaurtti
Matteo Gambaurtti 2017년 12월 9일
댓글: Mohammad Sami 2020년 3월 17일
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
Fareha Chowdhury
Fareha Chowdhury 2020년 3월 16일
did this code work?
Mohammad Sami
Mohammad Sami 2020년 3월 17일
You are using strcat. use the function fullfile(directory,fname) to get the fullpath.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by