Finding coordinates of a rectangle in a picture
Show older comments
I'm running an eyetracking experiment. I display an image using the Screen function from psychtoolbox and I want to know the coordinates of some of the items displayed in the picture. Is there a way of drawing a rectangle on the positions you want to find the location of? Or is there another way of doing it? Thanks.
Answers (3)
KSSV
on 3 Oct 2016
1 vote
You can draw rectangle using imrect.
doc imrect.
You can interactively pick the coordinates from the plot/ figure using ginput().
doc ginput.
6 Comments
Alice
on 3 Oct 2016
KSSV
on 3 Oct 2016
You have to write this ginput, when you want to seek the coordinates....in the code.
Image Analyst
on 3 Oct 2016
Is the screen function something that runs and waits for user input, or does it just display the image and move on to the next line of code? Understand that that third party toolbox is not a standard one that we all have (it's not even from the Mathworks) so we don't know.
Alice
on 4 Oct 2016
KSSV
on 4 Oct 2016
They are the coordinates/ locations where you have clicked.
Ann G
on 3 Oct 2016
You can use the ginput and save the coordinates x,y by choosing the items.
[x,y]=ginput;
save x
save y
Mihaela Duta
on 11 Oct 2016
Edited: Mihaela Duta
on 11 Oct 2016
0 votes
I would suggest to use an image processing package to identify the areas of interest in your picture. You can use Adobe Photoshop if you have it, but gimp is an excellent free alternative (https://www.gimp.org/).
I am not sure whether you want to use these regions of interest when displaying the picture during the experiment, or for data processing. If you want to highlight regions of interest during the stimuli presentation, you can do that using the FrameRect function from Psychtoolbox.
Categories
Find more on Image display and manipulation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!