To define a world coordinate system for an image, specify the
YData image properties for the image. The
YData image properties are
two-element vectors that control the range of coordinates spanned by the image. When you
do this, the MATLAB® axis coordinates become identical to the world (nondefault) coordinates.
If you do not specify
YData, the axes
coordinates are identical to the intrinsic coordinates of the image. By default, for an
With this default, the world coordinate system and intrinsic coordinate system coincide
perfectly. (Another way to define a world coordinate system is to use spatial
referencing—see Define World Coordinates Using Spatial Referencing.)
For example, if
A is a 100 row by 200 column image, the default
XData is [1 200], and the default
YData is [1
100]. The values in these vectors are actually the coordinates for the center points of
the first and last pixels (not the pixel edges), so the actual coordinate range spanned
is slightly larger. For instance, if
XData is [1 200], the interval
X spanned by the image is [0.5 200.5].
It is also possible to set
that the x-axis or y-axis is reversed. You would
do this by placing the larger value first. (For example, set the
YData to [1000 1].) This is a common technique to use with
Create an image of a 5-by-5 magic square.
A = magic(5);
Display this image with intrinsic coordinates. Here, the x- and y-coordinate ranges are both [1 5].
image(A) axis image colormap(gca,jet(25)) title('Image Displayed with Intrinsic Coordinates');
Specify nondefault x- and y-coordinate ranges.
x = [19.5 23.5]; y = [8.0 12.0];
Display the image with the nondefault spatial coordinates using the
YData image properties.
image(A,'XData',x,'YData',y) axis image colormap(gca,jet(25)) title('Image Displayed with Nondefault Coordinates');