Intensity Profile of a specific line

26 次查看(过去 30 天)
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

采纳的回答

Matt J
Matt J 2021-10-24
  9 个评论
Omor Khan
Omor Khan 2021-11-8
@Matt J would you mind showing me a demo of what you mean? I don't think I understand it and how to implement it. Thank you!
Matt J
Matt J 2021-11-8
编辑:Matt J 2021-11-8
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by