Main Content


Specify image data type


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.


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


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.


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 or 3. 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

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'

  • 'logical'

Example: 'uint8'

Data Types: char | string

Color format of the underlying image data, specified as 'RGB', 'Grayscale', or 'BGR'. 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


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.


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

Block LibraryBlock Name
  • Ground

  • Inport

  • Outport

  • From Multimedia File (Computer Vision Toolbox™)

Signal Routing
  • Goto

  • From

  • Data Store Read

  • Data Store Write

  • Data Store Memory

  • Switch

  • Multiport Switch

  • Merge

  • Variant Source

  • Variant Merge (internal block added during code generation)

  • Mux

  • Demux

  • Vector Concatenate, Matrix Concatenate

  • Selector

  • Terminator

  • Video Viewer (Computer Vision Toolbox) (simulation only)

Ports & Subsystems
  • Subsystem, Atomic Subsystem, CodeReuse Subsystem

  • Enabled Subsystem

  • Triggered Subsystem

  • Function-Call Subsystem

  • If

  • Switch Case

  • Resettable Subsystem

  • For Iterator Subsystem

  • Model

  • Unit Delay

Signal Attributes
  • Signal Conversion

  • Signal Specification

User-Defined Functions
  • Initialize Function, Reset Function, and Terminate Function

  • Simulink Function block with side I/O and arguments

Extended Capabilities

Introduced in R2021b