Read an image and display it. Get the size of the image.
I = imread('pout.tif');
[nrows,ncols] = size(I)
nrows =
291
ncols =
240
Create a spatial referencing object for this image, with default property settings. By default, the upper-left corner of the image has intrinsic coordinate (1,1).
RI = imref2d(size(I));
h = imshow(I,RI);
xData = get(h,'XData')
xData = 1×2
1 240
yData = get(h,'YData')
yData = 1×2
1 291
For illustrative purposes, specify an arbitrary image extent in the x- and y-directions. This example shifts the image up by 20 pixels and to the right by 400 pixels. The example also shifts the image to the right by 100 pixels and compresses the image horizontally by a factor of 2.
n — Number of image rows or columns positive integer
Number of image rows or columns, specified as a positive integer.
n is the number of image columns for the
x-coordinate, or the number of image rows for the
y-coordinate.
extent — Image world extent 2-element numeric vector
Image world extent, specified as a 2-element numeric vector.
extent is returned by
get(image_handle,"XData") or
get(image_handle,"YData").
axesCoord — Axes coordinates to convert numeric vector
Axes coordinate to convert to intrinsic coordinates, specified as a
numeric vector.
Intrinsic coordinates, returned as a numeric vector. If all of the input
arguments are of data type single, then
pixelCoord is of data type
single. Otherwise, pixelCoord is
of data type double.
Data Types: double | single
Tips
axes2pix performs minimal checking on the validity of the
n, axesCoord, or
extent arguments. For example,
axes2pix can extrapolate from extent
to return a negative coordinate. The function calling
axes2pix bears responsibility for error checking.
Extended Capabilities
C/C++ Code Generation Generate C and C++ code using MATLAB® Coder™.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.