dlresize
Syntax
Description
resizes the spatial dimensions of the Y
= dlresize(X
,'OutputSize',outputSize
)dlarray
object X
so that the spatial dimension sizes are equal to outputSize
.
adjusts the resizing operation using name-value pair arguments. If Y
= dlresize(___,Name,Value
)X
is
not a formatted dlarray
, then you must specify the
DataFormat
name-value pair argument.
Examples
Resize dlarray by Scale Factor
Read an RGB image.
A = imread('peppers.png');
Convert the image to data type single
for use in a dlarray
. Then, create a dlarray
containing the input image.
A = im2single(A);
dlarrayA = dlarray(A,'SSC');
Rescale the dlarray
by a factor of 1.5 vertically.
dlarrayB = dlresize(dlarrayA,'Scale',[1.5 1]);
Extract the image data from the resized dlarray
B
by using the extractdata
(Deep Learning Toolbox) function.
B = extractdata(dlarrayB);
Display the original and resized images as a montage.
montage({A,B},"ThumbnailSize",size(B,[1 2]), ... "BorderSize",10,"BackgroundColor","white")
Input Arguments
X
— Deep learning array to resize
dlarray
object
Deep learning array to resize, specified as a dlarray
(Deep Learning Toolbox)
object.
scale
— Scale factor to resize input
positive number | vector of positive numbers
Scale factor to resize input, specified as a positive number or a vector of positive
numbers of length equal to the number of spatial dimensions in X
.
If scale
is a scalar, then dlresize
applies
the same scale factor to all spatial dimensions.
outputSize
— Output size of resized input
vector of positive integers
Output size of resized input, specified as a vector of positive integers of length
equal to the number of spatial dimensions in X
. You can specify one
element as a positive integer and specify the other elements as NaN, in which case the
layer computes the other elements automatically to preserve the aspect ratio of the
input.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: 'Method',linear
DataFormat
— Dimension labels
string scalar | character vector
Dimension labels of the input dlarray
object
X
, specified as the comma-separated pair consisting of
'DataFormat'
and a string scalar or character vector. Each
character must be one of these labels:
S
— SpatialC
— ChannelB
— Batch observationsT
— Time or sequenceU
— Unspecified
If X
is not a formatted dlarray
, then you
must specify the DataFormat
name-value pair argument. For more
information, see dlarray
(Deep Learning Toolbox).
Example: 'SSC'
indicates the array has two spatial dimensions
and one channel dimension, appropriate for 2-D RGB image data.
Method
— Interpolation method
"nearest"
(default) | "linear"
Interpolation method, specified as the comma-separated pair consisting of
'Method'
and "nearest"
for nearest neighbor
interpolation or "linear"
for bilinear interpolation.
GeometricTransformMode
— Geometric transformation mode
"half-pixel"
(default) | "asymmetric"
Geometric transformation mode to map points from input space to output space,
specified as the comma-separated pair consisting of
'GeometricTransformMode'
and "half-pixel"
or
"asymmetric"
.
NearestRoundingMode
— Rounding mode for nearest neighbor interpolation
"round"
(default) | "floor"
| "onnx-10"
Rounding mode for nearest neighbor interpolation, specified as the comma-separated
pair consisting of 'NearestRoundingMode'
and one of the following.
This argument is used when you specify the Method
as
'nearest'
.
Output Arguments
Y
— Resized deep learning array
dlarray
object
Resized deep learning array, returned as a dlarray
(Deep Learning Toolbox)
object.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
dlarray
inputs with more than 3 spatial (S) dimensions are not supported.Code generation supports variable-size data for only the spatial (S) dimension of the
dlarray
input.For a
dlarray
input with more than one spatial dimension, all spatial dimensions must be fixed-size or all variable-size.DataFormat
must be compile-time constant.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Usage notes and limitations:
dlarray
inputs with more than 3 spatial (S) dimensions are not supported.Code generation supports variable-size data for only the spatial (S) dimension of the
dlarray
input.For a
dlarray
input with more than one spatial dimension, all spatial dimensions must be fixed-size or all variable-size.DataFormat
must be compile-time constant.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Image Processing on a GPU.
Version History
Introduced in R2020bR2024a: Generate CUDA code using GPU Coder
dlresize
now supports the generation of
optimized CUDA® code (requires GPU Coder™).
R2024a: Generate C code using MATLAB Coder
dlresize
now supports the generation of
C code (requires MATLAB
Coder™).
See Also
dlarray
(Deep Learning Toolbox) | maxpool
(Deep Learning Toolbox) | dltranspconv
(Deep Learning Toolbox)
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)