Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

axes2pix

Convert axes coordinates to pixel coordinates

Syntax

pixelx = axes2pix(dim, XDATA, AXESX)

Description

pixelx = axes2pix(dim, XDATA, AXESX) converts an axes coordinate into an intrinsic ("pixel") coordinate. For example, if pt = get(gca,'CurrentPoint') then AXESX could be pt(1,1) or pt(1,2). AXESX must be in intrinsic coordinates. XDATA is a two-element vector returned by get(image_handle, 'XData') or get(image_handle,'YData'). dim is the number of image columns for the x coordinate, or the number of image rows for the y coordinate.

Class Support

dim, XDATA, and AXESX can be double. The output is double.

Note

axes2pix performs minimal checking on the validity of AXESX, DIM, or XDATA. For example, axes2pix returns a negative coordinate if AXESX is less than XDATA(1). The function calling axes2pix bears responsibility for error checking.

Examples

collapse all

Display image.

h = imshow('pout.tif');

Get the size of the image.

[nrows,ncols] = size(get(h,'CData'));

Get the image XData and YData.

xdata = get(h,'XData')
xdata = 

     1   240

ydata = get(h,'YData')
ydata = 

     1   291

Convert an axes coordinate into an intrinsic coordinate for the x and y dimensions.

px = axes2pix(ncols,xdata,30)
px = 30
py = axes2pix(nrows,ydata,30)
py = 30

Display image.

h = imshow('pout.tif');

Get the size of the image.

[nrows,ncols] = size(get(h,'CData'));

Specify non-default XData and YData.

xdata = [10 100]
xdata = 

    10   100

ydata = [20 90]
ydata = 

    20    90

Convert the axes coordinate to an intrinsic (pixel) coordinate.

px = axes2pix(ncols,xdata,30)
px = 54.1111
py = axes2pix(nrows,ydata,30)
py = 42.4286

Introduced before R2006a

Was this topic helpful?