Main Content

Simulink.ImageType

Specify image data type

Since R2021b

Description

Use a Simulink.ImageType object to set and share image data types for signal, state, and parameter data in a model.

  1. Create an instance of this class in the MATLAB® base workspace.

  2. Set the properties of the object to describe the image.

  3. Assign the data type to supported blocks, which have a Data type parameter, that you want to conform to the data type.

The benefits of the Simulink.ImageType data type include:

  • Strong typing of image data at model interfaces.

  • Carrying image data attributes such as color format and pixel data type, eliminating the need to create and maintain secondary signals.

  • Enabling the Simulink® environment to interpret the data as an image.

  • Enabling custom data type replacement with third party implementation, such as the OpenCV class cv::Mat.

Note

To simulate a model that contains Simulink.ImageType signal, set the model configuration parameter Language (SimTargetLang) to C++.

Creation

To create a Simulink.NumericType object programmatically, use the Simulink.NumericType function described below.

Description

imageType = Simulink.ImageType returns a Simulink.Parameter object with default property values.

imageType = Simulink.ImageType(Rows,Columns,Channels) returns a Simulink.ImageType object and initializes the Rows, Columns, and Channels property to the specified values.

imageType = Simulink.ImageType(Rows,Columns,Channels,'ClassUnderlying',ClassUnderlying,'ColorFormat',ColorFormat,'Layout',Layout) returns a Simulink.ImageType object and additionally initializes the optional properties ClassUnderlying, ColorFormat, and Layout to the specified values.

Properties

expand all

Number of rows in the image data, specified as a positive integer.

Example: 480

Data Types: double

Number of columns in the image data, specified as a positive integer.

Example: 640

Data Types: double

Number of color channels or samples for each pixel in the array, specified as 1, 3, or 4. The number of channels must correspond to the number of color channels in the color format of the image data. These are the values of Channels for the supported color formats:

Color FormatChannels
Grayscale1
RGB3
BGR3
BGRA4

Example: 3

Data Types: double

Data type of the underlying image data, specified as one of these values:

  • 'uint8'

  • 'int8'

  • 'uint16'

  • 'int16'

  • 'uint32'

  • 'int32'

  • 'single'

  • 'double'

  • 'boolean'

Example: 'uint8'

Data Types: char | string

Color format of the underlying image data, specified as 'RGB', 'Grayscale', 'BGR', or 'BGRA'. The color format determines what each color channel of a pixel in the image represents.

Example: 'RGB'

Data Types: char | string

Memory arrangement of the matrix data in the image, specified as 'ColumnMajor' or 'RowMajor'.

Example: 'ColumnMajor'

Data Types: char | string

Examples

collapse all

  1. Create a Simulink.ImageType object with default values.

    imageType = Simulink.ImageType;
    imageType = 
    
      ImageType with properties:
    
                   Rows: 480
                   Cols: 640
               Channels: 3
        ClassUnderlying: 'uint8'
            ColorFormat: 'RGB'
                 Layout: 'ColumnMajor'

  2. Set the properties of the object to describe the image.

    imageType.Rows = 720
    imageType.Cols = 860

    You can then reference this object from supported blocks that have a Data type field parameter.

Limitations

These blocks support simulation and code generation of a Simulink.ImageType object:

Block LibraryBlock Name
Sources
Signal Routing
Sinks
Ports & Subsystems
Discrete
Signal Attributes
User-Defined Functions

Extended Capabilities

Version History

Introduced in R2021b