Filter löschen
Filter löschen

How to use improfile taking image from UIaxes in App designer

6 Ansichten (letzte 30 Tage)
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 Kommentar
Walter Roberson
Walter Roberson am 21 Aug. 2023
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?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Praveen Reddy
Praveen Reddy am 21 Aug. 2023
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.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by