Changing the x,y axis values

51 vues (au cours des 30 derniers jours)
Happy PhD
Happy PhD le 24 Mai 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 commentaire
Happy PhD
Happy PhD le 24 Mai 2018
Modifié(e) : Happy PhD le 24 Mai 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.

Connectez-vous pour commenter.

Réponse acceptée

Adam
Adam le 24 Mai 2018
Modifié(e) : Adam le 24 Mai 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 commentaires
Happy PhD
Happy PhD le 24 Mai 2018
Modifié(e) : Happy PhD le 24 Mai 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 le 31 Mai 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.

Connectez-vous pour commenter.

Plus de réponses (1)

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

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Produits


Version

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by