Filter löschen
Filter löschen

How to display an image in UI Figure on app designer?

205 Ansichten (letzte 30 Tage)
tejas alva
tejas alva am 13 Sep. 2018
Bearbeitet: Mostafa Amr am 5 Mai 2022
How can i display the figure i select from the folder in UI figure of App designer? I am using version 2016a and as per the code below, when i click the "button", the image opens in a different window.
% Button button pushed function
function ButtonButtonPushed2(app)
[file,path]=uigetfile({'*.jpg';'*.bmp';'*.gif';'*.tiff'}, 'Select file');
a= imread(file);
imshow(a);

Akzeptierte Antwort

OCDER
OCDER am 13 Sep. 2018
Try this:
imshow(a, 'parent', app.UIAxes);
But, you'll run into issues with having all this x, y, title of axes still shown and taking up space. See this post to fix that issue:
  14 Kommentare
Eric Sargent
Eric Sargent am 22 Mai 2020
Starting in R2019a, you can use the uiimage function to create an image component in your App Designer apps.
Mostafa Amr
Mostafa Amr am 5 Mai 2022
Bearbeitet: Mostafa Amr am 5 Mai 2022
[FileName, FilePath]= uigetfile({'*.jpg';'*.bnp';'*.gif';'*.tiff'}, 'Select a file'); %Don't override path.m
if isnumeric(FileName); return; end %User did not select a file
a = imread(fullfile(FilePath, FileName)); %Always use full file path, not relative path
imshow(a, 'Parent' , app.UIAxes); %This should work...
this code gives me an error which is
Error using image
Too many input arguments.
Error in images.internal.basicImageDisplay (line 24)
hh = image(cdata, ...
Error in imshow (line 330)
hh = images.internal.basicImageDisplay(fig_handle,ax_handle,...
when I use imshow outside the appdesigner it works but after trying to use it inside the appdesigner it gives me errors inside it and outside it and that happened with diffrenet codes not only with that and I do not know why (I use matlab R2021a)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Melinda Toth-Zubairi
Melinda Toth-Zubairi am 12 Jun. 2019
Starting in R2019a, you can use the uiimage function to create an image component in your App Designer apps. See here for more details:

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by