Enlarge or shrink image sizes
Geometric Transformations
visiongeotforms
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 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.
Port | Input/Output | Supported Data Types | Complex 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 |
| No |
ROI | Four-element vector [x y width height] that defines the ROI |
| No |
Output | Resized image | Same as Input port | No |
Flag | Boolean value that indicates whether the ROI is within the image bounds | Boolean | No |
To resize a particular region of each image, select the Enable ROI processing check box. To enable this option, select the following parameter values.
Specify = Number
of output rows and columns
Interpolation method = Nearest
neighbor
, Bilinear
, or Bicubic
Clear the Perform antialiasing when resize factor is between 0 and 100 check box.
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, 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 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 Output | Description |
---|---|
0 | ROI is completely inside the input image. |
1 | ROI is completely or partially outside the input image. |
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.
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
, or Number of output rows and
columns
.
When you select Output size as a percentage of input
size
, the Resize factor in percentage
parameter appears in the dialog box. Enter a scalar percentage value that is
applied to both rows and columns.
When 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.
When 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.
When 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.
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
.
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 the Resize factor in percentage parameter 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) |
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
.
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
.
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
.
Specify which interpolation method to resize the image.
When you select Nearest neighbor
, the block uses one nearby pixel
to interpolate the pixel value. This option though the most efficient, is
the least accurate. When you select Bilinear
, the
block uses four nearby pixels to interpolate the pixel value. When you
select Bicubic
or
Lanczos2
, the block uses 16 nearby pixels to
interpolate the pixel value. When you select
Lanczos3
, the block uses 36 surrounding
pixels to interpolate the pixel value.
The Resize block performs optimally when you set this parameter to
Nearest neighbor
with one of the following
conditions:
You set the Resize factor in percentage parameter to a multiple of 100.
Dividing 100 by the Resize factor in percentage parameter value results in an integer value.
If you select this check box, the block performs low-pass filtering on the input image before shrinking it to prevent aliasing.
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.
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.
Select the rounding mode for fixed-point operations.
Select the overflow mode for fixed-point operations.
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 select Same as input
, the word
length of the interpolation weights table values match that of the
input to the block.
When you select Binary point scaling
,
you can enter the word length of the interpolation weights table
values, in bits.
When you select Slope and bias scaling
,
you can enter the word length of the interpolation weights table
values, in bits.
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.
When you select Same as input
, these
characteristics match those of the input to the block.
When you select Binary point scaling
,
you can enter the word length and the fraction length of the product
output, in bits.
When you select Slope 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.
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.
When you select Same as product output
,
these characteristics match those of the product output.
When you select Same as input
, these
characteristics match those of the input to the block.
When you select Binary point scaling
,
you can enter the word length and the fraction length of the
accumulator, in bits.
When you select Slope 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.
Choose how to specify the word length and fraction length of the output of the block:
When you select Same as input
, these
characteristics match those of the input to the block.
When you select Binary point scaling
,
you can enter the word length and the fraction length of the output,
in bits.
When you select Slope 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.
Select this parameter to prevent the fixed-point tools from overriding the data types
you specify on the block mask. For more information, see fxptdlg
(Fixed-Point Designer), a reference page on the
Fixed-Point Tool in the Simulink® documentation.
[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.