Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

makeresampler

Create resampling structure

Syntax

R = makeresampler(interpolant,padmethod)
R = makeresampler(Name,Value,...)

Description

example

R = makeresampler(interpolant,padmethod) creates a separable resampler structure for use with 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.

R = makeresampler(Name,Value,...) create a resampler structure that uses a user-written resampler using parameter value pairs.

Examples

collapse all

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

collapse all

Interpolating kernel, specified as character vector or cell array. When you specify a character vector, interpolant can have any of the following values:

Interpolant

Description

'cubic'

Cubic interpolation

'linear'

Linear interpolation

'nearest'

Nearest-neighbor interpolation

If you are using a custom interpolating kernel, you can specify interpolant as a cell array in either of these forms:

{half_width, positive_half}

half_width is a positive scalar designating the half width of a symmetric interpolating kernel. positive_half is a vector of values regularly sampling the kernel on the closed interval [0 positive_half].

{half_width, interp_fcn}

interp_fcn is a function handle that returns interpolating kernel values, given an array of input values in the interval
[0 positive_half].

To specify the interpolation method independently along each dimension, combine both types of interpolant specifications. The number of elements in the cell array must equal the number of transform dimensions. For example, consider the following example of an interpolant value:

{'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 | cell

Method used to assign values to output elements that map outside the input array, specified as one of the following character vectors.

Pad Method

Description

'bound'

Assigns values from the fill value array to points that map outside the input array. Repeats border elements of the array for points that map inside the array (same as 'replicate'). When interpolant is 'nearest', this pad method produces the same results as 'fill'. 'bound' is like 'fill', but avoids mixing fill values and input image values.

'circular'

Pads array with circular repetition of elements within the dimension. Same as padarray.

'fill'

Generates 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 interpolant is 'nearest', this pad method produces the same results as 'bound'.

'replicate'

Pads array by repeating border elements of array. Same as padarray.

'symmetric'

Pads array with mirror reflections of itself. Same as padarray.

For 'fill', 'replicate', 'circular', or 'symmetric', the resampling performed by tformarray occurs in two logical steps:

  1. Pad the array A infinitely to fill the entire input transform space.

  2. 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

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: resamp = makeresampler('Type','separable','Interpolant','linear','PadMethod','fill');

collapse all

Resampler type, specified as one of the following character vectors.

TypeDescription
'separable'Create a separable resampler. If you specify this value, the only other properties 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' properties and, optionally, the 'CustomData' property.

Data Types: char

See the padmethod argument for more information.

Data Types: char

See the interpolant argument for more information.

Data Types: char | cell

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

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

User-defined data, specified using a numeric array or character vector.

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

Output Arguments

collapse all

Resampler, returned as a structure.

See Also

Introduced before R2006a

Was this topic helpful?