Image
data is (H, W) or (H, W, C) in the dtype encoding names; the dtype is kept as is.
Full docstring
Depth conventions follow ROS: 16UC1 is millimetres, 32FC1 is metres.
Preview
The figure robot_msgs.viz.plot(example) draws for the example below.

Fields
| Name | Type | Default |
|---|---|---|
data | Array | required |
encoding | str | required |
header | Header | Header() |
Example
One instance from the package's own test catalog; the output is its real repr().
Image(data=uint8[48×64×3], encoding='rgb8', header=Header(stamp=1761600000.25, frame_id='camera_color_optical_frame'))to_dict() as JSON
{
"_type": "sensor/Image",
"data": {
"dtype": "|u1",
"shape": [48, 64, 3],
"data": [190, 247, 186, 149, 158, 191, 65, 42, 139, 169, 209, 225, 199, 36, 223, 245, "… 9200 more values"]
},
"encoding": "rgb8",
"header": {
"_type": "std/Header",
"stamp": 1761600000.25,
"frame_id": "camera_color_optical_frame",
"meta": {}
}
}Long arrays are cut after 16 values and say so with “…”.
Functions
Constructors
Classmethods and staticmethods: ways to build one.
from_array(
array: Array,
encoding: str | None = None,
header: Header | None = None,
) -> ImageWrap an array. Without encoding, infer it where only one reading is sensible.
Properties
Read-only views computed from the fields.
Methods
Return new values; messages are never mutated.
crop(x_offset: int, y_offset: int, width: int, height: int) -> ImageThe width×height window whose top-left pixel is (x_offset, y_offset).
to_rgb() -> Array(H, W, 3) uint8 for display. Depth and 16-bit images are min-max normalised to grey.
to_dict
from Msgto_dict() -> dict[str, Any]JSON-safe dict with a "_type" key; arrays keep their dtype and shape.