Main Content

visionhdl.ImageResizer

Change dimensions of image in a pixel stream

Since R2023a

Description

The visionhdl.ImageResizer System object™ downscales grayscale input images. The horizontal and vertical scale factors are independent and you can optionally specify input and output sizes in real time. The object provides an optional antialiasing filter, and you can choose nearest-neighbor or bilinear interpolation.

You can use this System object for image resize operations such as:

  • Converting images to a uniform size for input to deep learning algorithms

  • Modifying disparate source videos for processing, resource, or display requirements

To change the dimensions of an image in a pixel stream:

  1. Create the visionhdl.ImageResizer object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

resizer = visionhdl.ImageResizer(Name=Value) returns a System object that resizes the active image in a pixel stream. Set properties using one or more name-value arguments. For example, InputSize=[48,48],OutputSize=[18,32] specifies an input image of 48-by-48 pixels and an output image resized to 18-by-32 pixels.

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Dimensions of the input frame, specified as a row vector of the form [ActiveVideoLines,ActivePixelsPerLine]. The dimensions must be integers greater than or equal to [16,16] and less than or equal to [4320,8192].

Source of the input active frame size, specified as one of these options:

  • 'Property' — Specify the input size by using the InputSize property.

  • 'Input port' — Specify the input size by using the inputSize input argument. The object samples the inputSize and outputSize arguments when vStart is true in the input control structure.

Dependencies

To enable this property, set the InputSizeSource property to 'Property'.

Dimensions of the largest anticipated input frame, specified as a row vector of the form [ActiveVideoLines,ActivePixelsPerLine]. The dimensions must be integers greater than or equal to [16,16] and less than or equal to [4320,8192].

Dependencies

This property applies when you set the InputSizeSource property to 'Input port'.

Dimensions of the output frame, specified as a matrix of the form [ActiveVideoLines,ActivePixelsPerLine]. The dimensions must be integers greater than or equal to [16,16] and less than or equal to [4320,8192].

The output dimensions must be less than or equal to the input dimensions.

Dependencies

To enable this property, set the OutputSizeSource property to 'Property'.

Source of the output active frame size, specified as one of these options:

  • 'Property' — Specify the output size by using the OutputSize property.

  • 'Input port' — Specify the output size by using the outputSize input argument. The object samples the inputSize and outputSize arguments when vStart is true in the input control structure.

Dimensions of the largest anticipated output frame, specified as a row vector of the form [ActiveVideoLines,ActivePixelsPerLine]. The dimensions must be integers greater than or equal to [16,16] and less than or equal to [4320,8192].

Dependencies

This property applies when you set the InputSizeSource property to 'Input port'.

The horizontal blanking interval is the period of inactive cycles between the end of one line and the beginning of the next line. When you set this property to true, the object includes a buffer to store the output pixels while inserting extra horizontal blanking cycles between the active lines of the output video stream. Set the number of blanking cycles in the MinOutputHorizontalBlanking property. For information on when to use horizontal blanking, see Configure Blanking Intervals.

The horizontal blanking interval is the period of inactive cycles between the end of one line and the beginning of the next line. If your downstream processing requires a certain blanking interval, specify that interval in this property. This value must be an integer between 1 and 1195. The object includes a buffer that stores the output pixels until the minimum number of blanking cycles is reached.

The recommended minimum horizontal blanking interval for Vision HDL Toolbox™ System objects that use a line buffer is 2×Kw when using padding or 12 cycles when you set the PaddingMethod property to 'None'. For more information on blanking requirements for image processing systems, see Configure Blanking Intervals.

Dependencies

To enable this property, set the InsertHorizontalBlanking property to true.

Method of interpolating pixel values in horizontal and vertical directions, specified as one of these types:

  • 'Bilinear' — The object implements a two-tap filter where the taps are the current and previous pixel values.

  • 'Nearest Neighbor' — The object implements muxes to select the closest of the current pixel value or the previous pixel value. This interpolation method uses the fewest hardware resources, at the tradeoff of coarser interpolation accuracy.

For more information about interpolation methods, see the Change Image Size example.

Comparison of interpolation accuracy

When you set this property to true, the object applies an antialiasing filter to the input image before the resize operation. The antialiasing filter is a separable 5-by-5 filter. The coefficients are [1 4 6 4 1]/16.

When the input is any integer or fixed-point data type, the algorithm uses fixed-point arithmetic for internal calculations. This property does not apply when the input data type is single or double.

When the input is any integer or fixed-point data type, the algorithm uses fixed-point arithmetic for internal calculations. This property does not apply when the input data type is single or double.

Data type for the filter coefficients, specified as numerictype(0,WL), where the type is unsigned and WL is a word length in the range 2 to 17. The object computes the binary point scaling to accommodate the interpolation coefficients. When converting the coefficients to the specified data type, the object uses the settings of the RoundingMethod and OverflowAction properties.

The interpolation filter also limits the internal pixel data types to 24 bits wide so that the filter maps to DSP blocks on your FPGA.

Specify the data type for the output pixels as 'Same as first input' or as a data type expression in the form numerictype(0,WL,0), where the type is unsigned and WL is in the range 8 to 16.

  • 'Same as first input' — Sets the data type of the output pixels to match the data type of the input pixel argument.

  • <data type expression> — Sets the data type of the output pixels to this data type.

When converting the pixel values to the specified data type, the object uses the settings of the RoundingMethod and OverflowAction properties.

Usage

Description

[pixelout,ctrlout] = resizer(pixelin,ctrlin) returns the next pixel, pixelout, of the resized image resulting from resampling the image described by the input pixel stream, pixelin, according to the properties of the object.

[pixelout,ctrlout] = resizer(pixelin,ctrlin,inputSize,outputSize) expects an input pixel stream with frames of inputSize dimensions and returns a pixel stream with frames of outputSize dimensions. Use this syntax when you have set the InputSizeSource and OutputSizeSource properties to 'Input port'. Specify the size of an input or output frame as a row vector of the form [ActiveVideoLines,ActivePixelsPerLine].

Input Arguments

expand all

Single pixel, specified as a scalar value.

The software supports double and single data types for simulation, but not for HDL code generation.

Data Types: uint8 | uint16 | fi(0,WL,0), WL between 8 and 16 | double | single

Control signals accompanying the input pixel stream, specified as a pixelcontrol structure containing five logical data type signals. The signals describe the validity of the pixel and its location in the frame. For more details, see Pixel Control Structure.

Data Types: struct

Dimensions of the input frame, specified as a row vector of the form [ActiveVideoLines,ActivePixelsPerLine]. The dimensions must be integers greater than or equal to [16,16] and less than or equal to [4320,8192].

The software supports double and single data types for simulation, but not for HDL code generation.

Dependencies

To enable this argument, set the InputSizeSource property to 'Input port'.

If you enable both inputSize and outputSize arguments, and those inputs use a fixed point type, both arguments must use the same fixed point type.

Data Types: single | double | uint8 | uint16 | fixdt(0,WL,0), WL up to 16

Dimensions of the output frame, specified as a row vector of the form [ActiveVideoLines,ActivePixelsPerLine]. The dimensions must be integers greater than or equal to [16,16] and less than or equal to [4320,8192].

The output dimensions must be less than or equal to the input dimensions.

The software supports double and single data types for simulation, but not for HDL code generation.

Dependencies

To enable this argument, set the OutputSizeSource property to 'Input port'.

If you enable both inputSize and outputSize arguments, and those inputs use a fixed point type, both arguments must use the same fixed point type.

Data Types: single | double | uint8 | uint16 | fixdt(0,WL,0), WL up to 16

Output Arguments

expand all

Single pixel of a resized pixel stream, returned as a scalar value.

Configure the data type of the output pixel by using the OutputDataType property.

Data Types: uint8 | uint16 | fi(0,WL,0), WL between 8 and 16 | double | single

Control signals accompanying the output pixel stream, returned as a pixelcontrol structure containing five logical data type signals. The signals describe the validity of the pixel and its location in the frame. For more details, see Pixel Control Structure.

Data Types: struct

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Extended Capabilities

Version History

Introduced in R2023a