ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Is our depth image already 8 Bit? Otherwise you'll have to find a smart way to scale it to 8 Bit, which might be tricky;)

Assuming your depth image is cv::Mat of type CV_8UC1 and your RGB image is cv::Mat of type CV_8UC3 with color space BGR it is quite easy ():

std::vector<cv::Mat> channels;
// split the channels
cv::splt( rgb_image, channels );

// blend depth image into each channel
channels[ 0 ] = (channels[ 0 ] * 0.5) +  ( depth_image * 0.5 );
channels[ 1 ] = (channels[ 1 ] * 0.5) +  ( depth_image * 0.5 );
channels[ 2 ] = (channels[ 2 ] * 0.5) +  ( depth_image * 0.5 );

// merge to overlayed image
cv::Mat blended;
cv::merge( channels, blended );

Is our depth image already 8 Bit? Otherwise you'll have to find a smart way to scale it to 8 Bit, which might be tricky;)

Assuming your depth image is cv::Mat of type CV_8UC1 and your RGB image is cv::Mat of type CV_8UC3 with color space BGR it is quite easy ():easy:

std::vector<cv::Mat> channels;
// split the channels
cv::splt( rgb_image, channels );

// blend depth image into each channel
channels[ 0 ] = (channels[ 0 ] * 0.5) +  ( depth_image * 0.5 );
channels[ 1 ] = (channels[ 1 ] * 0.5) +  ( depth_image * 0.5 );
channels[ 2 ] = (channels[ 2 ] * 0.5) +  ( depth_image * 0.5 );

// merge to overlayed image
cv::Mat blended;
cv::merge( channels, blended );

Is our depth image already 8 Bit? Otherwise you'll have to find a smart way to scale it to 8 Bit, which might be tricky;)

Assuming your depth image is cv::Mat of type CV_8UC1 and your RGB image is cv::Mat of type CV_8UC3 with color space BGR it is quite easy:

std::vector<cv::Mat> channels;
// split the channels
cv::splt( cv::split( rgb_image, channels );

// blend depth image into each channel
channels[ 0 ] = (channels[ 0 ] * 0.5) +  ( depth_image * 0.5 );
channels[ 1 ] = (channels[ 1 ] * 0.5) +  ( depth_image * 0.5 );
channels[ 2 ] = (channels[ 2 ] * 0.5) +  ( depth_image * 0.5 );

// merge to overlayed image
cv::Mat blended;
cv::merge( channels, blended );