필터 지우기
필터 지우기

Intensity Profile of a specific line

조회 수: 14 (최근 30일)
Omor Khan
Omor Khan 2021년 10월 24일
편집: Matt J 2021년 11월 8일
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