How to use getrect only for axes1?

조회 수: 2 (최근 30일)
guanin hae
guanin hae 2022년 1월 2일
댓글: guanin hae 2022년 1월 3일
I would like to show an image on GUI, and get the selected regions positions with getrect. But when i run my code i can draw a rectangle anywhere on the figure, but i want getrect to work only on axes1. How can i do that?
[file,path] = uigetfile('*.png');
if isequal(file,0)
disp('User selected Cancel');
else
disp(['User selected ', fullfile(path,file)]);
end
fullname=fullfile(path,file);
myimg=imread(fullname);
imshow(myimg);
rect = getrect;
x1 =rect(1);
x2 = x1 + rect(3);
y1 =rect(2);
y2 = y1 + rect(4);

채택된 답변

Adam Danz
Adam Danz 2022년 1월 2일
Specify the axis handle in the first input
However, getrect is outdated. Consider using
  댓글 수: 4
Adam Danz
Adam Danz 2022년 1월 3일
@guanin hae, take a few minutes to read through the drawrectangle link I provided in my answer. You'll quickly learn the answer to your question.
guanin hae
guanin hae 2022년 1월 3일
It worked thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by