Hello,
I am trying to build a GUI interface for blind deonvolution for some fluroscence images. I have an issue with assigning the variables from one ButtonPushed function to another ButtonPushed fuction. I tried to make the image variable Global but assigning it startupFcn but it didn't work. The issue is I want the image variable b from UploadButtonPushed2 to DeconvoluteButtonPushed
classdef GUI < matlab.apps.AppBase % Properties that correspond to app components
properties (Access = public) UIFigure matlab.ui.Figure UIAxes matlab.ui.control.UIAxes UploadButton matlab.ui.control.Button DeconvoluteButton matlab.ui.control.Button ParametersPanel matlab.ui.container.Panel GaussianVarianceEditFieldLabel matlab.ui.control.Label GaussianVarianceEditField matlab.ui.control.NumericEditField IterationsEditFieldLabel matlab.ui.control.Label IterationsEditField matlab.ui.control.NumericEditField end % Callbacks that handle component events
methods (Access = private) % Code that executes after component creation
function startupFcn(app) global b end % Button pushed function: UploadButton
function UploadButtonPushed2(app, event) [file,path] = uigetfile({'*.png';'*.jpg';'*.tiff';'*.jpeg'},... 'File Selector'); a=imread(file) b=imcrop(a,[145 58 370 370]) imshow(b,'Parent',app.UIAxes) title(sprintf('%s',file),'Parent',app.UIAxes) end % Button pushed function: DeconvoluteButton
function DeconvoluteButtonPushed(app, event) load(b) % there is the issue I want the image variable b from UploadButtonPushed2 to DeconvoluteButtonPushed
PSF = fspecial('gaussian',[371 371],app.GaussianVarianceEditField.Value) [J,psfr]=deconvblind(b,PSF,app.IterationsEditField.Value) figure subplot(131) imagesc(J) colorbar subplot(132) imagesc(psfr) colorbar subplot(133) imagesc(PSF) colorbar end end % Component initialization
methods (Access = private) % Create UIFigure and components
function createComponents(app) % Create UIFigure and hide until all components are created
app.UIFigure = uifigure('Visible', 'off'); app.UIFigure.Position = [100 100 566 322]; app.UIFigure.Name = 'UI Figure'; % Create UIAxes
app.UIAxes = uiaxes(app.UIFigure); title(app.UIAxes, '') xlabel(app.UIAxes, '') ylabel(app.UIAxes, '') app.UIAxes.XColor = 'none'; app.UIAxes.XTick = []; app.UIAxes.YColor = 'none'; app.UIAxes.YTick = []; app.UIAxes.ZColor = 'none'; app.UIAxes.ZTick = []; app.UIAxes.Position = [12 53 280 234]; % Create UploadButton
app.UploadButton = uibutton(app.UIFigure, 'push'); app.UploadButton.ButtonPushedFcn = createCallbackFcn(app, @UploadButtonPushed2, true); app.UploadButton.Position = [373 256 100 22]; app.UploadButton.Text = 'Upload'; % Create DeconvoluteButton
app.DeconvoluteButton = uibutton(app.UIFigure, 'push'); app.DeconvoluteButton.ButtonPushedFcn = createCallbackFcn(app, @DeconvoluteButtonPushed, true); app.DeconvoluteButton.Position = [374 198 100 22]; app.DeconvoluteButton.Text = 'Deconvolute'; % Create ParametersPanel
app.ParametersPanel = uipanel(app.UIFigure); app.ParametersPanel.TitlePosition = 'centertop'; app.ParametersPanel.Title = 'Parameters'; app.ParametersPanel.FontWeight = 'bold'; app.ParametersPanel.Position = [306 29 237 136]; % Create GaussianVarianceEditFieldLabel
app.GaussianVarianceEditFieldLabel = uilabel(app.ParametersPanel); app.GaussianVarianceEditFieldLabel.HorizontalAlignment = 'right'; app.GaussianVarianceEditFieldLabel.Position = [9 78 106 22]; app.GaussianVarianceEditFieldLabel.Text = 'Gaussian Variance'; % Create GaussianVarianceEditField
app.GaussianVarianceEditField = uieditfield(app.ParametersPanel, 'numeric'); app.GaussianVarianceEditField.Position = [130 78 100 22]; % Create IterationsEditFieldLabel
app.IterationsEditFieldLabel = uilabel(app.ParametersPanel); app.IterationsEditFieldLabel.HorizontalAlignment = 'right'; app.IterationsEditFieldLabel.Position = [46 24 55 22]; app.IterationsEditFieldLabel.Text = 'Iterations'; % Create IterationsEditField
app.IterationsEditField = uieditfield(app.ParametersPanel, 'numeric'); app.IterationsEditField.Position = [131 24 100 22]; % Show the figure after all components are created
app.UIFigure.Visible = 'on'; end end % App creation and deletion
methods (Access = public) % Construct app
function app = GUI % Create UIFigure and components createComponents(app) % Register the app with App Designer
registerApp(app, app.UIFigure) % Execute the startup function
runStartupFcn(app, @startupFcn) 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 endend
Please suggest me a possible solution to this problem
Best Answer