Note: also posted on answers.ros.org at https://answers.ros.org/question/292031/matlab-16uc1-or-32fc1-conversion/
ROS Image Encoding 16UC1 and 32FC1
9 次查看(过去 30 天)
显示 更早的评论
I have some image processing code in MATLAB and am attempting to use it with ROS. I read in a PointCloud2 object and execute readRGB(ptcloud) and readXYZ(ptcloud)where I get two MATLAB images each of size 480x640x3.
Q1: I assume that a depth image of size NxMx3 gives X, Y, and Z distances as the three channels. Is this correct??
I then execute my processing and need to send a depth image back encoded in either 16uc1 or 32fc1. I have not found a built-in MATLAB function for this. I can write a conversion script myself but I am unfamiliar with these formats.
Q2: What is the general algorithm to convert my NxMx3 matrix into either format?
My depth camera node publishes a depth image in the 16uc1 format. When I subscribe to that in MATLAB and execute readImage(ros_image) I get an image of size 480x640x1 in MATLAB but when I execute rostopic echo /ros_depth_image_topic I see the data is given as "data: array: type uint8, length: 614400".
Q3: I notice this is 480*640*2 so why does MATLAB only read in a 480x640x1 image? How do the 614400 data points translate to only 307200 data points in MATLAB?
Thank you for any assistance offered!
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Network Connection and Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!