Resize 3-D volumetric intensity image
returns the volume B
= imresize3(V
,[numrows
numcols numplanes]
)B
that has the number of rows, columns, and
planes specified by the 3-element vector [numrows numcols
numplanes]
.
returns a resized volume where B
= imresize3(___,Name,Value
)Name,Value
pairs control aspects
of the operation.
Read MRI volume into the workspace.
s = load('mri');
mriVolumeOriginal = squeeze(s.D);
sizeO = size(mriVolumeOriginal);
Visualize the volume.
figure; slice(double(mriVolumeOriginal),sizeO(2)/2,sizeO(1)/2,sizeO(3)/2); shading interp, colormap gray; title('Original');
Resize the volume, reducing the size all all dimensions by one-half. This example uses the default interpolation method and antialiasing.
mriVolumeResized = imresize3(mriVolumeOriginal, 0.5); sizeR = size(mriVolumeResized);
Visualize the resized volume.
figure; slice(double(mriVolumeResized),sizeR(2)/2,sizeR(1)/2,sizeR(3)/2); shading interp, colormap gray; title('Resized');
V
— Volume to be resizedVolume to be resized, specified as a 3-D numeric array or 3-D categorical array.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| categorical
scale
— Scale factorScale factor, specified as a numeric scalar.
If scale
is less than 1, then the output
image is smaller than the input volume.
If scale
is greater than 1, then the
output image is larger than the input volume.
imresize3
applies the scale factor to each dimension in
the volume. To apply a different resize factor to each dimension, use the
Scale
name-value pair argument.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
[numrows numcols numplanes]
— Size of output volumeSize of output volume, specified as a 3-element vector of positive integers in the form
[rows columns planes]
. If you specify one numeric
value and the other two values as NaN
s, then
imresize3
computes the other two elements
automatically to preserve the aspect ratio.
Data Types: single
| double
method
— Interpolation method'nearest'
| 'linear'
| 'box'
| 'triangle'
| 'lanczos2'
| 'lanczos3'
Interpolation method, specified as one of the values in the following table that identifies a general method or a named interpolation kernel.
Method | Description |
---|---|
| Nearest-neighbor interpolation. Nearest-neighbor interpolation is the only interpolation method supported for categorical images and it is the default method for images of this type. |
| Linear interpolation |
| Cubic interpolation. Cubic interpolation is the default for numeric volumes. Note Cubic interpolation can produce pixel values outside the original range. |
Interpolation Kernel | Description |
'box' | Box-shaped kernel. The box-shaped kernel is the only interpolation kernel supported for categorical images. |
'triangle' | Triangular kernel (equivalent to 'linear' ) |
'lanczos2' | Lanczos-2 kernel |
'lanczos3' | Lanczos-3 kernel |
Data Types: char
| string
Specify optional
comma-separated pairs of Name,Value
arguments. Name
is
the argument name and Value
is the corresponding value.
Name
must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN
.
mriVolumeResized =
imresize3(mristack,0.5,'Antialiasing',false);
'Antialiasing'
— Perform antialiasing when shrinking a volumetrue
| false
Perform antialiasing when shrinking a volume, specified as the
comma-separated pair consisting of 'Antialiasing'
and
true
or false
.
If method
is
'nearest'
, then the default value of
'Antialiasing'
is
false
.
If the interpolation method
is the
'box'
interpolation kernel and the
input volume is categorical, then the default value of
'Antialiasing'
is
false
.
For all other interpolation methods, the default value of
'Antialiasing'
is
true
.
Data Types: logical
'Method'
— Interpolation method'cubic'
(default) | character vectorInterpolation method, specified as the comma-separated pair consisting of
'Method'
and string scalar or character vector.
For details, see method
.
Data Types: char
| string
'OutputSize'
— Size of output volumeSize of the output volume, specified as the comma-separated pair consisting of
'OutputSize'
and a 3-element vector of positive
integers of the form [rows cols planes]
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
'Scale'
— Resize scale factorResize scale factor, specified as the comma-separated pair consisting
of 'Scale'
and a positive number or 3-element vector
of positive numbers. If you specify a scalar, then
imresize3
applies the same scale factor to each
dimension in the volume. If you specify a 3-element vector, then
imresize3
applies a different scale value to each
dimension.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
B
— Resized volumeResized volume, returned as an array of the same class as the input volume,
V
.
You have a modified version of this example. Do you want to open this example with your edits?