An imref2d object encapsulates the relationship
between the intrinsic coordinates anchored to the rows and columns
of a 2-D image and the spatial location of the same row and column
locations in a world coordinate system. The image is sampled regularly
in the planar world-X and world-Y coordinate
system such that intrinsic-X values align with
world-X values, and intrinsic-Y values
align with world-Y values. The pixel spacing from
row to row need not equal the pixel spacing from column to column.
The intrinsic coordinate values (x,y)
of the center point of any pixel are identical to the values of the
column and row subscripts for that pixel. For example, the center
point of the pixel in row 5, column 3 has intrinsic coordinates x =
3.0, y = 5.0. Be aware, however, that the order
of coordinate specification (3.0,5.0) is reversed in intrinsic coordinates
relative to pixel subscripts (5,3). Intrinsic coordinates are defined
on a continuous plane while the subscript locations are discrete locations
with integer values.
Construction
R = imref2d() creates
an imref2d object with default property settings.
R = imref2d(imageSize)
creates an imref2d object given an image size.
This syntax constructs a spatial referencing object for the default
case in which the world coordinate system is co-aligned with the intrinsic
coordinate system.
R = imref2d(imageSize,pixelExtentInWorldX,pixelExtentInWorldY) creates
an imref2d object given an image size and the resolution
in each dimension, specified by pixelExtentInWorldX and pixelExtentInWorldY.
R = imref2d(imageSize,xWorldLimits,yWorldLimits)
creates an imref2d object given an image size and
the world coordinate limits in each dimension, specified by xWorldLimits and yWorldLimits.
Code Generation:imref2d supports
the generation of efficient, production-quality C/C++ code from MATLAB.
When generating code, you can only specify singular objects—arrays
of objects are not supported. To see a complete list of all the list
of toolbox functions that support code generation, see List of Supported Functions with Usage Notes.
Input Arguments
imageSize
Size of the image associated with the object, specified as a
row vector of class double, such as [256
256], as returned by the size function.
pixelExtentInWorldX
Size of a single pixel in X dimension measured
in the world coordinate system, specified as a double.
pixelExtentInWorldY
Size of a single pixel in Y dimension measured
in the world coordinate system, specified as a double.
xWorldLimits
Minimum and maximum coordinate values in X dimension
in world coordinate system, specified as a two-element numeric vector,
such as [0.5 256.5].
yWorldLimits
Minimum and maximum coordinate values in Y in
world coordinate system, specified as a two-element numeric vector,
such as [0.5 256.5].
Properties
ImageExtentInWorldX
Span of image in X dimension in the world
coordinate system, specified as a numeric scalar. The imref2d object
calculates this value as PixelExtentInX * ImageSize(2).
ImageExtentInWorldY
Span of image in Y dimension in the world
coordinate system, specified as a numeric scalar. The imref2d object
calculates this value as PixelExtentInY * ImageSize(1).
ImageSize
Number of elements in each spatial dimension, specified as a
two-element vector, in the same form as that returned by the size function.
PixelExtentInWorldX
Size of a single pixel in X dimension measured
in the world coordinate system, specified as a double.
PixelExtentInWorldY
Size of a single pixel in Y dimension measured
in the world coordinate system, specified as a double.
XWorldLimits
Limits of image in world X dimension, specified
as a two-element row vector [xMin xMax]
YWorldLimits
Limits of image in world Y dimension, specified
as a two-element row vector [yMin yMax].
XIntrinsicLimits
Limits of image in intrinsic units in X dimension,
specified as a two-element row vector [xMin xMax].
For an M-by-N image (or an M-by-N-by-P image)
it equals [0.5, N + 0.5].
YIntrinsicLimits
Limits of image in intrinsic units inY dimension,
specified as a two-element row vector [yMin yMax].
For an M-by-N image (or an M-by-N-by-P image)
it equals [0.5, M + 0.5].
Create an imref2d object associated
with the image, specifying the size of the pixels. The DICOM file
contains a metadata field PixelSpacing that specifies
the image resolution in each dimension in millimeters/pixel.
RA = imref2d(size(A),m.PixelSpacing(2),m.PixelSpacing(1))