Products & Services Solutions Academia Support User Community Company

Learn more about Mapping Toolbox   

resizem - Resize regular data grid

Syntax

Z = resizem(Z1, scale)
Z = resizem(Z1, [numrows numcols])
[Z, R] = resizem(Z1, scale, R1)
[Z, R] = resizem(Z1, [numrows numcols], R1)
[...] = resizem(..., method)

Description

Z = resizem(Z1, scale) returns a regular data grid Z that is scale times the size of the input, Z1. resizem uses interpolation to resample to a new sample density/cell size. If scale is between 0 and 1, the size of Z is smaller than the size of Z1. If scale is greater than 1, the size of Z is larger. For example, if scale is 0.5, the number of rows and the number of columns will be halved. By default, resizem uses nearest neighbor interpolation.

Z = resizem(Z1, [numrows numcols]) resizes Z1 to have numrows rows and numcols columns. numrows and numcols must be positive whole numbers.

[Z, R] = resizem(Z1, scale, R1) or [Z, R] = resizem(Z1, [numrows numcols], R1) resizes a regular data grid with a referencing vector or matrix, R1, and returns a new grid and its referencing vector or matrix, R. R1 is either a 1-by-3 vector containing elements:

[cells/degree northern_latitude_limit western_longitude_limit]

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

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

If R1 is a referencing matrix, it must define 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. If R1 is a referencing vector, then R is a referencing vector. Likewise, if R1 is a referencing matrix, then R is a referencing matrix. If R1 is a referencing vector, then scale must be a scalar resizing factor; the form [numrows numcols] is supported only for referencing matrices.

[...] = resizem(..., method) resizes a regular data grid using one of the following three interpolation methods:

MethodDescription
'nearest'nearest neighbor interpolation (default)
'bilinear'bilinear interpolation
'bicubic'bicubic interpolation

If the grid size is being reduced (scale is less than 1 or [numrows numcols] is less than the size of the input grid) and method is 'bilinear' or 'bicubic', 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:

[...] = resizem(..., method, n)

n is an integer scalar specifying the size of the filter, which is n-by-n. If n is 0 or method is 'nearest', resizem omits the filtering step. You can also specify your own filter h using:

[...] = resizem(..., method, h)

h is any two-dimensional FIR filter (such as those returned by Image Processing Toolbox functions ftrans2, fwind1, fwind2, or fsamp2). If H is specified, filtering is applied even when method is 'nearest'.

Example

Double the size of a grid then reduce it using different methods:

Z = [1 2; 3 4]

Z = 
      1  2
      3  4

neargrid = resizem(Z,2)

neargrid = 
      1  1  2  2
      1  1  2  2
      3  3  4  4
      3  3  4  4

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

bilingrid =
    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

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

bicubgrid =
    0.7406    1.2994
    1.6616    2.3462
    1.9718    2.5306

See Also

filter2 (MATLAB function)

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS