Image To Matrix
Libraries:
Computer Vision Toolbox OpenCV Interface for Simulink
Description
The Image To Matrix block converts Simulink® image data to matrix data.
Examples
Smile Detection by Using OpenCV Code in Simulink
Build a smile detector by using the OpenCV Importer app. The detector estimates the intensity of the smile on a face image or a video. Based on the estimated intensity, the detector identifies an appropriate emoji from its database, and then places the emoji on the smiling face.
Convert RGB Image to Grayscale Image by Using OpenCV Importer
Convert an RGB image to a grayscale image by using the OpenCV Importer app. The converter converts an RGB image to a grayscale image by eliminating the hue and saturation information while retaining the luminance.
Shadow Detection by Using OpenCV Code in Simulink
Detect shadows in a recorded video by using the OpenCV Importer app.
Ports
Input
Port_1 — Input signal
Simulink.ImageType
Input signal to the Image To Matrix block. The input is a Simulink image data type.
Data Types: Simulink.ImageType
Output
Port_1 — Output signal
matrix
Output signal from the Image To Matrix block. The output is a matrix or an array, depending on the format of the input.
M-by-N matrix — The input is a
Grayscale
image. M and N are the height and width of the image, in pixels.M-by-N-by-C matrix — The input is an
RGB
orBGR
image. M and N are the height and width of the image, in pixels. C is the number of color channels.
Data Types: uint8
| uint16
| int8
| int16
| single
| double
Parameters
Rows — Number of rows in image data
'480'
(default) | positive integer
Specify the number of rows in the image data as a positive integer.
Programmatic Use
Block Parameter:
Rows |
Type:
double |
Value: positive integer |
Default:
'480'
|
Columns — Number of columns in image data
'640'
(default) | positive integer
Specify the number of columns in the image data as a positive integer.
Programmatic Use
Block Parameter:
Columns |
Type:
double |
Value: positive integer |
Default:
'640'
|
Channels — Number of color channels or samples for each pixel
3
(default) | 1
Specify the number of color channels or samples for each pixel in the array 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 Format | Channels |
---|---|
Grayscale | 1 |
RGB | 3 |
BGR | 3 |
Programmatic Use
Block Parameter:
Channels |
Type:
double |
Value: positive integer |
Default:
'3'
|
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Supports C++ code generation.
Version History
Introduced in R2021b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)