Trying to learn how to display an image using app designer

10 visualizaciones (últimos 30 días)
My goal is to display a series of cine images for QA that obviously displays the cine, and adjust the speed, intensity, etc. I am trying to use app designer to do this, which is probably trivial, but I am running into conceptual issues on my part. I have an image JJ created using the following in the Command Window:
JJ = imagesc(imadjust(dtx(:,:,1))); % where dtx is the cine data in the Workspace and JJ.CData is 128x128 double
Now these variable are in the Workspace and I can share then with other .m programs I have loaded, but when I copy over the mlapp text, edit it and run it, it does not see the current Workspace variables.
So how do I share the Workspace variables? Also I cannot edit the script while in Code View. Why is that the case and how do I modify that?
Text that I am trying to display a single image frame.
________________________________________________________________
classdef app2test2 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
UIAxes matlab.ui.control.UIAxes
end
% App initialization and construction
methods (Access = public)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure
app.UIFigure = uifigure;
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = 'UI Figure';
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
title(app.UIAxes, 'Title')
app.UIAxes.XColor = [1 1 1];
app.UIAxes.XTick = [];
app.UIAxes.YColor = [1 1 1];
app.UIAxes.YTick = [];
app.UIAxes.Position = [72 69 420 310];
end
end
methods (Access = public)
% Construct app
function app = app2test2
% Create and configure components
createComponents(app)
% JJ = imagesc(imadjust(dtx(:,:,1)));
imshow(JJ.CData,'Parent', app.UIAxes);
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end
  2 comentarios
Adam
Adam el 24 de Oct. de 2018
If I remember correctly, the constructor of App Designer classes now take arguments (they didn't until a very recent version of Matlab) so you can just pass them in there, or put them in a struct or, even better, their own parameter class(es), to pass in if there are a few of them.
Patrick Ford
Patrick Ford el 24 de Oct. de 2018
Right now I am attempting to learn how to use App design and want to access the variables in the work space that have been created by other apps to prototype. (Basically I am moving an .m to a have a gui)
I accomplished the effect by saving the image as a .mat file the reopening it.
X= open('JJ.mat');
imshow(X.JJ,'Parent', app.UIAxes);
where X is a stuct 1 with field JJ 128 x 128 double
But since I already have the data in ram, this is a lot of extra work and overhead.
Thanks

Iniciar sesión para comentar.

Respuesta aceptada

Chris Portal
Chris Portal el 25 de Oct. de 2018
You can pass workspace variables to your app using a startup function and app input arguments. The approach is described here:

Más respuestas (0)

Categorías

Más información sobre Develop uifigure-Based Apps en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by