Main Content

Cuboid

Spatial extents of 3-D cuboidal region

Since R2019b

Description

A Cuboid object stores the spatial extents of a 3-D volumetric image.

Creation

You can create a Cuboid object in several ways.

  • centerCropWindow3d— Create a Cuboid of a specified size whose position is centered on an image.

  • randomCropWindow3d— Create a Cuboid of a specified size whose position is selected randomly from inside an image.

  • Running the command

    c = images.spatialref.Cuboid(XLimits,YLimits,ZLimits);
    creates a Cuboid object and sets the XLimits, YLimits, and ZLimits properties.

Properties

expand all

Minimum and maximum limits of the cropping window along thex-axis, specified as a 2-element numeric vector of the form [min max], where max is greater than min.

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

Minimum and maximum limits of the cropping window along they-axis, specified as a 2-element numeric vector of the form [min max], where max is greater than min.

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

Minimum and maximum limits of the cropping window along thez-axis, specified as a 2-element numeric vector of the form [min max], where max is greater than min.

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

Examples

collapse all

Load a 3-D MRI image. Use the squeeze function to remove any singleton dimensions.

load mri;
D = squeeze(D);

Display the image.

volshow(D);

Specify the target size of the cropping window.

targetSize = [64 64 10];

Create a center cropping window that crops an image from its center.

win = centerCropWindow3d(size(D),targetSize);

Crop the image using the center cropping window.

Dcrop = imcrop3(D,win);

Display the cropped image.

volshow(Dcrop);

Load a 3-D MRI image. Use the squeeze function to remove any singleton dimensions.

load('mri.mat','D');
volumeData = squeeze(D);

Display the image.

volshow(volumeData);

Create a Cuboid object and specify the cropping window size in all three dimensions.

c = images.spatialref.Cuboid([30,90],[30,90],[1,20]);

Crop the image based on the Cuboid dimensions.

croppedVolume = imcrop3(volumeData,c);

Display the cropped image.

volshow(croppedVolume);

Version History

Introduced in R2019b