How to use getrect only for axes1?

2 Ansichten (letzte 30 Tage)
guanin hae
guanin hae am 2 Jan. 2022
Kommentiert: guanin hae am 3 Jan. 2022
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);

Akzeptierte Antwort

Adam Danz
Adam Danz am 2 Jan. 2022
Specify the axis handle in the first input
However, getrect is outdated. Consider using
  4 Kommentare
Adam Danz
Adam Danz am 3 Jan. 2022
@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 am 3 Jan. 2022
It worked thank you!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Visual Exploration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by