Changing the x,y axis values

51 次查看(过去 30 天)
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 个评论
Happy PhD
Happy PhD 2018-5-24
编辑:Happy PhD 2018-5-24
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.

请先登录,再进行评论。

采纳的回答

Adam
Adam 2018-5-24
编辑:Adam 2018-5-24
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 个评论
Happy PhD
Happy PhD 2018-5-24
编辑:Happy PhD 2018-5-24
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 2018-5-31
'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.

请先登录,再进行评论。

更多回答(1 个)

Vinny Chandran Suja
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'};

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

产品


版本

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by