How to use improfile taking image from UIaxes in App designer

조회 수: 8 (최근 30일)
Igor Grishin
Igor Grishin 2023년 8월 1일
댓글: Walter Roberson 2023년 8월 21일
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개)

Community Treasure Hunt

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

Start Hunting!

Translated by