This video shows the steps to open an image from a web URL in MATLAB App Designer.
The sample image URL which it used from demonstration is: https://i0.wp.com/programmerworld.co/wp-content/uploads/2018/11/programmer-world-learn-matlab-simulink-and-android-programming.jpg?resize=723%2C406&ssl=1
https://requestserver.mathworks.com/assets/computerVision.jpg
I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: programmerworld1990@gmail.com
Complete source code and other details:
Main method:
methods (Access = private)
% Value changed function: EngterURLEditField
function EngterURLEditFieldValueChanged(app, event)
value = app.EngterURLEditField.Value;
imageURL = webread(value);
imageURL = imresize(imageURL, 1.1);
image(app.UIAxes,imageURL);
end
end
Complete source code:
classdef WebImageInAppDesigner < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
EngterURLEditField matlab.ui.control.EditField
EngterURLEditFieldLabel matlab.ui.control.Label
UIAxes matlab.ui.control.UIAxes
end
% Callbacks that handle component events
methods (Access = private)
% Value changed function: EngterURLEditField
function EngterURLEditFieldValueChanged(app, event)
value = app.EngterURLEditField.Value;
imageURL = webread(value);
imageURL = imresize(imageURL, 1.1);
image(app.UIAxes,imageURL);
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 640 480];
app.UIFigure.Name = 'MATLAB App';
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
app.UIAxes.XTickLabel = '';
app.UIAxes.YTick = [0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1];
app.UIAxes.YTickLabel = '';
app.UIAxes.Position = [43 35 566 350];
% Create EngterURLEditFieldLabel
app.EngterURLEditFieldLabel = uilabel(app.UIFigure);
app.EngterURLEditFieldLabel.HorizontalAlignment = 'right';
app.EngterURLEditFieldLabel.Position = [43 420 68 22];
app.EngterURLEditFieldLabel.Text = 'Engter URL';
% Create EngterURLEditField
app.EngterURLEditField = uieditfield(app.UIFigure, 'text');
app.EngterURLEditField.ValueChangedFcn = createCallbackFcn(app, @EngterURLEditFieldValueChanged, true);
app.EngterURLEditField.Position = [126 420 473 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 = WebImageInAppDesigner
% Create UIFigure and 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
Screenshot:
![](https://programmerworld.co/wp-content/uploads/2023/11/image-28-1024x544.png)
![](https://programmerworld.co/wp-content/uploads/2023/11/image-29.png)
![](https://programmerworld.co/wp-content/uploads/2023/11/image-30-1024x546.png)