Intensity Profile of a specific line

13 views (last 30 days)
Omor Khan
Omor Khan on 24 Oct 2021
Edited: Matt J on 8 Nov 2021 at 21:03
Hello,
I want to build an app that lets the user upload an image then draw a line on that image. Then with a press of a button an intensity profile of the specified line will show up next to it.
I'm able to uplad an image but I'm stuck on how to draw a line on top of the image, then just save the location and then intensity afterwards.
Here's what I have so far:
classdef Intensity_Analysis < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
PlotButton matlab.ui.control.Button
UploadButton matlab.ui.control.Button
UIAxes2 matlab.ui.control.UIAxes
UIAxes matlab.ui.control.UIAxes
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: UploadButton
function UploadButtonPushed(app, event)
global a;
[filename, pathname] = uigetfile('*.*', 'Pick an Image');
filename = strcat(pathname,filename);
a = imread(filename);
imshow(a,'Parent',app.UIAxes);
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);
title(app.UIAxes, 'Original Image')
zlabel(app.UIAxes, 'Z')
app.UIAxes.Position = [15 173 300 185];
% Create UIAxes2
app.UIAxes2 = uiaxes(app.UIFigure);
title(app.UIAxes2, 'Intensity')
zlabel(app.UIAxes2, 'Z')
app.UIAxes2.Position = [314 173 300 185];
% Create UploadButton
app.UploadButton = uibutton(app.UIFigure, 'push');
app.UploadButton.ButtonPushedFcn = createCallbackFcn(app, @UploadButtonPushed, true);
app.UploadButton.Position = [115 134 100 22];
app.UploadButton.Text = 'Upload';
% Create PlotButton
app.PlotButton = uibutton(app.UIFigure, 'push');
app.PlotButton.Position = [414 134 100 22];
app.PlotButton.Text = 'Plot';
% 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 = Intensity_Analysis
% 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

Accepted Answer

Matt J
Matt J on 24 Oct 2021
  9 Comments
Matt J
Matt J on 8 Nov 2021 at 21:00
I can't demo it because it is interactive. Just issue the command improfile() at the command line or in a function, while an image axis is current. Then start drawing the profile line on the image.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!