MATLAB Answers

Alice
0

Finding coordinates of a rectangle in a picture

Asked by Alice
on 3 Oct 2016
Latest activity Answered by Mihaela Duta on 11 Oct 2016
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.

  0 Comments

Sign in to comment.

3 Answers

Answer by KSSV
on 3 Oct 2016

You can draw rectangle using imrect.
doc imrect.
You can interactively pick the coordinates from the plot/ figure using ginput().
doc ginput.

  6 Comments

Screen displays the image and moves to the next line of code, but when the next line is ginput() I get an error.
Thanks for your help, I know not everyone has the toolbox. :)
What do the x and y coordinates that you get from ginput relate to? Are they pixels, or are they just coordinates on an arbitrary scale?
They are the coordinates/ locations where you have clicked.

Sign in to comment.


Answer by 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

  0 Comments

Sign in to comment.


Answer by Mihaela Duta on 11 Oct 2016
Edited by Mihaela Duta on 11 Oct 2016

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.

  0 Comments

Sign in to comment.