Main Content

images.spatialref.Cuboid

Spatial extents of 3-D cuboidal region

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.

fullViewPnl = uipanel(figure,'Title','Original Volume');
volshow(D,'Parent',fullViewPnl);

Specify the target size of the cropping window.

targetSize = [64 64 10];

Create a center cropping window that crops the specified 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 in a display panel.

fullViewPnl = uipanel(figure,'Title','Cropped Volume');
volshow(Dcrop,'Parent',fullViewPnl);

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

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

Display the image.

fullViewPnl = uipanel(figure,'Title','Original Volume');
volshow(volumeData,'Parent',fullViewPnl);

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.

fullViewPnl = uipanel(figure,'Title','Cropped Volume');
volshow(croppedVolume,'Parent',fullViewPnl);

Introduced in R2019b