randomCropWindow3d - Create randomized cuboidal cropping window - MATLAB (original) (raw)

Main Content

Create randomized cuboidal cropping window

Syntax

Description

[win](#mw%5Fcdcb0b8c-e3a1-4c9c-bb2f-591986e9a095) = randomCropWindow3d([inputSize](#mw%5Fd104df6c-2bed-4270-9e02-9fe5a528a83c),[targetSize](#mw%5F7389ada8-c42b-482c-b9d7-f3c043a082aa)) 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 selected from a random position in the input image.

example

Examples

collapse all

Read a 3-D MRI volume. Use the squeeze function to remove any singleton dimensions.

load mri; D = squeeze(D);

Display the volume.

Specify the target size of the cropping window.

Create a random crop window that crops the input volume from a randomly-selected position.

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

Crop the volume using the random crop window.

Display the cropped volume.

Input Arguments

collapse all

Input image size, specified as one of the following.

Type of Input Image Format of inputSize
3-D grayscale or binary image 3-element vector of positive integers of the form [height width depth]
3-D RGB or multispectral image 4-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 Image Format of targetSize
3-D grayscale or binary image 3-element vector of positive integers of the form [height width depth]
3-D RGB or multispectral image 4-element vector of positive integers of the form [height width depth channels]

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

Version History

Introduced in R2019b