# intrinsicToWorld

## Description

`[`

maps points from the intrinsic coordinate system to the patient coordinate system using the
spatial referencing information, `X`

,`Y`

,`Z`

] = intrinsicToWorld(`R`

,`I`

,`J`

,`K`

)`R`

. The intrinsic coordinates
`I`

, `J`

, and `K`

are defined by
axes aligned with the row, column, and slice subscripts of the image data array,
respectively. The patient coordinates `X`

, `Y`

, and
`Z`

are defined by the patient coordinate system axes.

## Examples

### Map 3-D Intrinsic Coordinates to Patient Coordinates

Map 3-D intrinsic coordinates from a chest CT volume, saved as a directory of DICOM files, to patient coordinates. The volume is part of a data set containing three CT volumes. The size of the entire data set is approximately 81 MB. Download the data set from the MathWorks® website, then unzip the folder.

zipFile = matlab.internal.examples.downloadSupportFile("medical","MedicalVolumeDICOMData.zip"); filepath = fileparts(zipFile); unzip(zipFile,filepath)

Specify the directory of the DICOM files for the first CT volume in the data set.

dataFolder = fullfile(filepath,"MedicalVolumeDICOMData","LungCT01");

Create a medical volume object that contains the image and spatial metadata for the CT volume.

medVol = medicalVolume(dataFolder);

The `VolumeGeometry`

property of the medical volume object contains a `medicalref3d`

object that specifies the spatial referencing for the volume. Extract the `medicalref3d`

object for the chest CT.

R = medVol.VolumeGeometry;

Select three sample points, and store their (*i*, *j*, *k*) intrinsic coordinates, in voxels. The points must fall within the image boundary.

I = [54 200 512]; J = [46 48 79]; K = [1 13 88];

Convert the intrinsic coordinates to patient coordinates. The output vectors provide the (*x*, *y*, *z*) patient coordinates, in millimeters.

[X,Y,Z] = intrinsicToWorld(R,I,J,K)

`X = `*1×3*
-147.8887 -41.5253 185.7717

`Y = `*1×3*
-153.7168 -152.2597 -129.6758

`Z = `*1×3*
-281.2500 -251.2500 -63.7500

## Input Arguments

`R`

— Spatial referencing information

`medicalref3d`

object

Spatial referencing information, specified as a `medicalref3d`

object.

`I`

— Coordinates along *i*-dimension in intrinsic coordinate system

numeric array

Coordinates along the *i*-dimension in the intrinsic coordinate
system, specified as a numeric array. The *i*-axis is aligned with the
first dimension of the spatial volume specified by `R`

.

`I`

, `J`

, and `K`

must be the
same size.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

`J`

— Coordinates along *j*-dimension in intrinsic coordinate system

numeric array

Coordinates along the *j*-dimension in the intrinsic coordinate
system, specified as a numeric array. The *j*-axis is aligned with the
second dimension of the spatial volume specified by `R`

.

`I`

, `J`

, and `K`

must be the
same size.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

`K`

— Coordinates along *k*-dimension in intrinsic coordinate system

numeric array

Coordinates along the *k*-dimension in the intrinsic coordinate
system, specified as a numeric array. The *k*-axis is aligned with the
third dimension of the spatial volume specified by `R`

.

`I`

, `J`

, and `K`

must be the
same size.

**Data Types: **`single`

| `double`

| `int8`

| `int16`

| `int32`

| `int64`

| `uint8`

| `uint16`

| `uint32`

| `uint64`

## Output Arguments

`X`

— Coordinates along *x*-dimension in patient coordinate system

numeric array

Coordinates along the *x*-dimension in the patient coordinate
system, returned as a numeric array. `X`

is the same size as
`I`

.

**Data Types: **`double`

`Y`

— Coordinates along *y*-dimension in patient coordinate system

numeric array

Coordinates along the *y*-dimension in the patient coordinate
system, returned as a numeric array. `Y`

is the same size as
`I`

.

**Data Types: **`double`

`Z`

— Coordinates along *z*-dimension in patient coordinate system

numeric array

Coordinates along the *z*-dimension in the patient coordinate
system, returned as a numeric array. `Z`

is the same size as
`I`

.

**Data Types: **`double`

## Version History

**Introduced in R2022b**

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

# Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

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.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)