Trying to learn how to display an image using app designer

11 views (last 30 days)
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 Comments
Patrick Ford
Patrick Ford on 24 Oct 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

Sign in to comment.

Accepted Answer

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

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!