How to show ginput coordinates into real axis value

849 Views Asked by At

Hi i am trying to extract the coordinates from image (e.g. circle.png attached) enter image description here

I use ginput to extract x,y coorinate of my interest (in this case 4 red dots inside the circle)

A=imread('circle.png');
figure,imshow(A)
[y,x]=ginput

I click on 4 red dots and I got x,y coordinates as below

x=134.000000000000
  154.000000000000
  125.000000000000
  136.000000000000


y= 83
   153.000000000000
   170.000000000000
   245.000000000000

In this case, x and y coordinates that I got are based on which axis? How can I convert these x and y coordinates to relate into my real data (i.e. I would like to show x axis from 0 to 15 and y axis from 0 to 5)?

1

There are 1 best solutions below

4
On

By default imshow hides the tick marks of the axes on which the image is displayed. To see what the actual axis limits are (and hence how your image is scaled on the axis) you can do

>> get(gca,'Xlim')
>> get(gca,'YLim')

Or if you'd like to make the axis labels visible then you can do

>> h = gca;
>> h.XAxis.Visible = 'on';
>> h.YAxis.Visible = 'on';

The x and y point returned by ginput are relative to those axis limits.