Resize - Enlarge or shrink image sizes

Library

Geometric Transformations

Description

The Resize block enlarges or shrinks an image by resizing the image along one dimension (row or column). Then, it resizes the image along the other dimension (column or row).

PortInput/OutputSupported Data TypesComplex Values Supported

Image / Input

M-by-N matrix of intensity values or an M-by-N-by-P color video signal where P is the number of color planes

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

  • 8-, 16-, 32-bit signed integer

  • 8-, 16-, 32-bit unsigned integer

No

ROI

Four-element vector that defines the ROI

  • Double-precision floating point (only supported if the input to the Input port is floating point)

  • Single-precision floating point (only supported if the input to the Input port is floating point)

  • 8-, 16-, 32-bit signed integer

  • 8-, 16-, 32-bit unsigned integer

No

Output

Resized image

Same as Input port

No

Flag

Boolean value that indicates whether the ROI is within the image bounds

Boolean

No

If the data type of the input signal is floating point, the output has the same data type.

Use the Specify parameter to designate the parameters to use to resize your image. Your choices are Output size as a percentage of input size, Number of output columns and preserve aspect ratio, Number of output rows and preserve aspect ratio, Number of output rows and columns.

If, for the Specify parameter, you select Output size as a percentage of input size, the Resize factor in % parameter appears in the dialog box. Enter a scalar percentage value that is applied to both rows and columns. You must enter a scalar value that is greater than 0. For a 0< resize factor <100, the block shrinks the image. For resize factor =100, the block does not change the image. For resize factor >100, the block enlarges the image. The dimensions of the output matrix depend on the Resize factor in % parameter and are given by the following equations:

number_output_rows = round(number_input_rows*resize_factor/100);

number_output_cols = round(number_input_cols*resize_factor/100);

Alternatively, you can enter a two-element vector, where the first element is the percentage by which to resize the rows and the second element is the percentage by which to resize the columns.

If, for the Specify parameter, you select Number of output columns and preserve aspect ratio, the Number of output columns parameter appears in the dialog box. Enter a scalar value that represents the number of columns you want the output image to have. The block calculates the number of output rows so that the output image has the same aspect ratio as the input image.

If, for the Specify parameter, you select Number of output rows and preserve aspect ratio, the Number of output rows parameter appears in the dialog box. Enter a scalar value that represents the number of rows you want the output image to have. The block calculates the number of output columns so that the output image has the same aspect ratio as the input image.

If, for the Specify parameter, you select Number of output rows and columns, the Number of output rows and columns parameter appears in the dialog box. Enter a two-element vector, where the first element is the number of rows in the output image and the second element is the number of columns. In this case, the aspect ratio of the image can change.

Use the Interpolation method parameter to specify which interpolation method the block uses to resize the image. If you select Nearest neighbor, the block uses one nearby pixel to interpolate the pixel value. This selection is the most computationally efficient, but it is the least accurate. If you select Bilinear, the block uses four nearby pixels to interpolate the pixel value. If you select Bicubic or Lanczos2, the block uses 16 nearby pixels to interpolate the pixel value. If you select Lanczos3, the block uses 36 surrounding pixels to interpolate the pixel value.

The Resize block performs optimally when the Interpolation method parameter is set to Nearest neighbor and one of the following conditions is met:

Shrinking an image can introduce high frequency components into the image and aliasing might occur. If you select the Perform antialiasing when resize factor is between 0 and 100 check box, the block performs low pass filtering on the input image before shrinking it.

ROI Processing

To resize a particular region of each image, select the Enable ROI processing check box. This option is available under these conditions:

If you select the Enable ROI processing check box, the ROI port appears on the block. Use this port to define a region of interest (ROI) in the input matrix, I, that you want to resize. The input to this port must be a four-element vector, [row column height width]. The first two elements define the upper-left corner of the ROI, and the second two elements define the height and width of the ROI.

If you select the Enable ROI processing check box, the Output flag indicating if any part of ROI is outside image bounds check box appears in the dialog box. If you select this check box, the Flag port appears on the block. The following tables describe the Flag port output.

Flag Port OutputDescription
0ROI is completely inside the input image.
1ROI is completely or partially outside the input image.

Fixed-Point Data Types

The following diagram shows the data types used in the Resize block for fixed-point signals.

You can set the interpolation weights table, product output, accumulator, and output data types in the block mask.

Dialog Box

The Main pane of the Resize dialog box appears as shown in the following figure:

Specify

Specify which aspects of the image to resize. Your choices are Output size as a percentage of input size, Number of output columns and preserve aspect ratio, Number of output rows and preserve aspect ratio, Number of output rows and columns.

Resize factor in %

Enter a scalar percentage value that is applied to both rows and columns or a two-element vector, where the first element is the percentage by which to resize the rows and the second element is the percentage by which to resize the columns. This parameter is visible if, for the Specify parameter, you select Output size as a percentage of input size.

Number of output columns

Enter a scalar value that represents the number of columns you want the output image to have. This parameter is visible if, for the Specify parameter, you select Number of output columns and preserve aspect ratio.

Number of output rows

Enter a scalar value that represents the number of rows you want the output image to have. This parameter is visible if, for the Specify parameter, you select Number of output rows and preserve aspect ratio.

Number of output rows and columns

Enter a two-element vector, where the first element is the number of rows in the output image and the second element is the number of columns. This parameter is visible if, for the Specify parameter, you select Number of output rows and columns.

Interpolation method

Determine which interpolation method the block uses to resize the image. If you select Nearest neighbor, the block uses one nearby pixel to interpolate the pixel value. If you select Bilinear, the block uses two nearby pixels to interpolate the pixel value. If you select Bicubic or Lanczos2, the block uses four nearby pixels to interpolate the pixel value. If you select Lanczos3, the block uses six surrounding pixels to interpolate the pixel value.

Perform antialiasing when resize factor is between 0 and 100

If you select this check box, the block performs low-pass filtering on the input image before shrinking it to prevent aliasing.

Enable ROI processing

Select this check box to resize a particular region of each image. This parameter is available when the Specify parameter is set to Number of output rows and columns, the Interpolation method parameter is set to Nearest neighbor, Bilinear, or Bicubic, and the Perform antialiasing when resize factor is between 0 and 100 check box is not selected.

Output flag indicating if any part of ROI is outside image bounds

If you select this check box, the Flag port appears on the block. The block outputs 1 at this port if the ROI is completely or partially outside the input image. Otherwise, it outputs 0.

The Fixed-point pane of the Resize dialog box appears as shown in the following figure.

Rounding mode

Select the rounding mode for fixed-point operations.

Overflow mode

Select the overflow mode for fixed-point operations.

Interpolation weights table

Choose how to specify the word length of the values of the interpolation weights table. The fraction length of the interpolation weights table values is always equal to the word length minus one:

Product output

As depicted in the preceding diagram, the output of the multiplier is placed into the product output data type and scaling. Use this parameter to specify how to designate this product output word and fraction lengths.

Accumulator

As depicted in the preceding diagram, inputs to the accumulator are cast to the accumulator data type. The output of the adder remains in the accumulator data type as each element of the input is added to it. Use this parameter to specify how to designate this accumulator word and fraction lengths.

Output

Choose how to specify the word length and fraction length of the output of the block:

References

[1] Ward, Joseph and David R. Cok. "Resampling Algorithms for Image Resizing and Rotation", Proc. SPIE Digital Image Processing Applications, vol. 1075, pp. 260-269, 1989.

[2] Wolberg, George. Digital Image Warping. Washington: IEEE Computer Society Press, 1990.

See Also

Rotate

Video and Image Processing Blockset software

Shear

Video and Image Processing Blockset software

Translate

Video and Image Processing Blockset software

imresize

Image Processing Toolbox software

  


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