How to use improfile taking image from UIaxes in App designer

5 次查看(过去 30 天)
Hello!
I'm developing a windows application to demonstrate image profile as a program reaction to button click. Unfortunately I do not understand how I can use improfile function taking the image as a parameter from a UIAxes component of my application.
As I understand it must be really simple. I tried to pass the UIAxes as parameter, but it failes.
I will appreciate any guidance from Matlab community. Thank you in advance!
  1 个评论
Walter Roberson
Walter Roberson 2023-8-21
Have you used image() or imagesc() or imshow() to display an "image" to the UIAxis ? Or is it something else completely, such as a pcolor() or a patch or a histogram?

请先登录,再进行评论。

采纳的回答

Praveen Reddy
Praveen Reddy 2023-8-21
Hi Igor,
I understand that you want to pass image on the app designer UI axes as input to “improfile” function. Here is one way to do it in the call back function.
  • Read the image from app UI Axes using “getframe” function
  • Convert the image to grayscale
  • Define starting and ending coordinates for the profile.
  • Pass the grayscale image along with starting and ending coordinates as shown below.
function profileButtonPushed(app, event)
frame=getframe(app.UIAxes); %axes handle from which image has to be obtained
rgbImage = frame.cdata;
grayImage=rgb2gray(rgbImage);
x1 = 100; % starting x-coordinate
y1 = 100; % starting y-coordinate
x2 = 200; % ending x-coordinate
y2 = 200; % ending y-coordinate
profile = improfile(grayImage, [x1, x2], [y1, y2]);
plot(app.UIAxes2,profile);
end
Attaching an .mlapp file for reference where “improfile” function takes input from UI Axes.
Please refer to the following MATLAB documentations to know more about “improfile”,getframe” functions.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

Translated by