Main Content

centerCropWindow3d

Create cuboidal center cropping window

Description

win = centerCropWindow3d(inputSize,targetSize) determines the window to crop from a 3-D input image of size inputSize such that the size of the cropped image is targetSize. The coordinates of the window are centered in the input image.

example

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);

Input Arguments

collapse all

Input image size, specified as one of the following.

Type of Input ImageFormat of inputSize
3-D grayscale or binary image3-element vector of positive integers of the form [height width depth]
3-D RGB or multispectral image4-element vector of positive integers of the form [height width depth channels]

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

Target image size, specified as one of the following.

Type of Target ImageFormat of targetSize
3-D grayscale or binary image3-element vector of positive integers of the form [height width depth]
3-D RGB or multispectral image4-element vector of positive integers of the form [height width depth channels]

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

Output Arguments

collapse all

Cropping window, returned as a Cuboid object.

Version History

Introduced in R2019b