Read a 3-D volume into the workspace. This image consists of 27 frames of 128-by-128 pixel images.

Create an `imref3d`

spatial referencing object associated with the volume. For illustrative purposes, provide a pixel resolution in each dimension. The resolution is in millimeters per pixel.

R =
imref3d with properties:
XWorldLimits: [1 257]
YWorldLimits: [1 257]
ZWorldLimits: [2 110]
ImageSize: [128 128 27]
PixelExtentInWorldX: 2
PixelExtentInWorldY: 2
PixelExtentInWorldZ: 4
ImageExtentInWorldX: 256
ImageExtentInWorldY: 256
ImageExtentInWorldZ: 108
XIntrinsicLimits: [0.5000 128.5000]
YIntrinsicLimits: [0.5000 128.5000]
ZIntrinsicLimits: [0.5000 27.5000]

Select sample points, and store their world *x*-, *y*-, and *z*-coordinates in vectors. For example, the first point has world coordinates (108,92,52), the second point is 3 mm above it in the +*z*-direction, and the third point is 5.2 mm to the right of it in the +*x*-direction. The last point is outside the image boundary.

Convert the world coordinates to row, column, and plane subscripts using `worldToSubscript`

.

The resulting vectors contain the column, row, and plane indices that are closest to the point. Note that the indices are discrete, and that points outside the image boundary have index values of `NaN`

.

Also, the order of the input and output coordinates is reversed. The world *x*-coordinate vector, `xW`

, corresponds to the second output vector, `cS`

. The world *y*-coordinate vector, `yW`

, corresponds to the first output vector, `rS`

.