makeresampler
Create resampling structure
Description
creates a separable resampler structure for use with R
= makeresampler(interpolant
,padMethod
)tformarray
. The
interpolant
argument specifies the interpolating kernel
that the separable resampler uses. The padMethod
argument
controls how the resampler interpolates or assigns values to output elements that
map close to or outside the edge of the input array.
creates a user-written resampler using name-value arguments.R
= makeresampler(Name,Value
)
Examples
Use Separable Resampler to Stretch an Image in the Y Direction
Read an image into the workspace and display it.
A = imread('moon.tif');
imshow(A)
Create a separable resampler.
resamp = makeresampler({'nearest','cubic'},'fill');
Create a spatial transformation structure (TFORM) that defines an affine transformation.
stretch = maketform('affine',[1 0; 0 1.3; 0 0]);
Apply the transformation, specifying the custom resampler.
B = imtransform(A,stretch,resamp);
Display the transformed image.
imshow(B)
Input Arguments
interpolant
— Interpolation kernel
"cubic"
| "linear"
| "nearest"
| cell array
Interpolation kernel, specified as "nearest"
,
"linear"
, "cubic"
, or a cell
array. These kernels perform nearest-neighbor, bilinear, bicubic, and custom
interpolation, respectively.
Define a custom interpolation kernel as a two-element cell array in either of these forms:
Form | Description |
---|---|
|
|
|
|
You can define the interpolation method independently along each transform
dimension by specifying a cell array whose number of elements is equal to
the number of transform dimensions. Each element of the cell array must be
one of the prior types of interpolant kernels. For example, consider this
value of interpolant
for a 3-D interpolation
kernel:
{"nearest","linear",{2 KERNEL_TABLE}}
In this example, the resampler uses nearest-neighbor interpolation along the first transform dimension, linear interpolation along the second dimension, and custom table-based interpolation along the third.
Data Types: char
| string
| cell
padMethod
— Pad method
"bound"
| "circular"
| "replicate"
| "symmetric"
| "fill"
Pad method used to assign values to output elements that map outside the input array, specified as one of these values.
Pad Method | Description |
---|---|
| Assign values from the fill value array to points
that map outside the input array. Repeat border elements
of the array for points that map inside the array (same
as |
| Pad array with circular repetition of elements
within the dimension. Same as |
| Generate an output array with smooth-looking edges
(except when using nearest-neighbor interpolation). For
output points that map near the edge of the input array
(either inside or outside), it combines input image and
fill values. When |
| Pad array by repeating border elements of array.
Same as |
| Pad array with mirror reflections of itself. Same
as |
For "fill"
, "replicate"
,
"circular"
, or "symmetric"
, the
resampling performed by tformarray
occurs in two logical
steps:
Pad the array
A
infinitely to fill the entire input transform space.Evaluate the convolution of the padded
A
with the resampling kernel at the output points specified by the geometric map.
Each nontransform dimension is handled separately. The padding is virtual (accomplished by remapping array subscripts) for performance and memory efficiency. If you implement a custom resampler, you can implement these behaviors.
Data Types: char
| string
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: "Type","separable"
creates a separable resampler
Type
— Resampler type
"separable"
| "custom"
Resampler type, specified as one of the following values.
Type | Description |
---|---|
"separable" | Create a separable resampler. If you specify this value, the only other arguments that you
can specify are Interpolant and
PadMethod . The result is
equivalent to using the
makeresampler(interpolant,padMethod)
syntax. |
"custom" | Create a customer resampler. If you specify this value, you must specify the
NDims and
ResampleFcn arguments and,
optionally, the CustomData
argument. |
Data Types: char
| string
PadMethod
— Pad method
character vector | string scalar
See the padMethod
argument for more
information.
Data Types: char
| string
Interpolant
— Interpolation kernel
character vector | string scalar | cell array
See the interpolant
argument for more
information.
Data Types: char
| string
| cell
NDims
— Dimensionality custom resampler can handle
positive integer
Dimensionality custom resampler can handle, specified as a positive integer. Use a value of
Inf
to indicate that the custom resampler can
handle any dimension. If "Type"
is
"custom"
, you must specify
NDims
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
ResampleFcn
— Function that performs the resampling
function handle
Function that performs the resampling, specified as a function handle. You call this function with the following interface:
B = resample_fcn(A,M,TDIMS_A,TDIMS_B,FSIZE_A,FSIZE_B,F,R)
For more information about the input arguments to this function,
see the help for tformarray
.
The argument M
is an array that maps the transform
subscript space of B
to the transform subscript
space of A
. If A
has N
transform
dimensions (N = length(TDIMS_A))
and B
has P
transform
dimensions (P = length(TDIMS_B))
, then ndims(M)
= P + 1
, if N > 1
and P
if N
== 1
, and size(M,P + 1) = N
.
The first P
dimensions of M
correspond
to the output transform space, permuted according to the order in
which the output transform dimensions are listed in TDIMS_B
.
(In general TDIMS_A
and TDIMS_B
need
not be sorted in ascending order, although some resamplers can impose
such a limitation.) Thus, the first P
elements
of size(M)
determine the sizes of the transform
dimensions of B
. The input transform coordinates
to which each point is mapped are arrayed across the final dimension
of M
, following the order given in TDIMS_A
. M
must
be double
. FSIZE_A
and FSIZE_B
are
the full sizes of A
and B
, padded
with 1
's as necessary to be consistent with TDIMS_A
, TDIMS_B
,
and size(A)
.
Data Types: function_handle
CustomData
— User-defined data
numeric array | string scalar | character vector
User-defined data, specified using a string scalar, character vector, or numeric array.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
| char
| string
Output Arguments
R
— Resampler
structure
Resampler, returned as a structure.
Extended Capabilities
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced before R2006aR2021b: Support for thread-based environments
makeresampler
now supports thread-based
environments.
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)