Main Content

sliceCorners

Extract patient coordinates of corner voxels for one slice

Since R2022b

Description

xyzCorners = sliceCorners(R,slice) extracts the xyz-coordinates of the four corner voxels for one slice of an image volume.

example

Examples

collapse all

Extract the corner coordinates for one slice of the medical spatial referencing object of a chest CT volume, saved as a directory of DICOM files. 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;

Extract the xyz-coordinates, in millimeters, of the corner voxels for the first slice along the third dimension of the volume.

xyzCorners = sliceCorners(R,1)
xyzCorners = 4×3

 -186.5000 -186.5000 -281.2500
 -186.5000  185.7717 -281.2500
  185.7717  185.7717 -281.2500
  185.7717 -186.5000 -281.2500

Input Arguments

collapse all

Spatial referencing information, specified as a medicalref3d object.

Slice index, specified as a positive integer scalar in the range [1, p], where p is the number of slices in the image volume along the third dimension.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

Coordinates of the four corner voxels in the patient coordinate system, returned as a 4-by-3 numeric matrix. Each row contains xyz-coordinates for one corner of the slice, returned in clockwise order:

  1. Pixel in the first row and first column of the data array.

  2. Pixel in the first row and last column of the data array.

  3. Pixel in the last row and last column of the data array.

  4. Pixel in the last row and first column of the data array.

Version History

Introduced in R2022b

See Also