Extract image from ROS Image message
ROS Toolbox / ROS
The Read Image block extracts an image from a
CompressedImage message. You can select the ROS message parameters of a
topic active on a live ROS network or specify the message parameters separately. The ROS
messages are specified as a nonvirtual bus. Use the Subscribe block output to receive a message from a ROS network and input
the message to the Read Image block.
When reading ROS image messages from the network, the
property of the message can exceed the maximum array length set in Simulink®. To increase the maximum array length, click Tools > Manage Array Lengths > Robot Operating System, select the Data array, and increase the size
based on the number of points in the image.
Image— Extracted image signal
Extracted image signal from ROS message, returned as an
M-by-N-by-3 matrix for color
images, and an M-by-N matrix for
grayscale images. The matrix contains the pixel data from the
Data property of the ROS message.
AlphaChannel— Alpha channel for image
Alpha channel for image, returned as an
M-by-N matrix. This matrix is
the same height and width as the image output and has values
1] to indicate the opacity of each corresponding pixel,
with a value of 0 being completely transparent.
messages, the Alpha channel returns all zeros if the
Show Alpha output port is
ErrorCode— Error code for image conversion
Error code for image conversion, returned as a scalar. The error code values are:
0 – Successfully converted the image
1 – Incorrect image encoding. Check
that the incoming message encoding matches the
2 – The dimensions of the image message
exceed the limits specified in the
3 – The
of the image message was truncated. See Manage Array Sizes for ROS Messages in Simulink to increase the maximum
length of the array.
04 – Image decompression
Maximum Image Size— Maximum image size
[2000 2000](default) | two-element vector
Maximum image size, specified as a two-element
Click Configure using ROS ... to set this parameter automatically using an active topic on a ROS network. You must be connected to the ROS network.
Image Encoding— Image encoding
Image encoding for the input
ImageMsg. Select the
supported encoding type which matches the
property of the message. For more information about encoding types, see
Show Alpha output port— Toggle AlphaChannel port
Toggle Alpha channel output port if your encoding supports an Alpha channel.
Only certain encoding types support alpha channels. The
ImageEncoding parameter determines if this
parameter appears in the block mask.
Show error code output port— Toggle ErrorCode port
ErrorCode port to monitor errors.
Output variable-size signals— Toggle variable-size signal output
Toggle variable-size signal output. Variable-sized signals should only be used if the image size is expected to change over time. For more information about variable sized signals, see Variable-Size Signal Basics (Simulink).