Intensity Profile of a specific line
14 views (last 30 days)
Show older comments
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 is a thread of basically what I want to do: https://www.mathworks.com/matlabcentral/answers/389889-how-to-plot-intensity-profile-of-an-image?s_tid=srchtitle
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/776633/image.png)
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
0 Comments
Accepted Answer
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!