Main Content

Resize

Enlarge or shrink image sizes

Library

Geometric Transformations

visiongeotforms

  • Resize block

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

This block supports intensity and color images on its ports. When you input a floating point data type signal, the block outputs the same data type.

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

Port Description

Port Input/Output Supported Data Types Complex Values Supported

Image / Input

M-by-Nmatrix of intensity values or anM-by-N-by-Pcolor video signal wherePis 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 [x y width height] 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

ROI Processing

To resize a particular region of each image, select theEnable ROI processingcheck box. To enable this option, select the following parameter values.

  • Specify=Number of output rows and columns

  • Interpolation method=Nearest neighbor,Bilinear, orBicubic

  • Clear thePerform antialiasing when resize factor is between 0 and 100check box.

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

If you select theEnable ROI processingcheck box, theOutput flag indicating if any part of ROI is outside image boundscheck 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 Output Description
0 ROI is completely inside the input image.
1 ROI 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.

Parameters

Specify

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

When you selectOutput size as a percentage of input size,Resize factor in percentageparameter appears in the dialog box. Enter a scalar percentage value that is applied to both rows and columns.

When you selectNumber of output columns and preserve aspect ratio,Number of output columnsparameter 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.

When you selectNumber of output rows and preserve aspect ratio,Number of output rowsparameter 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.

When you selectNumber of output rows and columns,Number of output rows and columnsparameter 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.

Resize factor in percentage

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 theSpecifyparameter, you selectOutput size as a percentage of input size.

You must enter a scalar value that is greater than zero. The table below describes the affect of the resize factor value:

Resize factor in percentage Resizing of image
0< resize factor <100 The block shrinks the image.
resize factor =100 Image unchanged.
resize factor >100 The block enlarges the image.

The dimensions of the output matrix depend on theResize factor in percentageparameter and are given by the following equations:

number_output_rows = round(number_input_rows*resize_factor/100); (1)
number_output_cols = round(number_input_cols*resize_factor/100); (2)
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 theSpecifyparameter, you selectNumber 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 theSpecifyparameter, you selectNumber 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 theSpecifyparameter, you selectNumber of output rows and columns.

Interpolation method

Specify which interpolation method to resize the image.

When you selectNearest neighbor,block uses one nearby pixel to interpolate the pixel value. This option though the most efficient, is the least accurate. When you selectBilinear,block uses four nearby pixels to interpolate the pixel value. When you selectBicubicorLanczos2,block uses 16 nearby pixels to interpolate the pixel value. When you selectLanczos3,block uses 36 surrounding pixels to interpolate the pixel value.

TheResize块执行啊ptimally when you set this parameter toNearest neighborwith one of the following conditions:

  • You set theResize factor in percentageparameter to a multiple of 100.

  • Dividing 100 by theResize factor in percentageparameter value results in an integer 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 theSpecifyparameter is set toNumber of output rows and columns,Interpolation methodparameter is set toNearest neighbor,Bilinear, orBicubic, and thePerform antialiasing when resize factor is between 0 and 100check 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.

Rounding mode

Select therounding mode为定点操作。

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:

  • When you selectSame as input,word length of the interpolation weights table values match that of the input to the block.

  • When you selectBinary point scaling, you can enter the word length of the interpolation weights table values, in bits.

  • When you selectSlope and bias scaling, you can enter the word length of the interpolation weights table values, in bits.

Product output

描绘在前面的图中,o的输出f 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.

  • When you selectSame as input,se characteristics match those of the input to the block.

  • When you selectBinary point scaling, you can enter the word length and the fraction length of the product output, in bits.

  • When you selectSlope and bias scaling, you can enter the word length, in bits, and the slope of the product output. The bias of all signals in the Computer Vision Toolbox™ blocks is 0.

Accumulator

描绘在前面的图中,输入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.

  • When you selectSame as product output,se characteristics match those of the product output.

  • When you selectSame as input,se characteristics match those of the input to the block.

  • When you selectBinary point scaling, you can enter the word length and the fraction length of the accumulator, in bits.

  • When you selectSlope and bias scaling, you can enter the word length, in bits, and the slope of the accumulator. The bias of all signals in the Computer Vision Toolbox blocks is 0.

Output

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

  • When you selectSame as input,se characteristics match those of the input to the block.

  • When you selectBinary point scaling, you can enter the word length and the fraction length of the output, in bits.

  • When you selectSlope and bias scaling, you can enter the word length, in bits, and the slope of the output. The bias of all signals in the Computer Vision Toolbox blocks is 0.

Lock data type settings against change by the fixed-point tools

Select this parameter to prevent the fixed-point tools from overriding the data types you specify on the block mask. For more information, seefxptdlg(Fixed-Point Designer), a reference page on the Fixed-Point Tool in the Simulink®documentation.

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.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced before R2006a