Changing the x,y axis values

49 views (last 30 days)
Happy PhD
Happy PhD on 24 May 2018
Hi,
I have a figure of an image showing the pixel number in the x- and y-axis. I would like to display this in angle mrad instead. I know the angle size of one pixel from knowing the pizel size and the distance to light source.
How do I display the angle mrad, 0, 0.5, 1,5 etc in the axes instead of the pixel numbers 1, 2, 3?
Using 'image' to plot the image.
  1 Comment
Happy PhD
Happy PhD on 24 May 2018
Edited: Happy PhD on 24 May 2018
I should probably mentioned,..
I don't know the size of the image I am plotting. I take out a small part of the image and display it. The size can vary from time to time, depending on the size of my object.
I also plot lines and stuff onto the image.

Sign in to comment.

Accepted Answer

Adam
Adam on 24 May 2018
Edited: Adam on 24 May 2018
Set the XData (and YData if required) properties of your image, either when first creating it as e.g.
image( hAxes, 1:360, 1:200, myImage )
or afterwards as e.g.
hIm = image( hAxes, myImage );
hIm.XData = 1:360;
etc.
doc image properties
will take you to the help index page from which you can go to the first link which gives more details.
Note: hAxes there is your axes handle. If you aren't using one then you should! Don't get into the habit of plotting things without giving an explicit axes!
  5 Comments
Happy PhD
Happy PhD on 24 May 2018
Edited: Happy PhD on 24 May 2018
Ok, Im sorry but Im lost. I think I need an simple example. I need to plot something ontop of this image.
This didn't work for me:
hIm = image( hAxes, myImage );
hIm.XData = 1:360;
and Im unsure what hAxes is,...
Adam
Adam on 31 May 2018
'Note: hAxes there is your axes handle. If you aren't using one then you should! Don't get into the habit of plotting things without giving an explicit axes!'
from my original post.

Sign in to comment.

More Answers (1)

Vinny Chandran Suja
Vinny Chandran Suja on 14 Jun 2020
From the handle to the image, eg:
hIm = image(myImage );
It is possible to access the handles of the axes by invoking,
hIm.Parent
The above axes handle can be used to redefine the ticks and ticklabels. For eg. the Yticklabels can be changed as,
hIm.Parent.YTickLabel = {'0', '0.5', '1', '1.5'};

Categories

Find more on Images in Help Center and File Exchange

Products


Release

R2015b

Community Treasure Hunt

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

Start Hunting!