Main Content

resizem

(Removed) Resize regular data grid

resizem has been removed. Use the georesize or imresize function instead. For more information, see Compatibility Considerations.

Description

example

Zscaled = resizem(Z,scale) returns a regular data grid Zscaled that is scale times the size of the input, Z. resizem uses interpolation to resample to a new sample density (cell size). By default, resizem uses nearest neighbor interpolation.

Zscaled = resizem(Z,[numrows numcols]) resizes Z to have numrows rows and numcols columns.

[Zscaled,Rscaled] = resizem(Z,scale,R) and

[Zscaled,Rscaled] = resizem(Z,[numrows numcols],R) resizes a regular data grid that is spatially referenced by R.

[___] = resizem(___,method) specifies alternate interpolation methods.

[___] = resizem(___,method,n) applies a low-pass filter of size n-by-n before bilinear or bicubic interpolation to reduce aliasing.

[___] = resizem(___,h) applies 2-D FIR filter h to the data grid before resizing, for all interpolation methods.

Examples

collapse all

Define a sample data grid.

Z = [1 2; 3 4]
Z = 2×2

     1     2
     3     4

Double the size of the grid using nearest neighbor interpolation.

neargrid = resizem(Z,2)
neargrid = 4×4

     1     1     2     2
     1     1     2     2
     3     3     4     4
     3     3     4     4

Double the size of the grid using bilinear interpolation.

bilingrid = resizem(Z,2,'bilinear')
bilingrid = 4×4

    1.0000    1.3333    1.6667    2.0000
    1.6667    2.0000    2.3333    2.6667
    2.3333    2.6667    3.0000    3.3333
    3.0000    3.3333    3.6667    4.0000

Resize the grid to have three rows and two columns using bicubic interpolation.

bicubgrid = resizem(bilingrid,[3 2],'bicubic')
bicubgrid = 3×2

    0.7406    1.2994
    1.6616    2.3462
    1.9718    2.5306

Input Arguments

collapse all

Regular data grid, specified as an M-by-N numeric array that may contain NaN values. Z is either a georeferenced data grid, or a regular data grid associated with a geographic reference R.

Resizing scale factor, specified as a positive scalar. If scale is between 0 and 1, then the size of Zscaled is smaller than the size of Z. If scale is greater than 1, then the size of Zscaled is larger. For example, if scale is 0.5, then the number of rows and the number of columns are halved.

Output grid size, specified as a 1-by-2 vector of positive integers.

Geographic reference, specified as one of the following. For more information about referencing vectors and matrices, see Georeferenced Raster Data.

TypeDescription
Geographic raster reference object

GeographicCellsReference geographic raster reference object that relates the subscripts of Z to geographic coordinates. The RasterSize property must be consistent with the size of the data grid, size(Z). The RasterInterpretation must be 'cells'.

Vector

1-by-3 numeric vector with elements:

[cells/degree northern_latitude_limit western_longitude_limit]

Note

When R is a referencing vector, then the argument [nrows ncols] is not supported and the resizing factor scale must be a scalar.

Matrix

3-by-2 numeric matrix that transforms raster row and column indices to or from geographic coordinates according to:

[lon lat] = [row col 1] * R

R defines a (non-rotational, non-skewed) relationship in which each column of the data grid falls along a meridian and each row falls along a parallel. Nearest-neighbor interpolation is used by default. NaN is returned for points outside the grid limits or for which lat or lon contain NaN. All angles are in units of degrees.

Interpolation method, specified as one of the following.

MethodDescription
'nearest'Nearest neighbor interpolation
'bilinear'Bilinear interpolation
'bicubic'Bicubic interpolation

Note

If the grid size is being reduced (that is, when scale is less than 1 or [numrows numcols] is less than the size of the input grid) and method is 'bilinear' or 'bicubic', then resizem applies a low-pass filter before interpolation to reduce aliasing. The default filter size is 11-by-11. You can specify a different length for the default filter using the n argument. You can specify a nondefault filter using the h argument.

Data Types: char | string

Low-pass filter size, specified as a nonnegative integer. The filter size is n-by-n. If n is 0, or if method is 'nearest', then resizem does not perform low-pass filtering.

2-D FIR filter, specified as a numeric matrix. You can define a FIR filter using Image Processing Toolbox™ functions such as ftrans2 (Image Processing Toolbox), fwind1 (Image Processing Toolbox), fwind2 (Image Processing Toolbox), or fsamp2 (Image Processing Toolbox).

Output Arguments

collapse all

Rescaled data grid, returned as a numeric array.

Rescaled geographic reference, returned as a geographic raster reference object, numeric vector, or numeric matrix, consistent with the format of R.

Version History

Introduced before R2006a

expand all

R2023b: Removed

Some functions that accept referencing vectors or referencing matrices as input have been removed, including the resizem function. Use a geographic reference object and the georesize function instead. If your data is not geographically referenced, then use the imresize function instead. Reference objects have several advantages over referencing vectors and matrices.

  • Unlike referencing vectors and matrices, reference objects have properties that document the size of the associated raster, its geographic limits, and the direction of its rows and columns. For more information about reference object properties, see the GeographicCellsReference and GeographicPostingsReference objects.

  • You can manipulate the limits of geographic rasters associated with reference objects using the geocrop function.

  • You can manipulate the size and resolution of geographic rasters associated with reference objects using the georesize function.

To update your code, first create a reference object for either a raster of cells using the georefcells function or a raster of regularly posted samples using the georefpostings function. Alternatively, convert from a referencing vector or referencing matrix to a reference object using the refvecToGeoRasterReference or refmatToGeoRasterReference function, respectively.

Then, replace uses of the resizem function with the georesize function. This table shows typical uses of the resizem function and how to update your code to use the georesize function instead. Note that the default method of interpolation for the georesize function is 'cubic' instead of 'nearest'.

RemovedRecommended
[B,RB] = resizem(A,scale,R);
[B,RB] = georesize(A,R,scale,'nearest');
[B,RB] = resizem(A,[numrows numcols],R);
latscale = numrows / R.RasterSize(1);
lonscale = numcols / R.RasterSize(2);
[B,RB] = georesize(A,R,latscale,lonscale,'nearest');
[B,RB] = resizem(A,scale,R,method);
[B,RB] = georesize(A,R,scale,method);
[B,RB]  = resizem(A,[numrows numcols],R,method);
latscale = numrows / R.RasterSize(1);
lonscale = numcols / R.RasterSize(2);
[B,RB] = georesize(A,R,latscale,lonscale,method);

If your data is not geographically referenced, then use the imresize function instead. This table shows typical uses of the resizem function without reference object information and how to update your code to use the imresize function instead.

RemovedRecommended
B = resizem(A,scale,R);
B = imresize(A,scale);
B = resizem(A,[numrows numcols],R);
B = imresize(A,[numrows numcols]);
B = resizem(A,scale,R,method);
B = imresize(A,scale,method);
B = resizem(A,[numrows numcols],R,method);
B = imresize(A,[numrows numcols],method);