Filter löschen
Filter löschen

How to loop over images in a folder in an AppDesigner GUI?

1 Ansicht (letzte 30 Tage)
Michael
Michael am 19 Nov. 2017
Beantwortet: Praveen Reddy am 15 Mär. 2023
Unfortunately, I have absolutely no experience with AppDesigner yet. If there is a good tutorial going in the direction of what I want to solve, I'd also appreciate a hint to the corresponding link.
Now to my problem: I have a folder filled with images that are named following the convention A_i.tif and B_i.tif, i.e. for every i there are two images A and B.
How can I create a GUI using AppDesigner that "loops" over all i = 1:N image pairs, displays one pair at a time and waits for the user to click one of 3 button options before the next image pair is loaded and displayed?
I am only asking for the "loop" functionality, I'll be able to do the rest. The rather generic code frame is
classdef ManualCheckGUI < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
UIAxes matlab.ui.control.UIAxes
UIAxes2 matlab.ui.control.UIAxes
KeepButton matlab.ui.control.Button
RemoveButton matlab.ui.control.Button
UndoButton matlab.ui.control.Button
end
methods (Access = private)
% Button pushed function: KeepButton
function KeepButtonPushed(app, event)
end
% Button pushed function: RemoveButton
function RemoveButtonPushed(app, event)
end
% Button pushed function: UndoButton
function UndoButtonPushed(app, event)
end
end
% App initialization and construction
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure
app.UIFigure = uifigure;
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = 'UI Figure';
setAutoResize(app, app.UIFigure, true)
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
title(app.UIAxes, 'Title');
xlabel(app.UIAxes, 'X');
ylabel(app.UIAxes, 'Y');
app.UIAxes.Position = [16 160 300 185];
% Create UIAxes2
app.UIAxes2 = uiaxes(app.UIFigure);
title(app.UIAxes2, 'Title');
xlabel(app.UIAxes2, 'X');
ylabel(app.UIAxes2, 'Y');
app.UIAxes2.Position = [325 160 300 185];
% Create KeepButton
app.KeepButton = uibutton(app.UIFigure, 'push');
app.KeepButton.ButtonPushedFcn = createCallbackFcn(app, @KeepButtonPushed, true);
app.KeepButton.Position = [134 110 100 22];
app.KeepButton.Text = 'Keep';
% Create RemoveButton
app.RemoveButton = uibutton(app.UIFigure, 'push');
app.RemoveButton.ButtonPushedFcn = createCallbackFcn(app, @RemoveButtonPushed, true);
app.RemoveButton.Position = [449 110 100 22];
app.RemoveButton.Text = 'Remove';
% Create UndoButton
app.UndoButton = uibutton(app.UIFigure, 'push');
app.UndoButton.ButtonPushedFcn = createCallbackFcn(app, @UndoButtonPushed, true);
app.UndoButton.Position = [289 110 100 22];
app.UndoButton.Text = 'Undo';
end
end
methods (Access = public)
% Construct app
function app = ManualCheckGUI()
% Create and configure components
createComponents(app)
% 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

Antworten (1)

Praveen Reddy
Praveen Reddy am 15 Mär. 2023
Hi Michael,
I understand that you want to loop through all images in a folder but wait for the user to perform a UI activity before loading the next pair of images. You can use a state variable in the for loop to pause the execution (Alternatively state button). Toggle the state value in appropriate call back functions to resume the for loop. I have tried to replicate the functionality with a text box; however, you can use the similar logic with an image panel component instead of text box. I have attached the mlapp file for reference.
The following resources also might help you:

Kategorien

Mehr zu Develop uifigure-Based Apps 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